cancel
Showing results for 
Search instead for 
Did you mean: 

how to commit a transaction in BAPI using JCO3

Former Member
0 Kudos

Hi I am trying to create a Purchase Order. I am able to successfully create. Program is running fine without any errors , but its not adding data in the SAP. I am wondering how this is  happening. Please can you help me in understanding why this happens.

I tried using commit function as well as JCOContext.begin() and end() . In both the cases my program is running but its not creating the data in sap.


        try

        {

        JCoContext.begin(destination);

        createPurchaseOrderFunction.execute(destination);

        functionTransactionCommit.execute(destination);

        functionTransactionCommit.getImportParameterList().setValue("WAIT", 10);

        JCoContext.end(destination);

        }

        catch(Exception e)

        {

        throw e;

        }

I tried by removing 6 th line. Program is working for me in both the conditions , but its not creating record in sap , but when i am printing the Table structure it is showing record , but unfortunately record is not updated in SAP.


JCoTable table = createPurchaseOrderFunction.getTableParameterList().getTable("POITEM");

Accepted Solutions (0)

Answers (1)

Answers (1)

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Utsav,

your approach is correct, the sequence needs to be executed within a JCoContext. I assume that functionTransactionCommit is pointing to BAPI_TRANSACTION_COMMIT. One remark though: Setting an import parameter after execution does not have any effect. You should switch it with line 5 if you want it to have effect. Furthermore, it's a flag. You can set e.g. 'X' for signalling to wait or you use the default ' ', which means the function module will simply execute a commit work and return afterwards.

Best regards,

Markus