Subject: | Re my'ed variable generaes lots of warnings |
At line 585 we have the variable $idoc my'ed, yet it has been my'ed already just before. Naturally this generates an error/warning about redefining a variable that's still in scope.
# method to return an IDOC object of SAP::IDOC type
sub lookupIdoc {
my $self = shift;
my $idoc = shift; ##### First my
if ($CACHE && -f $CACHE."/idocs/".$idoc.".txt"){
my $idoc1;
open(IDOC, "<$CACHE/idocs/".$idoc.".txt") or
warn "cant open structure file $CACHE/idocs/".$idoc.".txt - $!";
$idoc = join("",(<IDOC>));
close IDOC;
eval($idoc);
return $idoc1;
}
my $idoc = new SAP::Idoc( 'NAME' => $idoc, ###### Second my
'SINGLE' => $self->discover('IDOC_INBOUND_SINGLE'),
'MANDT' => $self->{'CLIENT'},
);
# discover the complete structure of an IDOC
my $idoctype = $self->discover('IDOCTYPE_READ_COMPLETE');
$idoctype->PI_IDOCTYP($idoc->name);
my $segments = $idoctype->tab('PT_SEGMENTS');
$self->callrfc($idoctype);
while ( my $row = $segments->nextRow() ){
$row->{'SEGMENTTYP'} =~ s/\s//g;
$idoc->_addSegment($self->structure($row->{'SEGMENTTYP'}), $row);
}
# save the structure to the cache
if ($CACHE){
open(IDOC, ">$CACHE/idocs/".$idoc->name().".txt") or
warn "cant open cache file for $CACHE/idocs/".$idoc->name().".txt - $!\n";
$Data::Dumper::Varname = 'idoc';
print IDOC Dumper($idoc);
close IDOC;
}
return $idoc;