SAP / node-rfc

Asynchronous, non-blocking SAP NW RFC SDK bindings for Node.js
Apache License 2.0
252 stars 73 forks source link

call of BAPI BAPI_MATERIAL_GETLIST not working #50

Closed softy12 closed 6 years ago

softy12 commented 6 years ago

Hello,

I'm using a BAPI BAPI_MATERIAL_GETLIST as shown in below code. When I'm using the same parameters for the same BAPI in SAP GUI I get correct data (2 records in table MATNRLIST). However, BAPI call via node-RFC seems not working (10 records in MATNRLIST returned). So it looks like MAXROWS param doesn't work.

Can someone look at this?

thanks

"use strict";
var rfc = require('node-rfc');
var abapSystem = {
    user: '',
    passwd: '',
    ashost: '',
    sysnr: '',
    client: ''
};
var client = new rfc.Client(abapSystem);
var MAXROWS = "2";
var MATNRSELECTION_str = {
        SIGN:       "I", 
        OPTION:     "CP", 
        MATNR_LOW:  "AB*"
    };  
var MATNRSELECTION_tab = [MATNRSELECTION_str];

client.connect(function(err) {
    if (err) {
        return console.error('could not connect to server', err);
    }   
    client.invoke('BAPI_MATERIAL_GETLIST', {
            MAXROWS: MAXROWS,
            MATNRSELECTION: MATNRSELECTION_tab
        },
        function(err, res) {
            if (err) {
                return console.error('Error invoking BAPI_MATERIAL_GETLIST:', err);
            }
        console.log('Result BAPI_MATERIAL_GETLIST:', res);
        }); 
});
bsrdjan commented 6 years ago

The MAXROWS parameter ABAP type is integer, while test script passes the string, which node-rfc silently interprets as integer zero.

I added type check in master branch 74cfcf6, to help find such errors.

MAXROWS shall be passed as integer but you can also build current master from source and check if stops on error.

softy12 commented 6 years ago

Thanks for checking this. I can confirm that once I pass a value of the param as an integer it is working correctly. Unfortunately, I have no possibility to check the master branch. Anyway, the issue is solved. Thanks a lot!