sap-discover.pl
#!/usr/bin/perl
use strict;
use SAP::Rfc;
use Data::Dumper;
my $rfc_call = uc(shift) || die "No SAP RFC...?\nsap-discover.pl RFC
+_CALL [sap system] [exec RFC]\n";
my $sap_system = lc(shift) || "default.conf";
my $call_sap = shift;
print "Testing:\nSAP::Rfc\t$SAP::Rfc::VERSION\nRFC\t$rfc_call\nConf:\t
+$sap_system\n\n";
my $rfc = SAP::Rfc->new("./$sap_system");
die "ERROR: Unable to create SAP RFC Object\n" unless $rfc;
die "ERROR: ", $rfc->error(), "\n" unless ($rfc->is_connected());
my $iface = $rfc->discover($rfc_call);
if ($iface) {
print "Structure:\n";
print Dumper($iface);
if ($call_sap) {
eval {
$rfc->callrfc($iface);
};
if ($@) {
print "RFC ERROR: ", $rfc->error, "\n\n";
die "$@\n";
}
print "\nRFC Called okay.\n";
print Dumper($iface);
}
} else {
die "ERROR: ", $rfc->error(), "\n";
}
END {
$rfc->close() if $rfc;
print "\n";
}
You'll need some text config files that look like this:
ASHOST sapsystem.com
SYSNR 20
CLIENT 350
LANG E
USER Captain Foo
PASSWD password
TRACE 1
|