ERP Integrator V2 - Online Help
ERP Integrator V2
Questions / Feedback?

InstallFunction Method

Registers your function with the sap system.

Object Oriented Interface

public function doInstallFunction($functionname, $documentation);

Procedural Interface

inerp_sapserver_do_installfunction($res, $functionname, $documentation);

Remarks

Set the FunctionName parameter to the name of the function you plan to call remotely from the NetWeaver system. The Documentation parameter can be set with any descriptive text, however you may wish to follow the formatting used by other SAP functions. For example:

"Simple greeting app.

IMPORTING
  FIRSTNAME      C(256)
    Your first name.
  LASTNAME       C(256)
    Your last name.
EXPORTING
  GREETING       C(512)
    A nice hello to you."
where "IMPORTING" lists the ReceiveParams and "EXPORTING" the ReplyParams.

When a function is remotely called by the NetWeaver system, the FunctionCall event will fire. When it does, check if the FunctionName parameter of the FunctionCall event matches the name of the function you installed, and if it does execute the function. For example:

First, set up the connection, install the function, and begin listening for calls from the SAP system.

  SapServer1.AcceptConnections("Hello.App", "localhost", "sapgw00");
  SapServer1.InstallFunction("Z_HELLO", "Simple greeting app.");
  SapServer1.Listening = true;
Then, implement the function you installed inside the FunctionCall event.
void SapServer1_OnFunctionCall(object sender, SapserverFuncionCallEventArgs e) {
  if (e.FunctionName.Equals("Z_HELLO")) {
    SapServer1.ReceiveParams.Add(new nsoftware.InERP.SapParam("FIRSTNAME", "",ptCharacters));
    SapServer1.ReceiveParams.Add(new nsoftware.InERP.SapParam("LASTNAME", "", ptCharacters));
    SapServer1.UpdateReceiveParams();
        
    String greeting = "Hello " + SapServer1.ReceiveParams.ElementAt(0).Value + " " +
                       SapServer1.ReceiveParams.ElementAt(1).Value + ", I hope that you are well.";
    SapServer1.ReplyParams.Add(new nsoftware.InERP.SapParam("GREETING", greeting, ptCharacters));
    SapServer1.SendReply();
  }
}

Functions may only be installed after successfully connecting to the SAP system via the AcceptConnections method. While InstallFunction may be executed from inside the FunctionCall event, its use there is limited as your functions must be installed before the SAP system will make remote calls to your server.

 
 
Copyright (c) 2017 /n software inc. - All rights reserved.
Build 2.0.6240.0