CLASS {{p}}cx_presc_error DEFINITION PUBLIC INHERITING FROM cx_root FINAL CREATE PUBLIC. PUBLIC SECTION. TYPES ty_reason TYPE c LENGTH 12. CONSTANTS: BEGIN OF c_reason, empty TYPE ty_reason VALUE 'EMPTY', expired TYPE ty_reason VALUE 'EXPIRED', quantity TYPE ty_reason VALUE 'QUANTITY', unknown TYPE ty_reason VALUE 'UNKNOWN', dose TYPE ty_reason VALUE 'DOSE', duplicate TYPE ty_reason VALUE 'DUPLICATE', END OF c_reason. METHODS constructor IMPORTING iv_reason TYPE ty_reason. METHODS get_reason RETURNING VALUE(rv_reason) TYPE ty_reason. METHODS get_message_text RETURNING VALUE(rv_text) TYPE string. PRIVATE SECTION. DATA mv_reason TYPE ty_reason. ENDCLASS. CLASS {{p}}cx_presc_error IMPLEMENTATION. METHOD constructor. super->constructor( ). mv_reason = iv_reason. ENDMETHOD. METHOD get_reason. rv_reason = mv_reason. ENDMETHOD. METHOD get_message_text. CASE mv_reason. WHEN c_reason-empty. rv_text = 'The prescription has no items'. WHEN c_reason-expired. rv_text = 'The prescription is expired'. WHEN c_reason-quantity. rv_text = 'The quantity is not positive'. WHEN c_reason-unknown. rv_text = 'The drug is not in the drug master'. WHEN c_reason-dose. rv_text = 'The daily dose is not allowed'. WHEN c_reason-duplicate. rv_text = 'The drug appears more than once'. ENDCASE. ENDMETHOD. ENDCLASS.