问题
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