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.