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 = newRfcTransaction("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 = newRfcTransaction("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