Hello,
You can check the implementation in cancel event of below view.
BP_CONT/BPCONTOverview
Especially how ON EDIT entity is locked and method CL_CRM_BOL_CUSTOM_TX_CTXT=>ADD_TX_CONTEXT( ) is called. Then on CANCEL
CL_CRM_BOL_CUSTOM_TX_CTXT=>IF_BOL_TRANSACTION_CONTEXT~REVERT () is called.
If you refer above class you will get more idea.
Regards
Ashik