Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function parameter lost #15

Closed
ThaDafinser opened this issue Feb 22, 2016 · 12 comments
Closed

Function parameter lost #15

ThaDafinser opened this issue Feb 22, 2016 · 12 comments
Assignees
Labels
Milestone

Comments

@ThaDafinser
Copy link
Contributor

It seems that the function invoke parameters are lost

PHP7

$conn = new SapConnection($config);

$parameters = [
    'FMI_MATNR' => '887070'
];

$func = $conn->getFunction('Z_PPP_MAT_GET_METADATA');
$result = $func->invoke($parameters);
var_dump($result);

Trace

>> RfcOpenConnection
>> RfcOptions
    // ...
<< RfcOptions

>> RfcConnection name="none"
Handle = 108726000 ConvID = 42090651
<< RfcConnection

<< RfcOpenConnection returned RFC_OK

>> RfcGetFunctionDesc
RfcGetFunctionDesc(Z_PPP_MAT_GET_METADATA) via handle 108726000
RfcGetFunctionDesc(Z_PPP_MAT_GET_METADATA) via handle 108726000 (SID=T11) returned 00000000067237F0
<< RfcGetFunctionDesc returned RFC_OK

>> RfcInvoke
Invoking Z_PPP_MAT_GET_METADATA on handle 108726000

>> RfcFunction name="Z_PPP_MAT_GET_METADATA"
>> IMPORTING parameters
>> FMI_LAEDA, RFCTYPE_DATE, Length: 16, Active: false, Requested: false
    Value: 0000-00-00
<< FMI_LAEDA

>> FMI_MATNR, RFCTYPE_CHAR, Length: 36, Active: false, Requested: false
    Value: 
<< FMI_MATNR

>> FMI_MTART, RFCTYPE_CHAR, Length: 8, Active: false, Requested: false
    Value: 
<< FMI_MTART

<< IMPORTING parameters

>> CHANGING parameters
<< CHANGING parameters

PHP5

$conn = new sapnwrfc($config);

$parameters = [
    'FMI_MATNR' => '887070'
];

$func = $conn->function_lookup('Z_PPP_MAT_GET_METADATA');
$result = $func->invoke($parameters);
var_dump($result);

Trace

>> RfcOpenConnection
>> RfcOptions
    // ...
<< RfcOptions

>> RfcConnection name="none"
Handle = 22353560 ConvID = 42046954
<< RfcConnection

<< RfcOpenConnection returned RFC_OK

>> RfcGetFunctionDesc
RfcGetFunctionDesc(Z_PPP_MAT_GET_METADATA) via handle 22353560
RfcGetFunctionDesc(Z_PPP_MAT_GET_METADATA) via handle 22353560 (SID=T11) returned 015487C8
<< RfcGetFunctionDesc returned RFC_OK

>> RfcInvoke
Invoking Z_PPP_MAT_GET_METADATA on handle 22353560

>> RfcFunction name="Z_PPP_MAT_GET_METADATA"
>> IMPORTING parameters
>> FMI_LAEDA, RFCTYPE_DATE, Length: 16, Active: true, Requested: false
    Value: 0000-00-00
<< FMI_LAEDA

>> FMI_MATNR, RFCTYPE_CHAR, Length: 36, Active: true, Requested: false
    Value: 887070
<< FMI_MATNR

>> FMI_MTART, RFCTYPE_CHAR, Length: 8, Active: true, Requested: false
    Value: 
<< FMI_MTART

<< IMPORTING parameters

>> CHANGING parameters
<< CHANGING parameters
@gkralik
Copy link
Owner

gkralik commented Feb 22, 2016

Seems they are not active ([...] Active: false [...]) strange.

@gkralik
Copy link
Owner

gkralik commented Feb 22, 2016

Try calling $func->setParameterActive('FMI_MATNR', true) and check if it works.
There is a known bug with parameter activatation, I'll have a look...

@gkralik gkralik added the bug label Feb 22, 2016
@gkralik gkralik self-assigned this Feb 22, 2016
@ThaDafinser
Copy link
Contributor Author

That works.

>> RfcOpenConnection
>> RfcOptions
    // ...
<< RfcOptions

>> RfcConnection name="none"
Handle = 108726000 ConvID = 43018472
<< RfcConnection

<< RfcOpenConnection returned RFC_OK

>> RfcGetFunctionDesc
RfcGetFunctionDesc(Z_PPP_MAT_GET_METADATA) via handle 108726000
RfcGetFunctionDesc(Z_PPP_MAT_GET_METADATA) via handle 108726000 (SID=T11) returned 00000000067237F0
<< RfcGetFunctionDesc returned RFC_OK

>> RfcInvoke
Invoking Z_PPP_MAT_GET_METADATA on handle 108726000

>> RfcFunction name="Z_PPP_MAT_GET_METADATA"
>> IMPORTING parameters
>> FMI_LAEDA, RFCTYPE_DATE, Length: 16, Active: false, Requested: false
    Value: 0000-00-00
<< FMI_LAEDA

>> FMI_MATNR, RFCTYPE_CHAR, Length: 36, Active: true, Requested: false
    Value: 887070
<< FMI_MATNR

>> FMI_MTART, RFCTYPE_CHAR, Length: 8, Active: false, Requested: false
    Value: 
<< FMI_MTART

<< IMPORTING parameters

>> CHANGING parameters
<< CHANGING parameters

@gkralik
Copy link
Owner

gkralik commented Feb 22, 2016

OK, use that as a workaround for now. I hope to find enough time to rework the parameter handling this week. I'll keep you posted.

Thanks for testing 👍

@gkralik gkralik added this to the 0.7.0 milestone Feb 22, 2016
@ThaDafinser
Copy link
Contributor Author

Maybe just call $func->setParameterActive('FMI_MATNR', true) when a parameter is provided?

NO problem. Testing is important to get it into production asap ;-)

@gkralik
Copy link
Owner

gkralik commented Feb 22, 2016

Yes, the plan is to have a HashTable save the activation state and activate each parameter before invoking the RFC.

@gkralik
Copy link
Owner

gkralik commented Feb 22, 2016

Can't really reproduce this one either... all parameters seem to be active by default.

@ThaDafinser
Copy link
Contributor Author

Hmm...cant provide you more then the trace and the used code currently...

@gkralik
Copy link
Owner

gkralik commented Feb 22, 2016

No problem.

gkralik added a commit that referenced this issue Feb 28, 2016
the status of the parameters is now saved in a HashTable and the function
handle is now created in invoke(), not getFunction(). this enables reuse
of the RemoteFunction object.
all parameters are active by default, so RfcSetParameterActive is only
called if the user deactivated a parameter.
we cant call it for every parameter and set it to active as this causes
really strange errors and segfaults if the FM throws an ABAP exception
(eg use RFC_RAISE_ERROR test 043 to reproduce - when forcing parameters
active, the test segfaults because the exception is ignored and the code
tries to fetch a return value for CSTRING). there might be a better
solution, but for now it works.

refs #15
@gkralik
Copy link
Owner

gkralik commented Feb 28, 2016

I can't really reproduce your issue. For me, all parameters are active by default. Calling setParameterActive() for all FM parameters seems not to be a solution as it causes segfaults when exceptions occur in the FM...
But there have been changes to parameter handling, so maybe your issue is already resolved.

gkralik added a commit that referenced this issue Feb 28, 2016
all parameters that are passed as arguments to invoke should
be active by default.

refs #15
@gkralik
Copy link
Owner

gkralik commented Feb 28, 2016

OK, the new implementation now makes sure that all parameters passed as arguments to invoke() are activated. This seems to work and does not cause any strange errors.

@gkralik
Copy link
Owner

gkralik commented Feb 29, 2016

fixed in 0.7.0

@gkralik gkralik closed this as completed Feb 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants