Subject: | Problem with SAP::Iface : structure not filled? |
Hello Piers!
I just stumbled over your SAP::Rfc.
Great work! With it I'm able to learn about SAP, RFC and Perl and to write some really helpful and productive programs. :-)
Unfortunately I have a problem with it while playing with a modified version of your examples/reports.pl.
And I don't know if it's a bug in your module or in my Perl code (or in my head...)
I'm using perl, v5.6.1/i386-linux with your newest 1.32/1.31 SAP::Rfc against a SAP 4.6C running on AIX 5.2.
The following program:
-- %< ------
#!/usr/bin/perl
use strict;
use warnings;
use SAP::Rfc;
use Data::Dumper;
my $st;
my @a;
# get a list of report names from table TRDIR
# and then get the source code of each
my $rfc = new SAP::Rfc(
ASHOST => 'myhost',
USER => 'a_user',
PASSWD => 'secret',
LANG => 'DE',
CLIENT => '030',
SYSNR => '40',
TRACE => '1' );
my $if_table = $rfc->discover("RFC_READ_TABLE");
$if_table->QUERY_TABLE('TRDIR');
$if_table->DELIMITER('|');
$if_table->ROWCOUNT( 1 );
$if_table->OPTIONS( ["NAME LIKE 'ZBC%'"] );
$rfc->callrfc( $if_table );
print "No. of progs: ".$if_table->tab('DATA')->rowCount()." \n";
my $if_report = $rfc->discover( "RFC_READ_REPORT" );
my $total = 0;
my $cnt = 0;
for my $row ( $if_table->DATA ){
my $prog = (split(/\|/,$row))[0];
$if_report->reset();
$if_report->PROGRAM( $prog );
$rfc->callrfc( $if_report );
$cnt++;
my $rows = ( $if_report->QTAB );
$total += $rows;
print "\n------------\n";
print "No. $cnt PROGRAM: $prog ROWS: $rows TOTAL: $total \n------------\n";
# ?!? If not at least one of the following 3 commands
# is executed, the last two prints will fail
# with "uninitialized value"
#print Dumper( $if_report->TRDIR() ); # 1.)
#print $if_report->TRDIR() . "\n"; # 2.)
#$if_report->TRDIR(); # 3.)
$st = $if_report->parm("TRDIR")->structure();
print " ## struc-name=" . $st->name() . "\n";
print " " . $st->NAME() . "\n"; # failing without one of
print " " . $st->fieldValue('NAME') . "\n"; # the above command(s) 1-3
}
$rfc->close();
-- %< ------
fails with "Use of uninitialized value in print ...".
If I uncomment one of the numbered commands (1-3) it works.
So it looks like that the internal data structures aren't filled with data when I expected them to be.
The above line
print " ## struc-name=" . $st->name() . "\n";
always works, so I thought the data to be there.
But the following print commands fail.
Perhaps I'm simply a Perl newbie (what I am).
Would you please be so kind and have a short look?
Cheers
Christian