This queue is for tickets about the SAP-Rfc CPAN distribution.

Report information
The Basics
Id:
9082
Status:
new
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
Christian.Ziemski [...] thyssenkrupp.com
Cc:
AdminCc:

BugTracker
Severity:
Normal
Broken in:
1.31
Fixed in:
(no value)



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
From: Christian.Ziemski@thyssenkrupp.com
Hello Piers! Now I tried it with your new version SAP::Rfc 1.36. A look into the changelog shows: 1.33 Fri Jun 25 10:57:04 NZST 2004 - fix problem where structured parameter values are not recalculated after they have been set via structure- just prior to the RFC call. that seems to be related to my reported problem. It's no longer failing now with "uninitialized value", but the structure is empty when I expected it to be filled. I modified the program from my last message a bit and use Dumper(). Short extract: #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"; # the problem is visible with this Dumper too: print Dumper( $st ); The Dumper($st) lists an empty structure (only name() is working) unless I uncomment one of those three commands 1.) - 3.). Then the structure is completely filled as expected. Is this behavior by design now? Or is there still some internal filling of the structure missing? Cheers Christian
Date: Wed, 9 Feb 2005 18:12:09 +0000
From: Piers Harding <piers@ompa.net>
To: Guest via RT <bug-SAP-Rfc@rt.cpan.org>
CC: Christian.Ziemski@thyssenkrupp.com
Subject: Re: [cpan #9082] Problem with SAP::Iface : structure not filled?
RT-Send-Cc:
Hi Christian, Sorry for not getting back to you sooner. If I understand what you are trying to do correctly, then I think you are missunderstanding who RFC_READ_TABLE works and what you need to interpret the results. RFC_READ_TABLE is just a function module that is designed to generically read tables and return you the results. If you read the table, then you still need to figure out a way of unpacking the rows returned in DATA, for your own purpose. So - what I do is that I specify a blank delimiter in the parameter DELIMITER, and then get hold of a "helper object" that describes the structure of the table that I have chosen to read. Given that the table that I have dynamically read with RFC_READ_TABLE is "TRDIR" then I get a SAP::Struct object for this by executing $rfc->structure("TRDIR"). Then I can feed each row of DATA into this so that it does the tricky business of unpacking the binary structure of that table row. So - as an example: use SAP::Rfc; use Data::Dumper; print "VERSION: ".$SAP::Rfc::VERSION ."\n"; my $rfc = new SAP::Rfc( ASHOST => 'seahorse', USER => 'developer', PASSWD => 'developer', LANG => 'EN', CLIENT => '000', SYSNR => '00', TRACE => '1' ); print " START: ".scalar localtime() ."\n"; my $it = $rfc->discover("RFC_READ_TABLE"); $it->QUERY_TABLE('TRDIR'); $it->ROWCOUNT( 10 ); $it->OPTIONS( [ { TEXT => "NAME LIKE 'SAPL\%RFC\%'" } ] ); $rfc->callrfc( $it ); print "NO. PROGS: ".$it->tab('DATA')->rowCount()." \n"; $if = $rfc->discover( "RFC_READ_REPORT" ); my $str = $rfc->structure('TRDIR'); my $tot = 0; my $c = 0; for my $row ( $it->DATA ){ $c++; $str->value($row); my $prog = $str->NAME; $if->reset(); $if->PROGRAM( $prog ); $rfc->callrfc( $if ); my $rows = ( $if->QTAB ); $tot += $rows; print "No. $c PROGRAM: $prog ROWS: $rows TOTAL: $tot\n"; } $rfc->close(); print " END: ".scalar localtime() ."\n"; print " TOTAL ROWS: $tot \n"; Hope this is on the right track for you. Cheers, Piers Harding. On Wed, Feb 09, 2005 at 04:12:36AM -0500, Guest via RT wrote:
Show quoted text
> > This message about SAP-Rfc was sent to you by guest <> via rt.cpan.org > > Full context and any attached attachments can be found at: > <URL: https://rt.cpan.org/Ticket/Display.html?id=9082 > > > Hello Piers! > > Now I tried it with your new version SAP::Rfc 1.36. > > > A look into the changelog shows: > > 1.33 Fri Jun 25 10:57:04 NZST 2004 > - fix problem where structured parameter values are not recalculated > after they have been set via structure- just prior to the RFC call. > > that seems to be related to my reported problem. > > > It's no longer failing now with "uninitialized value", but the structure > is empty when I expected it to be filled. > > > I modified the program from my last message a bit and use Dumper(). > > Short extract: > > #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"; > > # the problem is visible with this Dumper too: > print Dumper( $st ); > > > The Dumper($st) lists an empty structure (only name() is working) > unless I uncomment one of those three commands 1.) - 3.). > Then the structure is completely filled as expected. > > Is this behavior by design now? > Or is there still some internal filling of the structure missing? > > > Cheers > > Christian >
From: Christian.Ziemski@thyssenkrupp.com
Hi Piers! Yesterday you wrote:
Show quoted text
> If I understand what you are trying to do correctly, then I think you > are missunderstanding how RFC_READ_TABLE works and what you need to > interpret the results.
Yes, absolutely. That seems to have been the case.
Show quoted text
> RFC_READ_TABLE is just a function module that is designed to > generically read tables and return you the results. > > If you read the table, then you still need to figure out a way of > unpacking the rows returned in DATA, for your own purpose. > > So - what I do is that I specify a blank delimiter in the parameter > DELIMITER,
That was another error I did: I specified a delimiter.
Show quoted text
> and then get hold of a "helper object" that describes the > structure of the table that I have chosen to read. > Given that the table that I have dynamically read with RFC_READ_TABLE > is "TRDIR" then I get a SAP::Struct object for this by > executing $rfc->structure("TRDIR").
That part I did correctly, I think.
Show quoted text
> Then I can feed each row of DATA into this so that it does the tricky > business of unpacking the binary structure of that table row.
And that one I missed. But now with your additional example I managed it to run as expected. The main thing that confused me in my early experiments was that I somehow got some data, even if I did it the wrong way... To resume: It's not a bug, it was my misunderstanding of the technique. THANK YOU VERY MUCH for your help! Cheers, Christian


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.