/[sap_import]/dir2sap.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

Annotation of /dir2sap.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Thu Mar 20 10:13:13 2003 UTC (19 years, 8 months ago) by dpavlin
Branch: MAIN
File MIME type: text/plain
import all files from some directory, for LIMS integration

1 dpavlin 1.1 #!/usr/bin/perl -w
2     #
3     # Read files from directory and import them to SAP
4     #
5    
6     use strict;
7     use SAP::Rfc;
8     use Data::Dumper;
9     use XML::Simple;
10     use AnyDBM_File;
11     use Fcntl; # for O_* values
12    
13     my $config_file;
14    
15     if ($#ARGV < 0) {
16     print "usage: $0 config.xml\n";
17     exit 1;
18     } else {
19     $config_file = $ARGV[0];
20     }
21    
22     $|++;
23    
24     my $config = XMLin($config_file);
25    
26     my $log = $config->{log} || die "config: no <log> defined";
27    
28     # open log and redirect die to it...
29     open(LOG,">> $log") || warn "open log $log: $!";
30     local $SIG{__DIE__} = sub { print LOG scalar localtime $_[0] ; die $_[0] };
31    
32     # directory in which are files
33     my $indir = $config->{indir} || die "config: no <indir> defined";
34    
35     # directory in which are files
36     my $dbm = $config->{dbm} || die "config: no <dbm> defined";
37    
38     my %dbmhash;
39     tie %dbmhash, "AnyDBM_File", $dbm, O_RDWR || die "tie: can't tie to '$dbm': $!";
40    
41     my $rfc = new SAP::Rfc(
42     ASHOST => $config->{sap}->{ashost},
43     USER => $config->{sap}->{user},
44     PASSWD => $config->{sap}->{passwd},
45     LANG => $config->{sap}->{lang},
46     CLIENT => $config->{sap}->{client},
47     SYSNR => $config->{sap}->{sysnr},
48     TRACE => $config->{sap}->{trace}
49     ) || die "new: $!";
50    
51     $rfc->is_connected || die "FATAL: SAP not connected";
52    
53     my $it = $rfc->discover($config->{sap}->{discover}) || die "FATAL: SAP discover: $!";
54    
55     foreach my $p ($config->{sap}->{params}) {
56     foreach my $p_name (keys %{$p}) {
57     # print "$p_name --> ",$p->{$p_name},"\n";
58     $it->$p_name($p->{$p_name});
59     }
60     }
61    
62     ## FIX
63     my $file="foobar";
64    
65     # override FILENAME with my name
66     $it->FILENAME($file);
67     print "Using file '$file'\n";
68    
69     # call SAP R/3
70     $rfc->callrfc( $it );
71    
72     $rfc->close();
73    

  ViewVC Help
Powered by ViewVC 1.1.26