1 |
#!/usr/bin/perl -w |
#!/usr/bin/suidperl |
2 |
|
|
3 |
# read e-mail from stdit (pipe from /etc/aliases) and call SAP rfc function |
# read e-mail from stdit (pipe from /etc/aliases) and call SAP rfc function |
4 |
# |
# |
29 |
open(LOG,">> $log") || warn "open log $log: $!"; |
open(LOG,">> $log") || warn "open log $log: $!"; |
30 |
local $SIG{__DIE__} = sub { print LOG $_[0] ; die $_[0] }; |
local $SIG{__DIE__} = sub { print LOG $_[0] ; die $_[0] }; |
31 |
|
|
|
# init SAP rfc |
|
|
# |
|
|
my $rfc = new SAP::Rfc( |
|
|
ASHOST => $config->{sap}->{ashost}, |
|
|
USER => $config->{sap}->{user}, |
|
|
PASSWD => $config->{sap}->{passwd}, |
|
|
LANG => $config->{sap}->{lang}, |
|
|
CLIENT => $config->{sap}->{client}, |
|
|
SYSNR => $config->{sap}->{sysnr}, |
|
|
TRACE => $config->{sap}->{trace} |
|
|
) || die "new: $!"; |
|
|
|
|
|
|
|
|
# no user editable content beyond this point |
|
|
|
|
32 |
umask 022; # world readable |
umask 022; # world readable |
33 |
|
|
|
$rfc->is_connected || die "SAP rfc: not connected"; |
|
34 |
|
|
35 |
#------------------------------------------------------------ |
#------------------------------------------------------------ |
36 |
# dump_entity - dump an entity's file info |
# dump_entity - dump an entity's file info |
66 |
|
|
67 |
# now, call SAP rfc |
# now, call SAP rfc |
68 |
|
|
69 |
my $it = $rfc->discover("Z_ZDMM0123_SIGMA_RFC") || die "discover: $!"; |
# init SAP rfc |
70 |
|
# |
71 |
|
my $rfc = new SAP::Rfc( |
72 |
|
ASHOST => $config->{sap}->{ashost}, |
73 |
|
USER => $config->{sap}->{user}, |
74 |
|
PASSWD => $config->{sap}->{passwd}, |
75 |
|
LANG => $config->{sap}->{lang}, |
76 |
|
CLIENT => $config->{sap}->{client}, |
77 |
|
SYSNR => $config->{sap}->{sysnr}, |
78 |
|
TRACE => $config->{sap}->{trace} |
79 |
|
) || die "new: $!"; |
80 |
|
|
81 |
|
$rfc->is_connected || die "SAP rfc: not connected"; |
82 |
|
|
83 |
|
my $it = $rfc->discover($config->{sap}->{discover}) || die "discover: $!"; |
84 |
|
|
85 |
|
foreach my $p ($config->{sap}->{params}) { |
86 |
|
foreach my $p_name (keys %{$p}) { |
87 |
|
$it->$p_name($p->{$p_name}); |
88 |
|
} |
89 |
|
} |
90 |
|
|
|
$it->FILEPATH( "ZSIGMA" ); |
|
91 |
$it->FILENAME( $new ); |
$it->FILENAME( $new ); |
|
$it->PORT( "ZIDOC" ); |
|
92 |
|
|
93 |
$rfc->callrfc( $it ); |
$rfc->callrfc( $it ); |
94 |
|
|
95 |
|
$rfc->close(); |
96 |
} |
} |
97 |
} |
} |
98 |
} |
} |
99 |
|
|
|
$rfc->close(); |
|
100 |
|
|
101 |
#------------------------------------------------------------ |
#------------------------------------------------------------ |
102 |
# main |
# main |