09-15-2008 3:51 PM
Hi,
As per requirement i need to call 3 BAPI's one after one. If any error throws by any BAPI then all changes should be rollback. Could you please tell me how can i achieve that.
Because if i use transaction commit then its not possible to rollback ...so please advice me.
09-15-2008 3:56 PM
You answered to your own question! Just use BAPI_TRANSACTION_COMMIT if all the 3 bapi's returned success status. Unless they are sequential, this means one need the success of the previous one. In that case, I think you cannot do it.
Regards,
Valter Oliveira.
09-15-2008 3:56 PM
You answered to your own question! Just use BAPI_TRANSACTION_COMMIT if all the 3 bapi's returned success status. Unless they are sequential, this means one need the success of the previous one. In that case, I think you cannot do it.
Regards,
Valter Oliveira.
09-15-2008 3:59 PM
So you mean ... only one trasaction_commit after the last BAPI ... in case if no errors found in any of the above BAPI's. ..
is it correct.
09-15-2008 4:05 PM
So you mean ... only one trasaction_commit after the last BAPI ... in case if no errors found in any of the above BAPI's...
Yes, give it a try (and post here the result). Otherwise, you cannot achieve your goal.
However, if they are related to each other it won't work, like: create sales order and then create a delivery regarding that salesorder. As I said, in those cases i can only remember of workaround, not good solutions.
Regards,
Valter Oliveira.
09-15-2008 3:59 PM
Read all the RETURN or ERROR_MESSAGE_TABLE values, with MESSAGE_TYPE EQ 'S'.
If condition satisfies call other BAPI, like wise do for all BAPIs
____________________________________________________
CALL FUNCTION 'BAPI_PROJECT_MAINTAIN'
EXPORTING
i_project_definition = ipd
i_project_definition_upd = iup
TABLES
i_method_project = imp
i_wbs_element_table = iwbs
e_message_table = it_return.
READ TABLE it_return INTO wa_return WITH KEY message_type = 'E'.
IF sy-subrc = 0.
LOOP AT it_return INTO wa_return WHERE message_type = 'E'.
WRITE 😕 wa_return-message_id,wa_return-message_type,wa_return-message_text .
ENDLOOP.
ELSE.
READ TABLE it_return INTO wa_return WITH KEY message_type = 'S'.
CALL FUNCTION 'BAPI_XXXXXX_XXXXX'.
READ TABLE it_return INTO wa_return WITH KEY message_type = 'E'.
IF sy-subrc = 0.
LOOP AT it_return INTO wa_return WHERE message_type = 'E'.
WRITE 😕 wa_return-message_id,wa_return-message_type,wa_return-message_text .
ENDLOOP.
LOOP AT it_return INTO wa_return WHERE message_type <> 'S'.
CALL FUNCTION 'BAPI_XXX_XXXXX'
READ TABLE it_return INTO wa_return WITH KEY message_type = 'E'.
IF sy-subrc = 0.
LOOP AT it_return INTO wa_return WHERE message_type = 'E'.
WRITE 😕 wa_return-message_id,wa_return-message_type,wa_return-message_text .
ENDLOOP.
ELSE.
READ TABLE it_return INTO wa_return WITH KEY message_type = 'S'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
LOOP AT it_return INTO wa_return WHERE message_type <> 'S'.
WRITE 😕 wa_return-message_id,wa_return-message_type,wa_return-message_text .
ENDLOOP.
ENDLOOP.