Hi Vaibhav,
There are 2 types of transaction contexts. Global and granular context.
Instead of using global context ( context instance fetched using bol core ), use granular context ( Instance fetched using entity ).
lr_trans = lr_entity->GET_TRANSACTION( ).
if lr_trans->CHECK_SAVE_POSSIBLE () = abap_true.
lr_trans->commit().
else.
lr_trans->rollback()
endif.
when you do rollback or commit, first transaction is finished. So you can start next transaction freshly.
this allows you to save your second transaction even though your first transaction got failed.
I think I also came across this issue long back. I did something like this. Please try this and share your feedback.
Regards,
Pallavi