SAP / node-rfc

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

Encoding errors #181

Closed krlwlfrt closed 4 years ago

krlwlfrt commented 4 years ago

I just updated my project to Node.js 12 (newest LTS), NWRFC 750P_7-70002752 (newest available version to download) and node-rfc 2.1.0 (current version).

I saw strange symbols in the output of our function module. So I tried the function module STFC_STRUCTURE, that is also mentioned in the readme.

Below is the JSON representation of the returned structure. What could be the cause of this?

{
  "ECHOSTRUCTd\u001ce": {
    "RFCFLOATX�d\u001ce": 0,
    "RFCCHAR1�ɕ\u0003": "",
    "RFCINT2": 0,
    "RFCINT1": 0,
    "RFCCHAR4�ɕ\u0003": "",
    "RFCINT4": 0,
    "RFCHEX3": {
      "type": "Buffer",
      "data": [
        0,
        0,
        0
      ]
    },
    "RFCCHAR2�ɕ\u0003": "",
    "RFCTIME": "000000",
    "RFCDATE": "00000000X�d\u001ce",
    "RFCDATA1\u0018ʕ\u0003": "                                                  ent must be an object parameters) must be an objec",
    "RFCDATA2(ʕ\u0003": "                                                  ent must be an object parameters) must be an objec"
  },
  "RESPTEXTPɕ\u0003": "SAP R/3 Rel. 750   Sysid: XXX      Date: 20201013   Time: 114713",
  "IMPORTSTRUCT": {
    "RFCFLOAT(ʕ\u0003": 0,
    "RFCCHAR1�ɕ\u0003": "",
    "RFCINT2": 0,
    "RFCINT1": 0,
    "RFCCHAR4�ɕ\u0003": "",
    "RFCINT4": 0,
    "RFCHEX3": {
      "type": "Buffer",
      "data": [
        0,
        0,
        0
      ]
    },
    "RFCCHAR2\bʕ\u0003": "",
    "RFCTIME": "000000",
    "RFCDATE": "00000000X�d\u001ce",
    "RFCDATA18ʕ\u0003": "",
    "RFCDATA2Hʕ\u0003": ""
  },
  "RFCTABLEpɕ\u0003": [
    {
      "RFCFLOATHʕ\u0003": 1,
      "RFCCHAR1�ɕ\u0003": "X",
      "RFCINT2": 1,
      "RFCINT1": 1,
      "RFCCHAR4": "XXX",
      "RFCINT4": 1,
      "RFCHEX3": {
        "type": "Buffer",
        "data": [
          241,
          242,
          243
        ]
      },
      "RFCCHAR20ʕ\u0003": "YZ",
      "RFCTIME": "114713",
      "RFCDATE": "20201013X�d\u001ce",
      "RFCDATA1`ʕ\u0003": "                                                    Time: 114713",
      "RFCDATA2pʕ\u0003": "                                                    Time: 114713"
    }
  ]
}
bsrdjan commented 4 years ago

Root cause identified, the patch will be provided soon

bsrdjan commented 4 years ago

The 2.2.0 release provides the fix

krlwlfrt commented 4 years ago

Unfortunately I can not confirm this. I just installed node-rfc 2.2.0. The following is the output of client.environment.

{
  platform: { name: 'linux', arch: 'x64', release: '5.8.14-arch1-1' },
  env: { SAPNWRFC_HOME: '', RFC_INI: '' },
  versions: {
    node: '12.19.0',
    v8: '7.8.279.23-node.44',
    uv: '1.39.0',
    zlib: '1.2.11',
    brotli: '1.0.9',
    ares: '1.16.0',
    modules: '72',
    nghttp2: '1.41.0',
    napi: '7',
    llhttp: '2.1.2',
    http_parser: '2.9.3',
    openssl: '1.1.1g',
    cldr: '37.0',
    icu: '67.1',
    tz: '2019c',
    unicode: '13.0'
  },
  noderfc: {
    version: '2.2.0',
    nwrfcsdk: { major: 7500, minor: 0, patchLevel: 7 }
  }
}

The output of the returned structure looks different but still wrong.

{
  'ECHOSTRUCT\u0006<n': {
    'RFCFLOATXk\u0006<n': 0,
    'RFCCHAR1���\u0003': '',
    RFCINT2: 0,
    RFCINT1: 0,
    'RFCCHAR4���\u0003': '',
    RFCINT4: 0,
    RFCHEX3: <Buffer 00 00 00>,
    'RFCCHAR2��\u0003': '',
    RFCTIME: '000000',
    RFCDATE: '00000000Xk\u0006<n',
    'RFCDATA1\u0018��\u0003': '                                                  W\u0004',
    'RFCDATA2(��\u0003': '                                                  W\u0004'
  },
  'RESPTEXTP��\u0003': 'SAP R/3 Rel. 750   Sysid: XXX      Date: 20201013   Time: 194743',
  IMPORTSTRUCT: {
    'RFCFLOAT(��\u0003': 0,
    'RFCCHAR1���\u0003': '',
    RFCINT2: 0,
    RFCINT1: 0,
    'RFCCHAR4ؙ�\u0003': '',
    RFCINT4: 0,
    RFCHEX3: <Buffer 00 00 00>,
    'RFCCHAR2\b��\u0003': '',
    RFCTIME: '000000',
    RFCDATE: '00000000Xk\u0006<n',
    'RFCDATA18��\u0003': '                                                    Time: 194743',
    'RFCDATA2H��\u0003': '                                                    Time: 194743'
  },
  'RFCTABLEp��\u0003': [
    {
      'RFCFLOATH��\u0003': 1,
      'RFCCHAR1Й�\u0003': 'X',
      RFCINT2: 1,
      RFCINT1: 1,
      RFCCHAR4: 'XXX',
      RFCINT4: 1,
      RFCHEX3: <Buffer f1 f2 f3>,
      'RFCCHAR20��\u0003': 'YZ',
      RFCTIME: '194743',
      RFCDATE: '20201013Xk\u0006<n',
      'RFCDATA1`��\u0003': '                                                        �\u0004',
      'RFCDATA2p��\u0003': '                                                        �\u0004'
    }
  ]
}
bsrdjan commented 4 years ago

Which Linux distro do you use?

Could you please post the output of ls -la node_modules/node-rfc/lib/binding ?

You can also try the build from source.

krlwlfrt commented 4 years ago

I have to apologize. I should have done a clean install previously. That's what I did now. Removed node_modules and package-lock.json and installed again. It's working now. Thank you!

Does the v2.2.0 release also include the fix for #165 #176?

bsrdjan commented 4 years ago

Yes, the 2.2.0 and future releases are built as described here: node-rfc/#176/#issuecomment-703690345/