SAP / node-rfc

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

RFC fails remotely but runs successful locally - sy-sysid not set? #239

Closed Zefau closed 2 years ago

Zefau commented 2 years ago

Describe the bug

I'm trying to call SUAUTH_SYSTEM_TRACE_FOR_AUTH to retrieve the current status of the security audit log. Internally, the rfc itself calls RFC_GET_ATTRIBUTES.

Eventually the result for CALLER_SYSTEM_ID, which relies on sy-sysid, is empty. For this reason, the rfc fails to retrieve the status of the security audit log.

Calling the rfc directly within the system using SE37 is successful.

To Reproduce

Simply calling SUAUTH_SYSTEM_TRACE_FOR_AUTH without arguments (respectively using default arguments) should return the security audit log status, but fails returning nothing. Running it via SE37 retrieves the status.

Screenshots

Result SUAUTH_SYSTEM_TRACE_FOR_AUTH

{
  ES_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: ''
  },
  EV_ANY_ACTIVE: '',
  EV_AUTH_ACTIVE: '',
  EV_AUTH_ERRORS_ONLY: '',
  EV_AUTH_FOR_USER: '',
  EV_MODUSER: '',
  EV_TIMESTAMP: '0',
  IV_AUTH_ERRORS_ONLY: '',
  IV_AUTH_FOR_USER: '',
  IV_FUNCTION: 0
}

Result RFC_GET_ATTRIBUTES

{
  CALLER_ASYNC_TYPE: '0',
  CALLER_CLIENT: '',
  CALLER_CODEPAGE: '4103',
  CALLER_DESTINATION: 'DE9 ... 253',
  CALLER_INSTALLATION_NUMBER: '',
  CALLER_IP: '::1',
  CALLER_KERNEL_RELEASE: '753',
  CALLER_MDMP: 'N',
  CALLER_PCS: '2',
  CALLER_PROGRAM: 'node',
  CALLER_RFC_TYPE: 'E',
  CALLER_START_INFO: '20211102 121930 W. Europe Standa',
  CALLER_SYSTEM_ID: '',
  CALLER_SYSTEM_RELEASE: '753',
  CALLER_TCODE: '',
  CALLER_TRANS_TYPE: 'N',
  CALLER_TRUSTED: '',
  CALLER_WHOAMI: ''
}

! CALLER_SYSTEM_ID is not set correctly !

Result SE37

image

Environment

{
  platform: { name: 'win32', arch: 'x64', release: '10.0.18363' },
  env: {
    SAPNWRFC_HOME: 'C:\\Users\\ ... correct path ... \\lib\\nwrfcsdk',
    RFC_INI: '',
    nwrfcsdk_lib_on_path: false
  },
  versions: {
    node: '14.18.1',
    v8: '8.4.371.23-node.84',
    uv: '1.42.0',
    zlib: '1.2.11',
    brotli: '1.0.9',
    ares: '1.17.2',
    modules: '83',
    nghttp2: '1.42.0',
    napi: '8',
    llhttp: '2.1.4',
    openssl: '1.1.1l',
    cldr: '39.0',
    icu: '69.1',
    tz: '2021a',
    unicode: '13.0'
  },
  noderfc: {
    version: '2.5.1',
    nwrfcsdk: { major: 7500, minor: 0, patchLevel: 8 }
  }
}

Additional context

None

bsrdjan commented 2 years ago

Where the CALLER_SYSTEM_ID is expected to be set?

The SUAUTH_SYSTEM_TRACE_FOR_AUTH is called from nodejs script and CALLER_SYSTEM_ID is not the output parameter?

Are you getting expected/correct results from SUAUTH_SYSTEM_TRACE_FOR_AUTH, when running it in SE37?

Zefau commented 2 years ago

Where the CALLER_SYSTEM_ID is expected to be set?

This is a variable set in the ABAP in the program routine of the rfc module RFC_GET_ATTRIBUTES. This rfc module is called in SUAUTH_SYSTEM_TRACE_FOR_AUTH, which is using the results.

The SUAUTH_SYSTEM_TRACE_FOR_AUTH is called from nodejs script and CALLER_SYSTEM_ID is not the output parameter?

Yes, SUAUTH_SYSTEM_TRACE_FOR_AUTH is called via Node.js. And no, CALLER_SYSTEM_ID is only a variable as stated above. The import / output parameter can be found here https://www.sapdatasheet.org/abap/func/suauth_system_trace_for_auth.html. These do not change the incorrect behaviour though.

Are you getting expected/correct results from SUAUTH_SYSTEM_TRACE_FOR_AUTH, when running it in SE37?

Yes. Locally it runs smoothly with correct results.


For clarification, the program code of SUAUTH_SYSTEM_TRACE_FOR_AUTH contains the following code:

  " System checks
  call function 'RFC_GET_ATTRIBUTES'
    importing
      caller_client             = lv_client
      caller_system_id          = lv_sysid
    exceptions
      system_call_not_supported = 1
      no_rfc_communication      = 2
      internal_error            = 3
      others                    = 4.

  if sy-subrc ne 2.
    if lv_client ne sy-mandt or
       lv_sysid  ne sy-sysid.
      return.
    endif.
  endif.

I don't write ABAP, but I read it like lv_sysid is set from caller_system_id. Running RFC_GET_ATTRIBUTES remotely returns an empty value for caller_system_id. Running it via SE37 it correctly holds the system ID.

This why lv_sysid ne sy-sysid is true and thus exists the rfc without result (return).


This is why I would like to set SY-SYSID via node-rfc, because that seems to be required in order to run this correctly?

bsrdjan commented 2 years ago

ok, now I understand. The question is more for ABAP experts, not the node-rfc issue.

What could eventually help is opening a RFC connection from node-rfc, before calling SUAUTH_SYSTEM_TRACE_FOR_AUTH, using the Client open() or Pool acquire() method:

If it does not help, you could reach out to ABAP experts or ask the question in SAP ABAP community: https://community.sap.com/topics/abap