/[sap_import]/mail2sap.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /mail2sap.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by dpavlin, Mon Nov 18 14:23:39 2002 UTC revision 1.2 by dpavlin, Tue Nov 19 08:34:40 2002 UTC
# Line 8  require 5.001; Line 8  require 5.001;
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    
# Line 21  my $outdir = "/var/autofs/data/export_si Line 21  my $outdir = "/var/autofs/data/export_si
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',
# Line 31  my $rfc = new SAP::Rfc( Line 37  my $rfc = new SAP::Rfc(
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
# Line 67  sub dump_entity { Line 67  sub dump_entity {
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      }      }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.26