Skip to Content
author's profile photo Former Member
Former Member

Question on working with tRFC or qRFC with windows client app

I have the following requirement: "Create a document and classify a document and update state".

I startet with the following BAPIs:

  • RfcSessionManager.BeginContext(this.Destination);
  • CVAPI_DOC_CREATE
  • BAPI_TRANSACTION_COMMIT
  • RfcSessionManager.EndContext(this.Destination);

=> Document is created


  • RfcSessionManager.BeginContext(this.Destination);
  • BAPI_OBJCL_CREATE
  • BAPI_TRANSACTION_COMMIT
  • RfcSessionManager.EndContext(this.Destination);

=> Document is classified

  • RfcSessionManager.EndContext(this.Destination);
  • CVAPI_DOC_CHANGE
  • BAPI_TRANSACTION_COMMIT
  • RfcSessionManager.EndContext(this.Destination);

=> Document status is changed


This works generally but I now wanted to make it more transaction-save (i.e. if the classification cannot be performed (because of wrong parameters entered by the user), the creation of the document should be rolled back also.

In this scenario, I analysed the return messages of the specific BAPIs which returned "E" and informed the user.


So I added the three BAPIs to a transaction like this:


RfcTransaction transaction = new RfcTransaction("testQueue");

RfcTID tid = transaction.Tid;

transaction.AddFunction(CVAPI_DOC_CREATE);

transaction.AddFunction(BAPI_OBJCL_CREATE);

transaction.AddFunction(CVAPI_DOC_CHANGE);

transaction.Commit(this.Destination);


The commit doesn't fail (no exception) but also not classification is created. The document is in the desired state so it seems that the 1st and 3rd BAPI were successfully executed.

I then tried to provoke an error in the 3rd call (updating to unknown status) which obivously led to complete rollback: no document was created but the commit still didn't fail.

UPDATE: Didn't check correctly

The commit doesn't fail (no exception) but the document stays in the first state so it seems only the first BAPI is commited and the following ones are ignored.


UPDATE2:

If I add a BAPI_TRANSACTION_COMMIT after each BAPI-CALL, the document is in the desired state but no classification created:

RfcTransaction transaction = new RfcTransaction("testQueue");

RfcTID tid = transaction.Tid;

transaction.AddFunction(CVAPI_DOC_CREATE);

transaction.AddFunction(BAPI_TRANSACTION_COMMIT);

transaction.AddFunction(BAPI_OBJCL_CREATE);

transaction.AddFunction(BAPI_TRANSACTION_COMMIT);

transaction.AddFunction(CVAPI_DOC_CHANGE);

transaction.AddFunction(BAPI_TRANSACTION_COMMIT);

transaction.Commit(this.Destination);


Is there a way to get information on client side (via NCO) if the operation was really successful i.e. the complete transaction was processed without error?

If there are errors (ie return = "E") how can the messages be retrieved in such a case?


Any help would be greatly appreciated!



Message was edited by: Tobias Buhl

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Nov 18, 2015 at 09:13 PM

    Hi Tobias,

    what if you implement following sequence:

    • RfcSessionManager.BeginContext(this.Destination);
    • Call CVAPI_DOC_CREATE
    • Check the return e.g. psx_message, on error call BAPI_TRANSACTION_ROLLBACK
    • Call BAPI_OBJCL_CREATE
    • Check the return table, on error call BAPI_TRANSACTION_ROLLBACK

    • Call CVAPI_DOC_CHANGE
    • Check the return e.g. psx_message, on error call BAPI_TRANSACTION_ROLLBACK
    • If all good sofar call BAPI_TRANSACTION_COMMIT
    • RfcSessionManager.EndContext(this.Destination);

    The guys are discussing the principle on another set of BAPIs : Calling Multiple BAPIs in a single LUW | SCN

    Hynek

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Tobias,

      this is an important side note: If the prerequisite exists that CVAPI_DOC_CREATE was committed before BAPI_OBJ_CREATE can be called, you cannot call them in a single transaction sequence. Then, using a different approach like you mentioned now, is the best choice.

      Best regards,

      Markus

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.