Skip to Content

nCo 3 fails after beginContext/endContext

Hi,

I'm developing an application with some calls to function modules on SAP. The function modules which just one call without need to encapsulate between a beginContext and endContext works fine, but when I need to call a function module that need to call before it's execution to another function call, for example BAPI_TRANSACTION_COMMIT, and needs to execute with beginContext/endContext it works fine but the next call after that everytime fails:

This works ok:

RfcRepository rfcRepository = rfcDestination.Repository;

IRfcFunction rfcFunction = rfcRepository.CreateFunction("ZCAU_LOG_000557");

rfcFunction.SetValue("MATERIAL", idMaterial);

rfcFunction.SetValue("CENTRO", centro);

rfcFunction.SetValue("ALMACEN", almacen);

rfcFunction.Invoke(rfcDestination);

result = rfcFunction.GetDecimal("STOCK");

This works ok, but after this the next call fails.

RfcRepository rfcRepository = rfcDestination.Repository;

IRfcFunction rfcFunction = rfcRepository.CreateFunction("BAPI_GOODSMVT_CREATE");

RfcSessionManager.BeginContext(rfcDestination);

rfcFunction.Invoke(rfcDestination);

IRfcTable result = rfcFunction.GetTable("RETURN");

IRfcFunction rfcFunctionCommit = rfcRepository.CreateFunction("BAPI_TRANSACTION_COMMIT");

RfcSessionManager.EndContext(rfcDestination);

The next call after this returns the following message:

SAP.Middleware.Connector.RfcCommunicationException: Connection with convid [64494310] was canceld, closed or broken.

Then the next call works fine again.

Anyone can help me?

Thanks!

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Sep 07, 2016 at 11:06 AM

    In general you may want to enable tracing, look into the trace logs. On the SAP side look into the ST22.

    Is the above code complete? Seems you do not invoke the rfcFunctionCommit.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.