Arvind Kumar
Arvind Kumar

Reputation: 103

Getting "Not logged on in interface XBP" error when calling XBP function module via SAP .NET Connector

I am getting the error while calling BAPI_XBP_JOB_START_IMMEDIATELY

            IRfcFunction rfcFunc = repository.CreateFunction("BAPI_XMI_LOGON");
            rfcFunc.SetValue("extcompany", "testC");
            rfcFunc.SetValue("extproduct", "testP");
            rfcFunc.SetValue("interface", "XBP");
            rfcFunc.SetValue("version", "3.0");

            rfcFunc.Invoke(dest);

            rfcFunc = repository.CreateFunction("BAPI_XBP_JOB_START_IMMEDIATELY");
            rfcFunc.SetValue("jobname", "MYSCHEDULEDJOB");
            rfcFunc.SetValue("jobcount", "15530600");
            rfcFunc.SetValue("external_user_name", "username");

            rfcFunc.SetValue("target_server", "devsapsystem");
            rfcFunc.Invoke(dest);

The first function module is giving sessionid in output, but the second XBP call is giving the message

Not logged on in interface XBP

Is there any problem parameters that I am passing or do I need maintain some session during these sequential calls?

Upvotes: 1

Views: 1943

Answers (2)

Sandra Rossi
Sandra Rossi

Reputation: 13638

If you call BAPI_XBP_JOB_START_ASAP or any other XBP BAPI without first calling BAPI_XMI_LOGON (because XBP is an application of the "XMI family"), it returns a functional error in the parameter RETURN.

Note that this answer is not limited to SAP .NET Connector, the XBP BAPI can be run from any RFC-based client (JCo, NW RFC SDK, ABAP, SAP BC, SAP-GUI-integrated RFC client, pyRFC, etc.)

You must log into XMI via BAPI_XMI_LOGON with these input parameters:

  • EXTCOMPANY: any name (your company name, no check)
  • EXTPRODUCT: any name (your software name, no check)
  • INTERFACE: the ID of the XMI application that you want to use ("XBP" in your case)
  • VERSION: the version of the XMI application that you want to use (it could be "1.0", "2.0" or "3.0" for XBP, I recommend to use the latest version)

BAPI_XMI_LOGON returns these parameters:

  • SESSIONID: an ID to be used if you need to call BAPI_XMI_SELECT_LOG to read the XMI log
  • RETURN: error message if any

BAPI_XBP_JOB_START_ASAP and BAPI_XBP_JOB_START_IMMEDIATELY can run only an existing job (prepared in advance and waiting to be started). If you want to create your own job, call these BAPI:

  • BAPI_XBP_JOB_OPEN: you pass a job name and it returns a "job count"
  • Either BAPI_XBP_JOB_ADD_ABAP_STEP or BAPI_XBP_JOB_ADD_EXT_STEP
  • BAPI_XBP_JOB_CLOSE

BAPI_XBP_JOB_START_ASAP and BAPI_XBP_JOB_START_IMMEDIATELY expect these input parameters:

  • JOBNAME: the name of the job to start
  • JOBCOUNT: the number of the job to start
  • EXTERNAL_USER_NAME: any name
  • etc.

Both return this parameter:

  • RETURN: error message if any

Source: me + my own answer at sap.com.

Upvotes: 0

vwegert
vwegert

Reputation: 18483

You will need to execute the function calls in a single session (stateful mode). This is outlined in detail in the JCo documentation - basically you will have to wrap your logic into JCoContext method invocations like this:

try
{
  JCoContext.begin(destination); 
  try
  {
    // your function calls here
    // probably bapiTransactionCommit.execute(destination);
  }
  catch(AbapException ex)
  {
    // probably bapiTransactionRollback.execute(destination);
  } 
}
catch(JCoException ex)
{
  [...]
}
finally
{
  JCoContext.end(destination);
}

Upvotes: 2

Related Questions