Table of contents
BADI: USMD_RULE_SERVICE
Create Enhancement Implementation & BADI Implementation
Filter Values
Implementing Class
Code
METHOD if_ex_usmd_rule_service~check_entity.
DATA : lo_data TYPE REF TO data,
lv_cr_number TYPE usmd_crequest,
lv_crtype TYPE usmd_crequest_type,
lv_process TYPE usmd_process,
lo_app_context TYPE REF TO if_usmd_app_context,
lt_data TYPE usmd_ts_data_entity,
lt_ques_data TYPE REF TO data,
lt_gen_data TYPE REF TO data,
lt_tax_data TYPE REF TO data,
lt_tel_data TYPE REF TO data,
lt_msg TYPE usmd_t_message,
ls_msg TYPE usmd_s_message,
lv_country TYPE land1.
FIELD-SYMBOLS:
<lt_ques> TYPE SORTED TABLE,
<ls_ques> TYPE any,
<lv_ques> TYPE any,
<lt_gen> TYPE SORTED TABLE,
<ls_gen> TYPE any,
<lv_gen> TYPE any,
<lt_tel> TYPE SORTED TABLE,
<ls_tel> TYPE any,
<lv_tel> TYPE any.
CALL METHOD cl_usmd_app_context=>get_context
RECEIVING
eo_context = lo_app_context.
IF lo_app_context IS BOUND.
CALL METHOD lo_app_context->get_attributes
IMPORTING
ev_crequest_id = lv_cr_number
ev_crequest_type = lv_crtype
ev_process = lv_process.
ENDIF.
io_model->read_entity_data_all(
EXPORTING
i_fieldname = 'BP_HEADER' " Financial MDM: Field Name
if_active = abap_false " Financial MDM: General Indicator
i_crequest = id_crequest " Change Request
IMPORTING
et_message = lt_msg " Messages
et_data_entity = lt_data " Data for Entity Types
).
lt_ques_data = VALUE #( lt_data[ usmd_entity = 'BP_HEADER' usmd_entity_cont = 'AD_TEL' struct = 'KATTR' ]-r_t_data OPTIONAL ).
IF lv_crtype EQ 'ZSUPP01'. "
IF lt_ques_data IS NOT INITIAL.
ASSIGN lt_ques_data->* TO <lt_ques>.
IF <lt_ques> IS ASSIGNED.
LOOP AT <lt_ques> ASSIGNING <ls_ques>.
ASSIGN COMPONENT 'T_NUMBER' OF STRUCTURE <ls_ques> TO <lv_ques>.
CHECK <lv_ques> IS ASSIGNED.
IF <lv_ques> IS INITIAL.
et_message = VALUE #( BASE et_message ( fieldname = 'T_NUMBER' msgid = 'Z_MESSAGE_CLS' msgno = '016' msgty = 'E' ) ).
ENDIF.
ENDLOOP.
ENDIF.
ELSE.
et_message = VALUE #( BASE et_message ( fieldname = 'T_NUMBER' msgid = 'Z_MESSAGE_CLS' msgno = '016' msgty = 'E' ) ).
ENDIF.
ENDIF. "
CLEAR lt_ques_data.
lt_ques_data = VALUE #( lt_data[ usmd_entity = 'BP_HEADER' usmd_entity_cont = 'AD_EMAIL' struct = 'KATTR' ]-r_t_data OPTIONAL ).
IF lv_crtype EQ 'ZSUPP01'. "
IF lt_ques_data IS NOT INITIAL.
ASSIGN lt_ques_data->* TO <lt_ques>.
IF <lt_ques> IS ASSIGNED.
LOOP AT <lt_ques> ASSIGNING <ls_ques>.
ASSIGN COMPONENT 'E_ADDRESS' OF STRUCTURE <ls_ques> TO <lv_ques>.
CHECK <lv_ques> IS ASSIGNED.
IF <lv_ques> IS INITIAL.
et_message = VALUE #( BASE et_message ( fieldname = 'E_ADDRESS' msgid = 'Z_MESSAGE_CLS' msgno = '017' msgty = 'E' ) ).
ENDIF.
ENDLOOP.
ENDIF.
ELSE.
et_message = VALUE #( BASE et_message ( fieldname = 'E_ADDRESS' msgid = 'Z_MESSAGE_CLS' msgno = '017' msgty = 'E' ) ).
ENDIF.
ENDIF. "
ENDMETHOD.
Note
Message Class not shown in this blog
Create It on your own
If new to message class refer this video: Link
Thank You :)