#!/usr/local/bin/perl -w
####################################################
####### Defines for your Idoc Environment ##########
####################################################
use strict;
my $OUT = '/peregrine/EDI_SAPDIR/NP2V4/out';
my $HOLD = '/peregrine/EDI_SAPDIR/NP2V4/hold';
my $infile = ($ARGV[0]);
my $translator = "/peregrine/tlrt/bin/tlreqc -p7772 -rxlato -- $OUT";
print "This is my infile : $infile\n";
# Incoming argument will be a file
# We assume the file is in the correct directory
# If we exit with an error - we fail -
# and the program calling us will take care of the
# rollback processing......
# We are also supposed to take care of the file
# we were given - i.e. delete it after processing
# We really only want one filename to be in there....
#
# Open In and out.....
my $outfile = $infile;
open (INPUT,"$infile") || die "Could not open infile\n";
$outfile =~s/.*\///;
open (OUT,">$OUT/$outfile") || die "Could not open outfile\n";
while (<INPUT>) {
chomp;
s/RFCNP2V4 /SAPNP2_V4/g;
print OUT "$_\n";
}
close(INPUT) || die "Failed closing file";
close(OUT) || die "Failed closing outfile";
unlink($infile) || die "Could not remove original file";
system("/usr/bin/cp $OUT/$outfile $HOLD") == 0 or die "system archiving failed: $?" ;
system($translator) == 0 or die "system $translator failed: $?" ;
print "TRANSLATION OK\n";