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

FunctionCall Event

Fired when the component receives a remote function call request from the SAP system.

Syntax

[VB.NET]
Public Event OnFunctionCall As OnFunctionCallHandler
[C#]
public event OnFunctionCallHandler OnFunctionCall;

public delegate void OnFunctionCallHandler(object sender, SapserverFunctionCallEventArgs e);

class SapserverFunctionCallEventArgs : EventArgs {
  string FunctionName {get;}
  string TransactionId {get;}
  string CallType {get;}
}

Remarks

When the SAP system calls a function on your server this event will fire. The FunctionName parameter will contain the name of the function the SAP system wishes to execute. If this the TransactionMode was set to tmTransactional, the TransactionId parameter will contain a unique transaction identifier and CallType will be "T". For regular synchronous calls CallType will be "S".

To process this function call, the first thing you must do is retrieve the ReceiveParams and tables. The ReceiveParams collection starts off empty. You must add the names of the parameters you wish to receive, and then call UpdateReceiveParams. If the caller of the function provided values for the parameters you indicated, each parameter contained in the ReceiveParams collection will now contain a value. If you're expecting to table data from the SAP system you should also set the TableCount as well as the TableName for each table you expect to receive.

After processing the input data, it's time to reply to the function call. Set the ReplyParams collection with the parameters you wish to return, and also update the RowData collection for each TableIndex. Then call SendReply.

The following example illustrates how to implement a very simple function. 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();
  }
}

If you wish to indicate to the SAP system that an error has occurred, use RaiseException instead of SendReply. For instance:

  if (e.FunctionName.Equals("Z_HELLO")) {
    if (e.CallType.Equals("T")) {
      SapServer1.RaiseException("This function is not available in Transactional mode.");
    }
  }

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