Getting “Not logged on in interface XBP” error when calling XBP function module via sap .net connector

拥有回忆 提交于 2019-12-11 13:06:44

问题


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);

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.


回答1:


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);
}


来源:https://stackoverflow.com/questions/31205019/getting-not-logged-on-in-interface-xbp-error-when-calling-xbp-function-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!