cancel
Showing results for 
Search instead for 
Did you mean: 

Communication between perl and SAP

helmut_schrder
Explorer
0 Kudos

Hi,

we use the perl module "sapnwrfc" together with nwrfcsdk of SAP

to read out some user details. The SAP system is installed as a

unicode system. We have a problem of setting the import parameter

USERNAME in BAPI_USER_GET_DETAIL correctly. The program

works fine for the value "TESTUSER". An error occured when we

call the bapi with german umlaut.

Here is an example:

#!/usr/bin/perl
 
...
use sapnwrfc;
...
$Username = "SCHRÖDER";
$Rfc = SAPNW::Rfc->rfc_connect(
              ASHOST => $Hostname,
              USER => $UserId,
              PASSWD => $Password,
              LANG => $Language,
              CLIENT => $Client,
              SYSNR => $SystemNr,
              TRACE => '1' );

$Rcb = $Rfc->function_lookup( "BAPI_USER_GET_DETAIL" );
$Iface = $Rcb->create_function_call;
$Iface->USERNAME( $Username );
$Iface->invoke;
...

The function "invoke" never ends.

Can anybody help us?

Thanks

Helmut

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Helmut -

have you tried adding use utf8; to your code?


#!/usr/bin/perl
use strict;
use utf8;

use sapnwrfc;
...

Cheers,

Piers Harding.

helmut_schrder
Explorer
0 Kudos

Hi,

yes, we have tried adding use utf8; to our code. But the problem

was not solved.

Regards,

Helmut

Former Member
0 Kudos

Do you have $LANG set for the user executing the script? For instance, mine is:

$ echo $LANG
en_US.UTF-8

helmut_schrder
Explorer
0 Kudos

Hi,

we have change $LANG from de_DE to en_US.UTF-8. The problem exists with and without "use utf8;".

Regards,

Helmut

Former Member
0 Kudos

Hi -

I got some time to test this over the weekend - I've tried, but I can't recreate the problem. I have created a user account with "SCHRÖDER", and am able to run the following code successfilly:


#!/usr/bin/perl
use strict;
use lib '../blib/lib';
use lib '../blib/arch';
use lib './blib/lib';
use lib './blib/arch';
use utf8;
use sapnwrfc;
use Data::Dumper;
my $Username = "SCHRÖDER";
SAPNW::Rfc->load_config;
print "Testing SAPNW::Rfc-$SAPNW::Rfc::VERSION
";
my $conn = SAPNW::Rfc->rfc_connect();
my $Rcb = $conn->function_lookup( "BAPI_USER_GET_DETAIL" );
my $Iface = $Rcb->create_function_call;
$Iface->USERNAME( $Username );
$Iface->invoke;
warn Dumper($Iface);

This is Ubuntu 9.10 - amd64, Perl 5.10.0, SAP NW 2004S, sapnwrfc 0.31, and NW RFC SDK 7.11 - Patch Level 3 .

Cheers,

Piers Harding.

Former Member
0 Kudos

Hi -

what version of sapnwrfc for Perl are you using - 0.31? Also, Perl, and OS version, and NW RFC SDK info would be useful.

Cheers,

Piers Harding.

helmut_schrder
Explorer
0 Kudos

Hi,

our technical support has installed the following software versions:

OS: Linux ... 2.6.16.27-0.9-smp #1 SMP Tue Feb 13 09:35:18 UTC 2007 x86_64 x86_64 x86_64 GNU/Linux

Perl: This is perl, v5.8.8 built for x86_64-linux-thread-multi

sapnwrfc for Perl : sapnwrfc-0.31

NW RFC SDK : NWRFC_4-20004549.SAR

In article is the latest version sapnwrfc-0.30.tar.gz available, which requires perl 5.10. Have we a problem with

perl v5.8.8?

Regards

Helmut Schröder

Former Member
0 Kudos

I don't have any usernames with umlauts in them, but I certainly didn't get any errors in the process. either.

$ cat umlaut-test.pl

#!/usr/bin/perl -w

use strict;

use sapnwrfc;

use Data::Dumper;

SAPNW::Rfc->load_config('rdu.yml');

my $rfc = SAPNW::Rfc->rfc_connect;

my $rcb = $rfc->function_lookup("BAPI_USER_GET_DETAIL");

my $tsl = $rcb->create_function_call;

$tsl->USERNAME('SCHRÖDER');

$tsl->invoke;

warn Dumper($tsl->LOGONDATA);

$rfc->disconnect();

$ perl umlaut-test.pl

$VAR1 = {

'PASSCODE' => '',

'LTIME' => '000000',

'CLASS' => ' ',

'USTYP' => ' ',

'GLTGB' => '00000000',

'TZONE' => ' ',

'CODVN' => ' ',

'BCODE' => '',

'ACCNT' => ' ',

'CODVC' => ' ',

'GLTGV' => '00000000'

};

Cheers,

David.

PS: my versions:

RHEL 5, kernel 2.6.18-164

perl 5.8.8

sapnwrfc 0.24

helmut_schrder
Explorer
0 Kudos

Hi David,

we have tested your source code.

Excuse me, but also your example never ends with statement "invoke".

Regards,

Helmut Schröder

Former Member
0 Kudos

I'm not sure I understand. There is an invoke. Are you suggesting it should be at the very end of the code?

Cheers,

David.

Former Member
0 Kudos

I have added spacing for easier reading:

This is the script:

$ cat umlaut-test.pl

#!/usr/bin/perl -w
use strict;
use sapnwrfc;
use Data::Dumper;
SAPNW::Rfc->load_config('rdu.yml');
my $rfc = SAPNW::Rfc->rfc_connect;
my $rcb = $rfc->function_lookup("BAPI_USER_GET_DETAIL");
my $tsl = $rcb->create_function_call;
$tsl->USERNAME('SCHRÖDER');
$tsl->invoke;
warn Dumper($tsl->LOGONDATA);
$rfc->disconnect();

And this is the code being executed:

$ perl umlaut-test.pl
$VAR1 = {
'PASSCODE' => '',
'LTIME' => '000000',
'CLASS' => ' ',
'USTYP' => ' ',
'GLTGB' => '00000000',
'TZONE' => ' ',
'CODVN' => ' ',
'BCODE' => '',
'ACCNT' => ' ',
'CODVC' => ' ',
'GLTGV' => '00000000'
};

helmut_schrder
Explorer
0 Kudos

Hi,

let's try it to explain with following example:

#!/usr/bin/perl
 
...
use sapnwrfc;
...
$Username = "SCHRÖDER";
$Rfc = SAPNW::Rfc->rfc_connect(
              ASHOST => $Hostname,
              USER => $UserId,
              PASSWD => $Password,
              LANG => $Language,
              CLIENT => $Client,
              SYSNR => $SystemNr,
              TRACE => '1' );
 
$Rcb = $Rfc->function_lookup( "BAPI_USER_GET_DETAIL" );
$Iface = $Rcb->create_function_call;
$Iface->USERNAME( $Username );
print "before invoke...
";
$Iface->invoke;
print "after invoke...
";
...

The output before $Iface->invoke is printed. The output

after $Iface->invoke is never displayed. The command

"Iface->invoke" loops.

We have no problems with values without german umlauts.

Regards,

Helmut Schröder

Former Member
0 Kudos

OK, I understand now.

You activated tracing. Does the trace file show anything unusual, as compared with a username without an umlaut?

Cheers,

David.

Former Member
0 Kudos

I also tried passing the username into a variable as you were doing, but this script succeeded for me as well.

#!/usr/bin/perl -w
use strict;
use sapnwrfc;
use Data::Dumper;
SAPNW::Rfc->load_config('rdu.yml');
my $username = "SCHRÖDER";
my $rfc = SAPNW::Rfc->rfc_connect;
my $rcb = $rfc->function_lookup("BAPI_USER_GET_DETAIL");
my $tsl = $rcb->create_function_call;
$tsl->USERNAME($username);
$tsl->invoke;
warn Dumper($tsl->LOGONDATA);

Former Member
0 Kudos

I also activated tracing, and see no errors in the trace file. Here is a snippet:

>> RfcInvoke
Invoking BAPI_USER_GET_DETAIL on handle 161762128

>> RfcFunction name="BAPI_USER_GET_DETAIL"
>> IMPORTING parameters
>> CACHE_RESULTS, RFCTYPE_CHAR, Length: 2, Active: false, Requested: false
        Value: 
<< CACHE_RESULTS

>> USERNAME, RFCTYPE_CHAR, Length: 24, Active: true, Requested: false
        Value: SCHRÖDER
<< USERNAME

<< IMPORTING parameters

>> CHANGING parameters
<< CHANGING parameters

>> TABLES parameters
>> ACTIVITYGROUPS, RFCTYPE_TABLE, Length: 0, Active: true, Requested: false
        Value: (empty)
<< ACTIVITYGROUPS

>> ADDCOMREM, RFCTYPE_TABLE, Length: 0, Active: true, Requested: false
        Value: (empty)
<< ADDCOMREM

Former Member
0 Kudos

Looks like the code tags replaced '>>' with this 'jive-quote' syntax. Very strange.

Cheers,

David.

helmut_schrder
Explorer
0 Kudos

Hi,

trace file with username 'TEST':

...
<< RfcOptions

>> RfcConnection name="none"
Handle = 13630944 ConvID = 62464895
<< RfcConnection

<< RfcOpenConnection returned RFC_OK

>> RfcGetFunctionDesc
<< RfcGetFunctionDesc returned RFC_OK

>> RfcInvoke
Invoking BAPI_USER_GET_DETAIL on handle 13630944

>> RfcFunction name="BAPI_USER_GET_DETAIL"
>> IMPORTING parameters
>> CACHE_RESULTS, RFCTYPE_CHAR, Length: 2, Active: false, Requested: false
        Value:
<< CACHE_RESULTS

>> USERNAME, RFCTYPE_CHAR, Length: 24, Active: true, Requested: false
        Value: TEST
<< USERNAME

<< IMPORTING parameters

>> CHANGING parameters
<< CHANGING parameters

>> TABLES parameters
...

Trace file with username 'SCHRÖDER':

...
<< RfcOptions

>> RfcConnection name="none"
Handle = 13630944 ConvID = 62679909
<< RfcConnection

<< RfcOpenConnection returned RFC_OK

>> RfcGetFunctionDesc
<

RfcGetFunctionDesc is the last entry in the trace file.

Regards,

Helmut