SAP / node-rfc

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

Node RFC Connection and Testing with ABAP #271

Closed kamskanagi closed 1 year ago

kamskanagi commented 1 year ago

Hello everyone,

I have successfully install the SAP NWRFC SDK and node-rfc. By the way, i am new to SAP NWRFC SDK and node-rfc. Next i want to test the connection. so i created a file name client.js in the clone node-rfc directory and use the below code. in the same directory i created sapnwrfc.ini and connection details.

When i run the client.js, it create dev_rfc.log file with information about my system as show below.

My question are 1) How can i know if my connection is successful or not? 2) Do i have to create, in my case 'client.js and sapnwrfc.ini" in the node-rfc folder or i can use any folder or directory in my system. 3) Is it possible to do GET and POST? if yes, can you help me with the reference.

client.js `

    const noderfc = require("node-rfc");
    const pool = new noderfc.Pool({ connectionParameters: { dest: "MME" } });

  (async () => {
      try {
    // get a client connection instance
    const client = await pool.acquire();

    // invoke ABAP function module, passing structure and table parameters

    // ABAP structure
    const abap_structure = {
        RFCINT4: 345,
        RFCFLOAT: 1.23456789,
        RFCCHAR4: "ABCD",
        RFCDATE: "20180625", // ABAP date format
        // or RFCDATE: new Date('2018-06-25'), // as JavaScript Date object, with clientOption "date"
    };
    // ABAP table
    let abap_table = [abap_structure];

    const result = await client.call("STFC_STRUCTURE", {
        IMPORTSTRUCT: abap_structure,
        RFCTABLE: abap_table,
    });

    // check the result
    console.log(result);
  } catch (err) {
    // connection and invocation errors
    console.error(err);
  }

})();`

dev_rfc.log

`

      **** Log file opened at 2022-10-18 16:19:58.917830 UTC+08:00 (---- Standard Time), Encoding UTF-8
     NW RFC Library: SDK variant, Release 750 Patch Level 10, Compiled on Jun 11 2022 06:51:55
     CPIC library: 753.2021.05.10 version 3, NI library: 40, Kernel Release: 753 Patch Level 1021
     Current working directory: c:\Users\---\Documents\Codeing\node-rfc, Program: node
     Hardware: PC with Windows ---), Operating_system: Windows NT 10.0
      Hostname: -----, IP address: ----, IPv6 address: fe80::----:----:----:----

     2022-10-18 16:19:58.918064 [20920] >> Info entry
       Did find config file c:\Users\----\Documents\Codeing\node-rfc\sapnwrfc.ini.`
kamskanagi commented 1 year ago

I was able to know able to test the connection and it was successful.

Thanks

bsrdjan commented 1 year ago

Sorry for the late reply. The node-rfc is using SAP proprietary TCP/IP based protocol.

HTTP server can be added like here for example: https://github.com/SAP-samples/node-rfc-samples/tree/main/integration/express