cancel
Showing results for 
Search instead for 
Did you mean: 

nCo 3 fails after beginContext/endContext

sistemes_emaya
Explorer
0 Kudos

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!

Accepted Solutions (1)

Accepted Solutions (1)

hynek_petrak
Active Participant
0 Kudos

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.

sistemes_emaya
Explorer
0 Kudos

Hi,

I've found In ST22 an authorization error and with this the problem was solved!!

Thanks!!!

And you are right, I make a mistake while copying the code from my editor to the forum, an invoke call was not copied.

Thanks again!

Answers (0)