This blog post contains code templates for adding ZCX_RETURN2 exception raising code.
Template overview
◉ CREATE_BY_SYSTEM_MESSAGE (without MESSAGE statement)
◉ CREATE_BY_SYSTEM_MESSAGE (with MESSAGE statement for custom message)
◉ CREATE_BY_BAPIRETURN_STRUC
◉ CREATE_BY_BAPIRETURN_TABLE
◉ CREATE_BY_BAPIRET1_TABLE
◉ CREATE_BY_BAPIRET2_STRUC
◉ CREATE_BY_BAPIRET2_TABLE
◉ CREATE_BY_BDC_MESSAGE_TABLE
◉ CREATE_BY_EXCEPTION_OBJECT – catch for example CX_ROOT