--- pipe2sap.pl 2003/02/03 14:24:55 1.3 +++ pipe2sap.pl 2003/03/10 15:49:01 1.7 @@ -21,7 +21,7 @@ # open log and redirect die to it... open(LOG,">> $log") || warn "open log $log: $!"; -local $SIG{__DIE__} = sub { print LOG $_[0] ; die $_[0] }; +local $SIG{__DIE__} = sub { print scalar localtime LOG $_[0] ; die $_[0] }; # directory in which files will be left my $outdir = $config->{outdir} || die "config: on defined"; @@ -33,7 +33,7 @@ my $outfile = $config_file; $outfile =~ s/\.xml//i; $outfile =~ s/^.*\/([^\/]+)/$1/i; # basename -$outfile .= "_${yy}-${mm}-${dd}_${hh}:${mm}:${ss}_$$"; +$outfile .= sprintf("_%04d-%02d-%02d_%02d:%02d:%02d_%d",$yy,$mm,$dd,$hh,$mm,$ss,$$); my $rfc = new SAP::Rfc( ASHOST => $config->{sap}->{ashost}, @@ -62,13 +62,14 @@ my @data; # array for order my $lines; # number of lines in order +my $nr; # order number my $first = ; push @data,$first; chomp $first; $first=~s/ //g; if ($first =~ m/\s+(\d+)\s+(\d+)\w+\s*$/) { - my ($nr,$lines) = ($1,$2); + ($nr,$lines) = ($1,$2); print "Processing $lines lines order no. $nr\n"; } else { die "FATAL: can't find number of lines in first line ($first) of input file."; @@ -83,11 +84,11 @@ if ($#data != $lines) { print "FATAL: file integrity check failed: "; if ($#data > $lines) { - print "too many"; + print "too many ($#data > $lines)"; } else { - print "too few"; + print "too few ($#data < $lines)"; } - print " lines ($#data)...\n"; + print " lines...\n"; } else { print "File integrity checked, saving file...\n"; open(OUT, "> $outdir/$outfile") || die "FATAL: can't open '$outdir/$outfile': $!"; @@ -96,9 +97,10 @@ print OUT $first,@data; close(OUT); - # cludge filename to nark.0004 - rename "$outdir/$outfile", "$outdir/nark.0004"; - $it->FILENAME("nark.0004"); + # cludge filename to medika + link("$outdir/$outfile","$outdir/medika"); + chmod 0664,"$outdir/medika"; + $it->FILENAME("medika"); # call SAP R/3 $rfc->callrfc( $it );