SAP / node-rfc

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

BAPI_HU_GETLIST not giving any output or error #301

Closed vishalshingate closed 6 months ago

vishalshingate commented 10 months ago

Description:- BAPI_HU_GETLIST is giving me an empty response; on the sap GUI client, I'm able to see the HUKY is getting in response.

On SAP GUI this is result:- image

When I call the bapi from node_rfc client following the response I'm getting.

{ "NOTEXT": "", "ONLYKEYS": "X", "HIGHESTLEVEL": [], "HUHEADER": [], "HUHISTORY": [], "HUITEM": [], "HUKEY": [], "HUNUMBERS": [], "HUOBJECTS": [ { "OBJECT": "09", "OBJKEY": "000070001048" } ], "NOTFOUNDHUS": [], "RETURN": [ { "TYPE": "", "ID": "", "NUMBER": "000", "MESSAGE": "", "LOG_NO": "", "LOG_MSG_NO": "000000", "MESSAGE_V1": "", "MESSAGE_V2": "", "MESSAGE_V3": "", "MESSAGE_V4": "", "PARAMETER": "", "ROW": 0, "FIELD": "", "SYSTEM": "" } ] }

Steps to reproduce:- Sap side:- You have to create the process order by using the cor1 transaction. After that, you have to create a handling unit for that transaction using cowbpack transaction code.

We have used the following code to call the BAPI:-

function invokeRFC(client, rfcName, options, callback) { if (!client) return callback('Client not found') client.invoke(rfcName, options, function (err, res) { if (err) { return callback(err) } return callback(null, res) }) }

Input :-

rfcName:- BAPI_HU_GETLIST

options:-{ "HIGHESTLEVEL": [], "HUHEADER": [], "HUHISTORY": [], "HUITEM": [], "HUKEY": [], "HUNUMBERS": [], "HUOBJECTS": [ { "OBJECT": "09", "OBJKEY": "000070001048" } ], "NOTEXT": "", "NOTFOUNDHUS": [], "ONLYKEYS": "X", "RETURN": [ { "FIELD": "", "ID": "", "LOG_MSG_NO": "", "LOG_NO": "", "MESSAGE": "", "MESSAGE_V1": "", "MESSAGE_V2": "", "MESSAGE_V3": "", "MESSAGE_V4": "", "NUMBER": "", "PARAMETER": "", "SYSTEM": "", "TYPE": "" } ] } The expected output should be the same as the SAP output, but we are not getting the expected result.

Screenshots image

Environment I have used node_rfc 3.3.0 and 1.0.1 same result I'm getting.

Can someone please check why there is a difference in the output of SAPGUI and node_rfc call output?

bsrdjan commented 10 months ago

Could you please send the screenshot of the selection data used in SAPGUI, like how the key 000070001048 looks in HUOBJECTS table record in SAPGUI:

Screenshot 2023-09-01 at 11 07 04

You can also set the external breakpoint at the beginning of BAPI_HU_GETLIST and see in ABAP debugger if difference in selection data from SAPGUI and from Node.js. More info here: RFM call results differ from expected

To check if ABAP User Exit used for selection field, you can useabap utility from SAP/fundamental tools

mkdir tmp
cd tmp
npm init -y
npm install abap-api-tools
# create sapnwrfc.ini file, here in tmp folder, with your system connection parameters
# like
# sysId
# DEST=mySysId
# USER=demo
# PASSWD=welcome
# ASHOST=coevi51
# SYSNR=00
# CLIENT=620
# LANG=EN

# get ABAP metadata of your function module
abap get yourSysMME BAPI_HU_GETLIST

# inspect fields with user exits, search for ALPHA in editor, or from command line
grep ALPHA api/bapi_hu_getlist.js

It would help find out if selection field(s) have user-exits and if leading zeroes for example should be sent from Node.js

vishalshingate commented 10 months ago

Hi @bsrdjan , Thanks for the quick response on this.

From sap GUI too, I'm providing the leading zeros. image

bsrdjan commented 10 months ago

I tested with the latest and older node-rfc versions and in remote enabled debugger the selection data look the same, no matter if called from node-rfc or from SAPGUI:

SAPGUI

I would suggest to get in touch with Functional Consultant to check if any configuration in the system has influence on RFC call of this particular BAPI.

If no progress could you please open customer incident for BC-MID-RFC-SDK component, provide the url of this issue there and also update this issue with the incident number.

Customer incident helps that more experts can analyse if needed. Next three weeks I am on vacation with very limited access to system.

With customer incident we can also get access and test in your system.

In my test system the OBJKEY 000070001048 does not exist and the correct error message is returned.

test.mjs

import { Client } from "node-rfc";

(async () => {
  const client = new Client({ dest: "MME" });
  await client.open();

  const R = await client.call("BAPI_HU_GETLIST", {
    HUOBJECTS: [
      {
        OBJECT: "09",
        OBJKEY: "000070001048",
      },
    ],
  });

  console.log(R);
})();

Console output

node test.mjs
{
  NOTEXT: '',
  ONLYKEYS: '',
  HIGHESTLEVEL: [],
  HUHEADER: [],
  HUHISTORY: [],
  HUITEM: [],
  HUKEY: [],
  HUNUMBERS: [],
  HUOBJECTS: [ { OBJECT: '09', OBJKEY: '000070001048' } ],
  NOTFOUNDHUS: [],
  RETURN: [
    {
      TYPE: 'E',
      ID: 'HUSELECT',
      NUMBER: '009',
      MESSAGE: 'No handling units for required objects',
      LOG_NO: '',
      LOG_MSG_NO: '000000',
      MESSAGE_V1: '',
      MESSAGE_V2: '',
      MESSAGE_V3: '',
      MESSAGE_V4: '',
      PARAMETER: '',
      ROW: 0,
      FIELD: '',
      SYSTEM: ''
    }
  ]
}

We need to check the behaviour in your system.

vishalshingate commented 10 months ago

Hi @bsrdjan , This error you are getting because the process order is not there.

  1. You must first create the process order using the cor1 transaction code. image

  2. Then, by using cowbpack transaction code, you have to create the handling units. image

  3. Then you have to provide the 09 and the objkey = your process order number that you have created.

vishalshingate commented 10 months ago

Hi @bsrdjan If you want, we can set up a call and check the behavior in my system.

bsrdjan commented 10 months ago

Thank you for detailed steps. My point was that when HU not found, the error message is correct and in your system there is no result and no error message.

My test system is plain Basis system in which I can't test steps to reproduce. We need to test the behaviour in your system, with customizing applied there. For that we need a customer incident and from EoD today I am anyway out of office.

vishalshingate commented 10 months ago

Hi @bsrdjan The root cause of this issue is when we pass any return parameter. Suppose you are passing a message to this to return then in that at the line n0 89 getting some problem and it does not execute the 107 line that adds the hukey to hukey array. image

If I pass the following input to that BAPI on SAPI UI, too, I'm not getting any output. image So, I wonder if it is expected behavior or not.

bsrdjan commented 10 months ago

The question can be discussed with Functional/ABAP Consultant. node-rfc support can help with technical and integration issues, related to Python RFC connections. For questions about particular BAPIs it is recommended to reach out to Functional Consultants or SAP ABAP Community.

vishalshingate commented 10 months ago

Hi @bsrdjan Thanks for the support. The issue is happening because we are passing an empty string in the RETURN parameter array like the following:-

RETURN: [
    {
      TYPE: 'E',
      ID: 'HUSELECT',
      NUMBER: '009',
      MESSAGE: 'No handling units for required objects',
      LOG_NO: '',
      LOG_MSG_NO: '000000',
      MESSAGE_V1: '',
      MESSAGE_V2: '',
      MESSAGE_V3: '',
      MESSAGE_V4: '',
      PARAMETER: '',
      ROW: 0,
      FIELD: '',
      SYSTEM: ''
    }

To resolve this issue temporarily, we initialized the return parameter with an empty array, and the issue get resolved. As one suggestion, if SAP itself does not accept the empty string in the return parameter, then the node_rfc library should handle this scenario like if a user is not providing input to the field, then Node_rfc should remove that parameter or provide that which can be accepted at the SAP system.

bsrdjan commented 10 months ago

Which field exactly causes the issue when returned as empty string? Could you please provide the example of RETURN parameter with empty string, which causes the issue?

vishalshingate commented 10 months ago

From our node js code, we previously provided this input. Because of this, it's not giving us the expected output.

"RETURN": [ { "FIELD": "", "ID": "", "LOG_MSG_NO": "", "LOG_NO": "", "MESSAGE": "", "MESSAGE_V1": "", "MESSAGE_V2": "", "MESSAGE_V3": "", "MESSAGE_V4": "", "NUMBER": "", "PARAMETER": "", "SYSTEM": "", "TYPE": "" } ]

If you see line number 89, it's saying if the return is initialized, if we are passing the input to any field that array then this array will get initialized Because of that might following statements will not be executed. image

bsrdjan commented 9 months ago

The support here can't help with questions related to ABAP functional logic. Is there an issue with ABAP RETURN parameter which is not handled properly by node-rfc? Can you provide an example of such ABAP RETURN parameter and describe what the node-rfc issue exactly is?

I am asking because the above comment is not clear to me:

The issue is happening because we are passing an empty string in the RETURN parameter array like the following:-

The example following this sentence shows non-empty structure and I am not sure which empty string is mentioned here?