Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Express document "Update was terminated" for BAPI BAPI_SALESORDER_CREATEFROMDAT2

firefighter1
Explorer
0 Kudos
1,096

Hi All,

For first sales order I didn't get any error. But when I tried to create another sales in same session I am getting this error for when BAPI_TRANSACTION_COMMIT is executed. When I check in ST22 got the below error analysis.

While debugging, I got to know that, in internal table DA_XVBFAI has first created sales order data and new sales order data. So it is getting dump. I went through so many pages but didn't the answer, Please hep.

1 ACCEPTED SOLUTION

RaymondGiuseppi
Active Contributor
833

You could

  • call the BAPI_TRANSACTION_COMMIT function module with the parameter WAIT = X.
  • call function module SD_SALES_DOCUMENT_INIT with the parameter SIMULATION_MODE_BAPI = X between each call.
  • Execute the BAPI calls with the DESTINATION 'NONE' followed by a call of RFC_CONNECTION_CLOSE.
13 REPLIES 13

abo
Active Contributor
833

Since the header information in BAPI_SALESORDER_CREATEFROMDAT2 is not a table but a structure, I'd say you can only use it to create ONE order for every commit cycle.

To create a second order, after the first commit set the data for the new order and again call BAPI_SALESORDER_CREATEFROMDAT2 with commit.

RaymondGiuseppi
Active Contributor
834

You could

  • call the BAPI_TRANSACTION_COMMIT function module with the parameter WAIT = X.
  • call function module SD_SALES_DOCUMENT_INIT with the parameter SIMULATION_MODE_BAPI = X between each call.
  • Execute the BAPI calls with the DESTINATION 'NONE' followed by a call of RFC_CONNECTION_CLOSE.

0 Kudos
833

Function module SD_SALES_DOCUMENT_INIT works for me. Thank you.

0 Kudos
357

Hello RaymondGiuseppi,

I am facing simmilar issue with BAPI_PO_CHNAGE could you please suggest any solution for below issue?

We are using 'BAPI_PO_CHANGE' to modify Delivery date, some times after 'BAPI_TRANSACTION_COMMIT' we are getting error “Express document "Update was terminated" received from author”. If we run same file second time it will get processed successfully.

dubbaka_0-1745910038769.png

 

 

Can anyone please let me know how to suppress this error.

dubbaka_1-1745910038777.png

 

CALL FUNCTION 'BAPI_PO_CHANGE'
    EXPORTING
      PURCHASEORDER                = T_EKET-EBELN
*     POHEADER                     = T_HEADER
*     POHEADERX                    = T_HEADERX
*     POADDRVENDOR                 =
*     TESTRUN                      =
*     MEMORY_UNCOMPLETE            =
*     MEMORY_COMPLETE              =
*     POEXPIMPHEADER               =
*     POEXPIMPHEADERX              =
*     VERSIONS                     =
*     NO_MESSAGING                 =
*     NO_MESSAGE_REQ               =
*     NO_AUTHORITY                 =
*     NO_PRICE_FROM_PO             =
*   IMPORTING
*     EXPHEADER                    =
*     EXPPOEXPIMPHEADER            =
   TABLES
     RETURN                       = RETURN
*     POITEM                       = T_POITEM
*     POITEMX                      = T_POITEMX
*     POADDRDELIVERY               = T_POADDRDELIVERY
     POSCHEDULE                   = T_POSCHEDULE
     POSCHEDULEX                  = T_POSCHEDULEX
*     POACCOUNT                    =
*     POACCOUNTPROFITSEGMENT       =
*     POACCOUNTX                   =
*     POCONDHEADER                 =
*     POCONDHEADERX                =
*     POCOND                       = T_POCOND
*     POCONDX                      =
*     POLIMITS                     =
*     POCONTRACTLIMITS             =
*     POSERVICES                   =
*     POSRVACCESSVALUES            =
*     POSERVICESTEXT               =
*     EXTENSIONIN                  =
*     EXTENSIONOUT                 = T_EXTENSIONOUT
*     POEXPIMPITEM                 =
*     POEXPIMPITEMX                =
*     POTEXTHEADER                 =
*     POTEXTITEM                   =
*     ALLVERSIONS                  =
*     POPARTNER                    = T_POPPARTNER
*     POCOMPONENTS                 =
*     POCOMPONENTSX                =
*     POSHIPPING                   =
*     POSHIPPINGX                  =
*     POSHIPPINGEXP                =
*     POHISTORY                    =
*     POHISTORY_TOTALS             =
*     POCONFIRMATION               =
            .
  READ TABLE RETURN  WITH KEY TYPE = 'E' .
  IF SY-SUBRC IS INITIAL.
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
*     IMPORTING
*       RETURN        =
              .
    DELETE RETURN WHERE TYPE NE 'E'.
    LOOP AT RETURN.
      IT_ERROR-MESS = RETURN-MESSAGE.
      IT_ERROR-PO = T_EKET-EBELN.
      APPEND IT_ERROR.
    ENDLOOP.
  ELSE.
    READ TABLE RETURN  WITH KEY TYPE = 'A' .
    IF SY-SUBRC IS INITIAL.
      CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.             .
      DELETE RETURN WHERE TYPE NE 'A'.                                             
      LOOP AT RETURN.
        IT_ERROR-MESS = RETURN-MESSAGE.
        IT_ERROR-PO = T_EKET-EBELN.
        APPEND IT_ERROR.
      ENDLOOP.
    ELSE.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        WAIT          = 'X'.
 
ENDIF.

 

307

Hi,

can you share the SM13 entries for this error,

Try to call the BAPI function with BACKGROUND TASK, if this doesnt work, then try below.

also try to call the BAPI function inside a custom wrapper function with UPDATE TASK, custom function should be start delayed with update.

0 Kudos
291

Hello Karthik, 

Please find the error details from sm13.

dubbaka_0-1746016453648.png

How to call BAPI function inside a custom wrapper function with UPDATE TASK?

Do we need to add SET UPDATE TASK LOCAL before calling BAPI_TRANSACTION_COMMIT ?

 

KarthikD1
Explorer
0 Kudos
256

1) firstly, did you try using the background task option, if it is not working then try creating update task logic.

2) create a custom function module, with update task, then use start immediately, call the BAPI_PO_CHANGE, inside the custom function. commit work will happen as per standard no explicit commit needed.

Subbaka11
Participant
0 Kudos
195

Hello Karthik,

I tried with Update function module which also gives same errors but at different location.

I have added Update FM code below.

dubbaka_0-1747060746137.png

 

CALL FUNCTION 'ZFM_UPDATE_PO_CHANGE' IN UPDATE TASK
  EXPORTING
    PURCHASEORDER       = T_EKET-EBELN
 TABLES
*   RETURN              = RETURN[]
*   POITEM              = P_T_ITEM[]
*   POITEMX             = P_T_ITEMX[]
   POSCHEDULE          = T_POSCHEDULE
   POSCHEDULEX         = T_POSCHEDULEX .
*   AFS_POITEM          = P_T_POITEM[]
*   AFS_POITEMX         = P_T_POITEMX[] .

FUNCTION ZFM_UPDATE_PO_CHANGE.
*"----------------------------------------------------------------------
*"*"Update Function Module:
*"
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(PURCHASEORDER) LIKE  BAPIMEPOHEADER-PO_NUMBER
*"  TABLES
*"      RETURN STRUCTURE  BAPIRET2 OPTIONAL
*"      POITEM STRUCTURE  BAPIMEPOITEM OPTIONAL
*"      POITEMX STRUCTURE  BAPIMEPOITEMX OPTIONAL
*"      POSCHEDULE STRUCTURE  BAPIMEPOSCHEDULE OPTIONAL
*"      POSCHEDULEX STRUCTURE  BAPIMEPOSCHEDULX OPTIONAL
*"      AFS_POITEM STRUCTURE  /AFS/BAPIMEPOITEM OPTIONAL
*"      AFS_POITEMX STRUCTURE  /AFS/BAPIMEPOITEMX OPTIONAL
*"----------------------------------------------------------------------

DATA: LWA_ZBAPIRET2 TYPE ZBAPIRET2 .
CLEAR:LWA_ZBAPIRET2 .

  CALL FUNCTION 'BAPI_PO_CHANGE'
    EXPORTING
      PURCHASEORDER = PURCHASEORDER "P_T_EKET_EBELN
    TABLES
      RETURN        = RETURN
      POITEM        = POITEM[]        "P_T_ITEM[]
      POITEMX       = POITEMX[]       "P_T_ITEMX[]
      POSCHEDULE    = POSCHEDULE[]    "P_T_POSCHED[]
      POSCHEDULEX   = POSCHEDULEX[]   "P_T_POSCHEDX[]
      AFS_POITEM    = AFS_POITEM[]    "P_T_POITEM[]
      AFS_POITEMX   = AFS_POITEMX[].  "P_T_POITEMX[].

LOOP AT RETURN WHERE TYPE EQ 'E' OR TYPE EQ 'A' OR TYPE EQ 'S'.
  LWA_ZBAPIRET2-TYPE           = RETURN-TYPE     .
  LWA_ZBAPIRET2-MESSAGE        = RETURN-MESSAGE     .
MODIFY ZBAPIRET2 FROM LWA_ZBAPIRET2.
CLEAR LWA_ZBAPIRET2  .
ENDLOOP.

ENDFUNCTION.

 

0 Kudos
166

Hi,

I would like to know whether you are calling the BAPI_PO_CHANGE in a SE38 program. If yes, then the below code logic works fine for me. If the BAPI_PO_CHANGE is not called in SE38, please provide the details in which user exit or BADI it is being called.

 

lw_poschedule-po_item        = lf_po_item.
lw_poschedule-delivery_date  = '20250520'.
APPEND lw_poschedule TO lt_poschedule.

lw_poschedulex-po_item        = lf_po_item.
lw_poschedulex-delivery_date  = abap_true.
APPEND lw_poschedulex TO lt_poschedulex.




CALL FUNCTION 'BAPI_PO_CHANGE'
  EXPORTING
    purchaseorder = ls_ekko-ebeln
  TABLES
    return        = lt_bapiret2
    poschedule    = lt_poschedule
    poschedulex   = lt_poschedulex.
READ TABLE lt_bapiret2 TRANSPORTING NO FIELDS WITH KEY type = 'S'.
IF sy-subrc = 0.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      wait   = abap_true
    IMPORTING
      return = lw_bapiret2.
ENDIF.

 

 

 

 

Subbaka11
Participant
0 Kudos
153

Hi Karthik, "We are calling BAPI_PO_CHANGE inside a loop over the PO item internal table. It works fine for a few records; however, when we process 40 to 50 POs (including line items) at once, we receive the error: 'Express document "Update was terminated" received from author.' In such cases, the changes are not applied. Interestingly, if we run the same data again, the error does not occur, and the details are updated successfully."

CALL FUNCTION 'BAPI_PO_CHANGE'
    EXPORTING
      PURCHASEORDER                = EKET-EBELN
   TABLES
     RETURN                       = RETURN
     POSCHEDULE                   = LT_POSCHEDULE
     POSCHEDULEX                  = LT_POSCHEDULEX

  READ TABLE RETURN  WITH KEY TYPE = 'E' .                                    
  IF SY-SUBRC IS INITIAL.
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
              
    DELETE RETURN WHERE TYPE NE 'E'.

    LOOP AT RETURN.
      IT_ERROR-MESS = RETURN-MESSAGE.
      IT_ERROR-PO = T_EKET-EBELN.
      APPEND IT_ERROR.
    ENDLOOP.

  ELSE.
    READ TABLE RETURN  WITH KEY TYPE = 'A' .
    IF SY-SUBRC IS INITIAL.
      CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

      DELETE RETURN WHERE TYPE NE 'A'.
      LOOP AT RETURN.
        IT_ERROR-MESS = RETURN-MESSAGE.
        IT_ERROR-PO = T_EKET-EBELN.
        APPEND IT_ERROR.
      ENDLOOP.
    ELSE.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        WAIT          = 'X'.

      IT_SUCCESS-PO = T_EKET-EBELN.
      IT_SUCCESS-MESS = RETURN-MESSAGE.
      LOOP AT T_POSCHEDULE2 INTO W_POSCHEDULE.                  
        IT_SUCCESS-ITEM = W_POSCHEDULE-PO_ITEM.                 
        IT_SUCCESS-DLV_DATE = W_POSCHEDULE-DELIVERY_DATE.       
        AT END OF PO_ITEM.                                      
          APPEND IT_SUCCESS.
        ENDAT.                                                  
      ENDLOOP.                                                  
      CLEAR IT_SUCCESS.
      CLEAR W_POSCHEDULE.                                       
    ENDIF.
  ENDIF.

KarthikD1
Explorer
0 Kudos
141

option 1:- As you know, the records from file for which the BAPI_PO_CHANGE didnt process, you can collect those fallouts in internal table and at the end of current code logic you can check if the reprocess internal table is not initial, you can call the BAPI_PO_CHANGE again, like recursive untill all the file records had gone thru BAPI_PO_CHANGE. You can use counter, total file records against total records triggered BAPI_PO_CHANGE.

Option 2:- You can use the asynchronous RFC technique, receiving results routine will have BAPI return tables data for every file record triggered BAPI_PO_CHANGE.

https://help.sap.com/doc/saphelp_nw74/7.4.16/en-us/48/9bdeec0c1c73e7e10000000a42189b/frameset.htm

0 Kudos
123

option 1: BAPI_PO_CHANGE is giving Success message first later we are getting 'Express document "Update was terminated" received from author.' records not getting processed, if this error comes in BAPI return parameter it is easy to handle as you said. Can we use WAIT UP TO 2 SECONDS. after calling BAPI_TRASACTION_COMMIT will it fix the issue?

Option 2: I am checking this option.

0 Kudos
90

If you are trying for second option, you can have DESTINATION 'NONE', secondly you can split the total file records into data packets, you can start with 25 and if you are getting results then you can increment it, for all the 25 records (parameter selection screen) if you are getting BAPI return table populated in RECEIVING RESULTS routine.