ā2014 May 19 10:11 AM
Hi Experts,
Is there a BAPI that can rollback a transaction or an update that was created when the transaction find an error ?
Example: When a program finds an error during the transaction, all the successful transactions must not be updated.
1 0001 Successful
2 0002 Successful
3 0003 Successful
4 0004 Error
5 0005 Successful
But if all infotypes are successful the program must update.
1 0001 Successful
2 0002 Successful
3 0003 Successful
4 0004 Successful
5 0005 Successful
The program right now, saves all infotypes with successful status.
ā2014 May 19 10:16 AM
Steps 1 through 5 is your logical unit of work (LUW), so you would only do a commit work (BAPI_TRANSACTION_COMMIT) in case of all five being successfull, and a rollback (BAPI_TRANSACTION_ROLLBACK) if at least one ended in error.
This looks pretty standard, the key is that there is no commit work within the single steps, otherwise you cannot rollback later on.
Thomas
ā2014 May 19 10:26 AM
Hi Thomas,
Im using HRHAP_DOCUMENT_CREATE every single line. Is it possible for it not to commit every single step ?
ā2014 May 19 10:39 AM
You can add simulation check using FM HRHAP_BC_DOCUMENT.
for eg.
* For Simulation
Loop
if FM HRHAP_BC_DOCUMENT returns errors
create log table.
endif.
endloop.
* No errors then create
if log table is empty.
loop
call FM HRHAP_DOCUMENT_CREATE
endloop.
endif.
ā2014 May 19 10:43 AM
Hi,
fm HRHAP_DOCUMENT_CREATE has an import parameter VTASK.
All option for VTASK can be seen in the values of domain HR_VTASK.
Value 'B' looks quite interesting for buffer update, maybe this one is the right. Maybe you have to call an additional fm to put the buffer updates to database after all updates.
Regards,
Klaus
ā2014 May 19 10:17 AM
Hi Jepoy,
Please use BAPI_TRANSACTION_ROLLBACK.
Regards,
Abijith
ā2014 May 19 10:34 AM
Hi Jepoy ,
I think we have a export parameter S_RETURN which will return the provide us the returning value, so depending upon the S_RETURN-MSGTY you can write a conditional statement that if S_RETURN-MSGTY is 'S' then call BAPI "COMMIT WORK" else ROLL_BACK.
Thanks & Regards,
Seshadri.
ā2014 May 19 10:39 AM
Thanks for the reply.
If I do this even though I have an status = 'E' it will update all status with 'S'. My requirement is not to update anything if I find an error/status = 'E'.
ā2014 May 19 11:36 AM
Hi Jepoy,
After calling the FM , write
IF MSGTYP = 'S'
Use COMMIT WORK FM.
else.
clear the contents
Use ROLL BACK FM.
endif.
I think above logic may be useful.
Seshadri.
ā2014 May 20 1:30 AM
The FM will commit even though you don't use the commit FM.
CALL FUNCTION 'HRHAP_DOCUMENT_CREATE'
EXPORTING
PLAN_VERSION = c_plvar
T_HEADER_APPRAISER = it_appraiser
T_HEADER_APPRAISEE = it_appraisee
T_HEADER_OTHERS = it_header_others "lt_hap_t_header_others
S_HEADER_TEXTS = wa_header_text
S_HEADER_DATES = wa_header_dates
S_HEADER_STATUS = wa_header_status
S_HEADER_DISPLAY = wa_header_display
T_BODY_COLUMNS = it_body_columns
T_BODY_ELEMENTS = it_body_elements
T_BODY_CELLS = it_body_cells
S_DOC_PROCESSING = wa_hap_s_doc_processing
VTASK = 'D'
IMPORTING
S_RETURN = wa_return_message
CHANGING
S_APPRAISAL_ID = wa_hap_s_appraisal_id
T_HEADER_PART_APPRAISERS = it_hap_t_header_part
T_BODY_CELL_NOTES = it_hap_t_body_cell_notes
T_STATUS_NOTES = it_hap_t_status_note
ā2014 May 19 10:43 AM
Hi, that's work of SAP-LUW. You need to bundle all your sub-calls to one FM and call this FM in update task, probably you will use local update (set update task local). During the update, commits are omitted, but any rollback stops&rollback all the steps of the update process. See LUW realted SAP ABAP help.
Br
Bohuslav
ā2014 May 19 10:45 AM
Hi Jepoy,
All success and error log will be stores in RETURN table , so filter error one(message type E) if it exits then use BAPI ROLLBACK , if not then commit those work.
Regards,
Krishna
ā2014 May 19 11:50 AM