--- pipe2sap.pl 2003/02/03 13:36:52 1.2 +++ pipe2sap.pl 2003/02/06 08:45:46 1.5 @@ -29,10 +29,11 @@ # create output filename my ($ss,$mm,$hh,$dd,$mm,$yy) = localtime(time); $yy += 1900; +$mm++; 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}, @@ -61,14 +62,15 @@ 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+)\w+\s*$/) { - $lines = $1; - print "Processing $lines lines\n"; +if ($first =~ m/\s+(\d+)\s+(\d+)\w+\s*$/) { + ($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."; } @@ -82,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': $!"; @@ -95,6 +97,10 @@ print OUT $first,@data; close(OUT); + # cludge filename to nark.0004 + #rename "$outdir/$outfile", "$outdir/nark.0004"; + #$it->FILENAME("nark.0004"); + # call SAP R/3 $rfc->callrfc( $it ); }