2012 Apr 03 10:29 AM
What other statement is used to commit work other that 'BAPI_TRANSACTION_COMMIT' after creating a service order using 'BAPI_ALM_ORDER_MAINTAIN'.
Even COMMIT WORK, doesn't do the needful.
Moderator Message: Please use a more meaningful subject line for your post.
Message was edited by: Suhas Saha
What other statement is used to commit work other that 'BAPI_TRANSACTION_COMMIT' after creating a service order using 'BAPI_ALM_ORDER_MAINTAIN'.
Even COMMIT WORK, doesn't do the needful.
Moderator Message: Please use a more meaningful subject line for your post.
Message was edited by: Suhas Saha
2012 Apr 03 10:37 AM
Hi Nikhil,
Did you un-comment the import parameter 'return' of 'BAPI_TRANSACTION_COMMIT' and check if it's INITIAL. In case of an unsuccessful COMMIT WORK, the value of return will be helpful.
Also, try using COMMIT WORK AND WAIT.
In worst case, a NOT RECOMMENDED solution that I have used in a slow system was calling 'BAPI_TRANSACTION_COMMIT' in DO - WHILE loop with 5 loop passes hard-coded to verify if it works.
Hope this helps.
Regards, Pranav.
2012 Apr 03 10:45 AM
No other statement is required. But, did you forget to add a method 'SAVE' in BAPI_ALM_ORDER_MAINTAIN call ?
Small sample :
* Data definition
DATA: lt_methods TYPE TABLE OF bapi_alm_order_method,
ls_methods LIKE LINE OF lt_methods,
lt_header TYPE TABLE OF bapi_alm_order_headers_i,
ls_header LIKE LINE OF lt_header,
lt_header_up TYPE TABLE OF bapi_alm_order_headers_up,
ls_header_up LIKE LINE OF lt_header_up.
REFRESH: lt_methods, lt_header, lt_header_up.
* Change a data to the header
CLEAR: ls_methods.
ls_methods-refnumber = 1.
ls_methods-objecttype = 'HEADER'.
ls_methods-method = 'CHANGE'.
ls_methods-objectkey(12) = aufk-aufnr.
APPEND ls_methods TO lt_methods.
CLEAR: ls_header.
ls_header-orderid = aufk-aufnr.
ls_header-short_text = aufk-ktext.
APPEND ls_header TO lt_header.
CLEAR: ls_header_up.
ls_header_up-orderid = aufk-aufnr.
ls_header_up-short_text = 'X'.
APPEND ls_header_up TO lt_header_up.
* Save data " REQUIRED STEP OF COURSE
CLEAR: ls_methods.
ls_methods-refnumber = 2.
ls_methods-method = 'SAVE'.
APPEND ls_methods TO lt_methods.
* Execution
CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
it_methods = lt_methods
it_header = lt_header
it_header_up = lt_header_up
return = return.
* Error messages
LOOP AT return WHERE type = 'E' OR type = 'A'.
MESSAGE ID return-id TYPE 'I' NUMBER return-number
WITH return-message_v1 return-message_v2
return-message_v3 return-message_v4.
ENDLOOP.
* Commit or Rollback
IF sy-subrc = 0.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
MESSAGE i228(zfsi) WITH aufk-aufnr aufk-aedat sy-datum.
ENDIF.
Take some time to read the BAPI documentation
Regards,
Raymond
2012 Apr 03 10:46 AM
Hello Nikhil,
Read the documentation of the BAPI thoroughly. You'll understand why a COMMIT WORK or BAPI_TRANSACTION_COMMIT doesn't commit the changes to the DB!
In fact using BAPI_TRANSACTION_COMMIT without the SAVE method terminates the update
BR,
Suhas
2012 Apr 03 11:01 AM
Please see the standard SAP documentation below:
Every time the BAPI is called up, a SAVE or DIALOG method must be transferred. Normally, calling up a BAPI is seen as a transaction. All data that is changed in the BAPI should be saved to the database immediately. The BAPI checks whether a SAVE method exists, otherwise it terminates processing. A test run of the BAPI is composed of a normal call-up using the SAVE method and a subsequent BAPI_TRANSACTION_ROLLBACK. To call up the BAPI without the SAVE method, for example, to realize dialog transactions, the BAPI can be called up with the DIALOG method. This switches off the check for the SAVE method. The processor must then ensure that later either a SAVE method or a BAPI_TRANSACTION_ROLLBACK is called up.
A BAPI_TRANSACTION_COMMIT without SAVE method terminates processing in the update to ensure that no inconsistent data is written to the database. The processor who called up the BAPI does not receive any confirmation for the termination of the update in the target system. This logic is necessary as the order data was flagged for updating with BAPI_TRANSACTION_COMMIT through the SAVE method. However, the status information was already flagged for updating when the BAPI was called up. A BAPI_TRANSACTION_COMMIT without SAVE method then just saves the status information and would generate inconsistent orders, if the updating was not terminated.
Regards.
Tanmoy
2012 Apr 03 10:47 AM
Does the commit work takes time to save or it doesn't work at all?
if it's the second case then then bapi is not executing successfully. Are you checking the return table of the BAPI for error?
2012 Apr 03 10:28 PM
I have used this BAPI and faced the similar problem.. I found that writing " WAIT for 5 seconds" and then commit work was successfull.
Regards,
Archna
2012 Apr 04 3:45 AM
Hi Nikhil,
Please check BAPI return parameter and if no error in return internal table check BAPI_ALM_ORDER_MAINTAIN Document there are some method like
Have you Called Save Method to Save all data ?
Please check
Regards,
Yukti
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |