1

Below is ABAP program which uses lv_destination which is RFC Target system for functional module BAPI_COMPANYCODE_GETDETAIL.

DATA lv_destination TYPE char10.

CASE sy-sysid+2(1).
  WHEN 'P'.
    lv_destination = 'K0P_040'.
  WHEN OTHERS.
    lv_destination = 'NONE'.
ENDCASE.

CALL FUNCTION 'BAPI_COMPANYCODE_GETDETAIL'
    DESTINATION lv_destination
    ...

Below is the code of javascript code which uses node-RFC libraries to call and communicate with SAP system.

This is ABAP system connection details and below is complete code to create client and calling connect and invoke method.

Where exactly I need to pass lv_destination value i.e; RFC Target system in invoke method ?

const abapSystem_EH8 = {
    user: '',
    passwd: '',
    ashost: '',
    sysnr: '00',
    client: '800',
    
   };

//creating client object
const clientEH8 = new nodeRFC.Client(abapSystem_EH8);

//calling connection method and invoke

clientEH8.connect(function (err) {
                
                if (err) 
                {
              console.error('could not connect to server', err);
              addContext(_this, 'could not connect to server', err);
                 done(err)
                }
               
                console.log('After Connect success:');
                addContext(_this,'After Connect success:')

             clientEH8.invoke('BAPI_COMPANYCODE_GETDETAIL', {
                "COMPANYCODEID": "1000", 
                             
                 },

 function (err, res) 
                    {                
                        if (err) 
                        {                          
                          done(err)
                        }
                                 
               clientEH8.close();  
                      
                        done()                                            
                    });
                                
               });  

I am trying to pass RFC TARGET system value in invoke method of node-RFC library.

Suncatcher
  • 10,355
  • 10
  • 52
  • 90

1 Answers1

2

The lv_destination in the ABAP code refers to RFC destinations that are configured in the calling ABAP system via transaction code SM59. The information that is configured there is exactly the information your code provides through the object abapSystem_EH8: where to find the destination system (ashost and sysnr) and login credentials for an account on the destination system (user, client and passwd).

However, your node.js program does not run on your ABAP system, so it doesn't have access to the repository of RFC destinations pre-configured in SM59. That means you need to either hardcode the login information (not advised) or replicate the functionality of pre-configured RFC destinations in node.js. See Which is the best way to store sensitive credentials in Node.js? for how to avoid putting cleartext passwords into your JavaScript code.

Philipp
  • 67,764
  • 9
  • 118
  • 153