#!/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"; }