/[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.2 by dpavlin, Tue Nov 19 08:34:40 2002 UTC revision 1.5 by dpavlin, Tue Nov 19 10:43:46 2002 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl -w  #!/usr/bin/suidperl -w
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  #  #
# Line 11  use vars qw($Msgno); Line 11  use vars qw($Msgno);
11  use SAP::Rfc;  use SAP::Rfc;
12  use Digest::MD5 qw(md5_hex);  use Digest::MD5 qw(md5_hex);
13  use MIME::Parser;  use MIME::Parser;
14    use XML::Simple;
15    use Data::Dumper;
16    
17  # configuration  # read configuration from xml file
18    my $config = XMLin();
19    
20  # directory in which attachemnts will be left  # directory in which attachemnts will be left
21  my $outdir = "/var/autofs/data/export_sigma";  my $outdir = $config->{outdir} || die "config: on <outdir> defined";
22  # temporary directory (ON SAME FILESYSTEM AS $outdir -- we use rename!)  # temporary directory (ON SAME FILESYSTEM AS $outdir -- we use rename!)
23  # for extraction of *ALL* attachements  # for extraction of *ALL* attachements
24  my $msgdir = "/var/autofs/data/export_sigma/mime$$";    # temp  my $msgdir = $config->{msgdir} || die "config: no <msgdir> defined";
25  my $log = "/data/sap_sigma/orders.log";  $msgdir .= "$$";        # append PID to make it unique
26    my $log = $config->{log} || die "config: no <log> defined";
27    
28  # open log and redirect die to it...  # open log and redirect die to it...
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   => 'cipkg',  
         USER     => 'rfctest',  
         PASSWD   => 'dinamo',  
         LANG     => 'HR',  
         CLIENT   => '200',  
         SYSNR    => '20',  
         TRACE    => '0'  
         ) || 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
# Line 78  sub dump_entity { Line 66  sub dump_entity {
66    
67                  # now, call SAP rfc                  # now, call SAP rfc
68    
69                    # 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("Z_ZDMM0123_SIGMA_RFC") || die "discover: $!";                  my $it = $rfc->discover("Z_ZDMM0123_SIGMA_RFC") || die "discover: $!";
84    
85                  $it->FILEPATH( "ZSIGMA" );                  $it->FILEPATH( "ZSIGMA" );
# Line 85  sub dump_entity { Line 87  sub dump_entity {
87                  $it->PORT( "ZIDOC" );                  $it->PORT( "ZIDOC" );
88    
89                  $rfc->callrfc( $it );                  $rfc->callrfc( $it );
90    
91                    $rfc->close();
92          }          }
93      }      }
94  }  }
95    
 $rfc->close();  
96    
97  #------------------------------------------------------------  #------------------------------------------------------------
98  # main  # main

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

  ViewVC Help
Powered by ViewVC 1.1.26