8 |
|
|
9 |
use strict; |
use strict; |
10 |
use vars qw($Msgno); |
use vars qw($Msgno); |
11 |
|
use SAP::Rfc; |
12 |
use Digest::MD5 qw(md5_hex); |
use Digest::MD5 qw(md5_hex); |
13 |
use MIME::Parser; |
use MIME::Parser; |
|
use SAP::Rfc; |
|
14 |
|
|
15 |
# configuration |
# configuration |
16 |
|
|
21 |
my $msgdir = "/var/autofs/data/export_sigma/mime$$"; # temp |
my $msgdir = "/var/autofs/data/export_sigma/mime$$"; # temp |
22 |
my $log = "/data/sap_sigma/orders.log"; |
my $log = "/data/sap_sigma/orders.log"; |
23 |
|
|
24 |
|
# open log and redirect die to it... |
25 |
|
open(LOG,">> $log") || warn "open log $log: $!"; |
26 |
|
local $SIG{__DIE__} = sub { print LOG $_[0] ; die $_[0] }; |
27 |
|
|
28 |
|
# init SAP rfc |
29 |
|
# |
30 |
my $rfc = new SAP::Rfc( |
my $rfc = new SAP::Rfc( |
31 |
ASHOST => 'cipkg', |
ASHOST => 'cipkg', |
32 |
USER => 'rfctest', |
USER => 'rfctest', |
37 |
TRACE => '0' |
TRACE => '0' |
38 |
) || die "new: $!"; |
) || die "new: $!"; |
39 |
|
|
|
my $it = $rfc->discover("Z_ZDMM0123_SIGMA_RFC") || die "discover: $!"; |
|
|
|
|
|
$it->FILEPATH( "ZSIGMA" ); |
|
|
$it->PORT( "ZIDOC" ); |
|
40 |
|
|
41 |
# no user editable content beyond this point |
# no user editable content beyond this point |
42 |
|
|
43 |
umask 022; # world readable |
umask 022; # world readable |
44 |
|
|
45 |
open(LOG,">> $log") || warn "log $log: $!"; |
$rfc->is_connected || die "SAP rfc: not connected"; |
|
|
|
|
$rfc->is_connected || die "not connected"; |
|
46 |
|
|
47 |
#------------------------------------------------------------ |
#------------------------------------------------------------ |
48 |
# dump_entity - dump an entity's file info |
# dump_entity - dump an entity's file info |
67 |
$new=~s/ +/_/g; |
$new=~s/ +/_/g; |
68 |
$new=~s/^.*\/([^\/]+)$/$1/g; |
$new=~s/^.*\/([^\/]+)$/$1/g; |
69 |
$new=~s/[^a-zA-Z._0-9]//g; |
$new=~s/[^a-zA-Z._0-9]//g; |
70 |
|
|
71 |
|
# never try to overwrite file |
72 |
|
my $suffix = ""; |
73 |
|
while (-e "$outdir/$new$suffix") { $suffix++; } |
74 |
|
$new .= $suffix; |
75 |
|
|
76 |
rename $file,"$outdir/$new" || die "move $file -> $outdir/$new: $!"; |
rename $file,"$outdir/$new" || die "move $file -> $outdir/$new: $!"; |
77 |
print LOG scalar localtime," $new\n"; |
print LOG scalar localtime," $new\n"; |
78 |
|
|
79 |
# now, call SAP rfc |
# now, call SAP rfc |
80 |
|
|
81 |
$it->FILENAME( "$new" ); |
my $it = $rfc->discover("Z_ZDMM0123_SIGMA_RFC") || die "discover: $!"; |
82 |
|
|
83 |
|
$it->FILEPATH( "ZSIGMA" ); |
84 |
|
$it->FILENAME( $new ); |
85 |
|
$it->PORT( "ZIDOC" ); |
86 |
|
|
87 |
$rfc->callrfc( $it ); |
$rfc->callrfc( $it ); |
88 |
} |
} |
89 |
} |
} |