marciabogner has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to use SAP::Rfc to call a function on a remote SAP server from an AIX Unix server. When I dump the connection information, it shows the UNICODE parameter with a value of 0. The SAP Component version is "SAP ECC 6.0" with "Unicode System" set to "Yes". I am having trouble parsing table output from the function, and I think it is related to the unicode setting. Here is my code:

#!/usr/local/bin/perl use strict; use SAP::Rfc; use Data::Dumper; my $rfc = new SAP::Rfc( ASHOST => 'SD2', USER => 'MYUSER', PASSWD => 'mypassword', LANG => 'EN', CLIENT => '400', SYSNR => '00', TRACE => '1'); if ($rfc->is_connected()) { print "RFC dump\n"; print Dumper ($rfc); $rfc->close(); } else { print "Error connecting to SAP RFC Gateway"; }

Here is the output I get:

RFC dump $VAR1 = bless( { 'TRFC' => 0, 'TRFC_COMMIT' => sub { "DUMMY" }, 'LCHECK' => '0', 'UNICODE' => 0, 'PASSWD' => 'mypassword', 'USER' => 'MYUSER', 'LANG' => 'EN', 'TRFC_ROLLBACK' => sub { "DUMMY" }, 'TRFC_CONFIRM' => sub { "DUMMY" }, 'TRACE' => '1', 'LINTTYP' => 'BIG', 'TRFC_CHECK' => sub { "DUMMY" }, 'CLIENT' => '400', 'INTERFACES' => {}, 'HANDLE' => 1, 'ASHOST' => 'SD2', 'SYSNR' => '00' }, 'SAP::Rfc' );

Is there something I am missing on my end or something else I can have them check on their end. It looks like we have version 1.55 of SAP::Rfc loaded.

Updated 8/11/2014. Here is more detailed information on the problem I am having parsing complex output. Here is my new code:

#!/usr/local/bin/perl use strict; use SAP::Rfc; use Data::Dumper; my $rfc = new SAP::Rfc( ASHOST => 'SD2', USER => 'MYUSER', PASSWD => 'mypassword', LANG => 'EN', CLIENT => '400', SYSNR => '00', TRACE => '1'); if ($rfc->is_connected()) { my $it = $rfc->discover("ZRMA_MATERIAL_ASSIGN") || Out_N_Die("RFC Di +scover failed for ZRMA_MATERIAL_ASSIGN. " . $rfc->error() . "."); $it->MATERIAL("41000642"); $rfc->callrfc( $it ); print "Interface After Call=\n"; print Dumper($it); my $rtncode = $it->RTNCODE; print "rtncode=$rtncode\n"; my $description = $it->DESCRIPTION; print "description=$description\n"; my $testtable = $it->TESTTABLE; print Dumper($testtable); my $tableMaterial = @$testtable{'MATERIAL'}; print "Material from Table: $tableMaterial\n"; my $tableDescription = @$testtable{'DESCRIPTION'}; print "Description from Table: $tableDescription\n"; $rfc->close(); } else { print "Error connecting to SAP RFC Gateway"; }

Here is the output I get:

Interface After Call= $VAR1 = bless( { 'NAME' => 'ZRMA_MATERIAL_ASSIGN', 'EXCEPTIONS' => {}, 'TABLES' => {}, 'SYSINFO' => { 'RFCSI_RESV' => ' ', 'RFCPROTO' => '011', 'RFCHOST2' => 'sd2 + ', 'RFCKERNRL' => '721 ', 'RFCTZONE' => '-21600', 'RFCDEST' => 'sd2_SD2_00 + ', 'RFCDATABS' => 'SD2 ', 'RFCDAYST' => 'X', 'RFCDBSYS' => 'ORACLE ', 'RFCDBHOST' => 'sd2.woodward.com + ', 'RFCINTTYP' => 'BIG', 'RFCCHARTYP' => '4102', 'RFCSAPRL' => '701 ', 'RFCMACH' => ' 324', 'RFCIPADDR' => '10.1.105.46 ', 'RFCSYSID' => 'SD2 ', 'RFCOPSYS' => 'AIX ', 'RFCHOST' => 'sd2 ', 'RFCFLOTYP' => 'IE3' }, 'PARAMETERS' => { 'RTNCODE' => bless( { 'DECIMALS' => + 0, 'NAME' => 'RT +NCODE', 'VALUE' => 0, 'INTYPE' => 8 +, 'LEN' => 4, 'DEFAULT' => +undef, 'TYPE' => 0, 'CHANGED' => +0, 'RFCINTTYP' = +> 'BIG', 'UNICODE' => +0, 'ENDIAN' => ' +BIG', 'STRUCTURE' = +> '' }, 'SAP::Parms' + ), 'DESCRIPTION' => bless( { 'DECIMALS +' => 0, 'NAME' => + 'DESCRIPTION', 'VALUE' = +> 'PISTON ', 'INTYPE' +=> 0, 'LEN' => +40, 'DEFAULT' + => undef, 'TYPE' => + 0, 'CHANGED' + => 0, 'RFCINTTY +P' => 'BIG', 'UNICODE' + => 0, 'ENDIAN' +=> 'BIG', 'STRUCTUR +E' => '' }, 'SAP::Pa +rms' ), 'MATERIAL' => bless( { 'DECIMALS' = +> 0, 'NAME' => 'M +ATERIAL', 'VALUE' => ' +41000642 ', 'INTYPE' => +0, 'LEN' => 18, 'DEFAULT' => + ' ', 'TYPE' => 1, 'CHANGED' => + 1, 'RFCINTTYP' +=> 'BIG', 'UNICODE' => + 0, 'ENDIAN' => +'BIG', 'STRUCTURE' +=> '' }, 'SAP::Parms +' ), 'TESTTABLE' => bless( { 'DECIMALS' +=> 0, 'NAME' => ' +TESTTABLE', 'VALUE' => +'000000000041000642PISTON + ', 'INTYPE' => + 38, 'LEN' => 11 +6, 'DEFAULT' = +> undef, 'TYPE' => 0 +, 'CHANGED' = +> 0, 'RFCINTTYP' + => 'BIG', 'UNICODE' = +> 0, 'ENDIAN' => + 'BIG', 'STRUCTURE' + => bless( { + 'NAME' => 'ZMATTEST', + 'LINTTYP' => 'BIG', + 'LEN' => 116, + 'TYPE' => 38, + 'RFCINTTYP' => 'BIG', + 'DATA' => [], + 'FIELDS' => { + 'DESCRIPTION' => { + 'DECIMALS' => 0, + 'NAME' => 'DESCRIPTION' +, + 'POSITION' => 2, + 'OFFSET' => 36, + 'INTYPE' => 0, + 'LEN' => 80, + 'EXID' => 'C' + }, + 'MATERIAL' => { + 'DECIMALS' => 0, + 'NAME' => 'MATERIAL', + 'POSITION' => 1, + 'OFFSET' => 0, + 'INTYPE' => 0, + 'LEN' => 36, + 'EXID' => 'C' + } + } + }, 'SAP::Struc' ) }, 'SAP::Parm +s' ) }, 'UNICODE' => 0, 'ENDIAN' => 'BIG' }, 'SAP::Iface' ); rtncode=0 description=PISTON $VAR1 = { 'DESCRIPTION' => ' + ', 'MATERIAL' => '000000000041000642PISTON ' }; Material from Table: 000000000041000642PISTON Description from Table:

According to my SAP developer, the "MATERIAL" field in the "TESTTABLE" is 18 characters and the "DESCRIPTION" is 40, but I show lengths of twice that. The output line matches his lengths, but when I dump the hashtable, the values are messed up because I am expecting twice the length I am getting.

Replies are listed 'Best First'.
Re: SAP::Rfc not recognizing SAP as Unicode
by Anonymous Monk on Aug 01, 2014 at 09:11 UTC

    SAP::Rfc was last updated almost three years ago, has 11 open bugs, its test suite doesn't look very useful, and three of the open bugs are about Unicode. Is there another module you can use?

    I am having trouble parsing table output from the function, and I think it is related to the unicode setting.

    Then why don't you describe that problem? See How do I post a question effectively? Perhaps we can find a workaround for your problem.