SAP MDG: Locking Supplier General Data When Data Already exists

Hi SCN Folks, 

Hope you guys are doing great 🙂

Note 01: This blog does not include execution screenshots.
Note 02: 
The entire code was developed and validated in the SANDBOX system, with results meeting expectations.
Note 03: 
There are several ways to implement; this blog is written about one of them.

Create one custom class & redefine the standard class (CL_MDG_BS_ECC_HANDLER)

Method Responsible: IF_MDG_BS_BP_ACCESS_HANDLER~GET_ENTITY_PROPERTIES.

DATA: lv_crequest_type TYPE usmd_crequest_type,
lv_cr_number TYPE usmd_crequest,
lo_app_context TYPE REF TO if_usmd_app_context.

DATA: lo_data TYPE REF TO data,
lt_data TYPE usmd_ts_data_entity,
lt_msg TYPE usmd_t_message,
ls_msg TYPE usmd_s_message,
lt_erp_v TYPE REF TO data.

FIELD-SYMBOLS:
<lt_erpv> TYPE SORTED TABLE,
<ls_erpv> TYPE any,
<lv_erpv> 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_crequest_type
ev_process = lv_process.

lv_crequest_type = iv_crequest_type.

CALL METHOD super->if_mdg_bs_bp_access_handler~get_entity_properties
EXPORTING
iv_entity = iv_entity
is_key = is_key
io_model = io_model
iv_crequest_type = iv_crequest_type
iv_crequest_step = iv_crequest_step
iv_crequest_index = iv_crequest_index
CHANGING
cf_read_only = cf_read_only.

IF iv_crequest_type EQ ‘ZMDGS03’.
io_model->read_entity_data_all(
EXPORTING
i_fieldname = ‘BP_HEADER’
if_active = abap_false
i_crequest = lv_cr_number
IMPORTING
et_message = lt_msg
et_data_entity = lt_data
).

lt_erp_v = VALUE #(
lt_data[ usmd_entity = ‘BP_HEADER’
usmd_entity_cont = ‘BP_VENGEN’
struct = ‘KATTR’ ]-r_t_data OPTIONAL ).

IF lt_erp_v IS NOT INITIAL.
IF iv_entity EQ ‘BP_VENGEN’.
cf_read_only = ‘X’.
ENDIF.
ENDIF.
ENDIF.

ENDIF.

SAP S/4HANA   SAP Master Data Governance   ABAP Development  

Thank You, 
Sandeep Suggu.
SAP Community Profile | SAP Profile | LinkedIn   

 

​ Hi SCN Folks, Hope you guys are doing great 🙂Note 01: This blog does not include execution screenshots.Note 02: The entire code was developed and validated in the SANDBOX system, with results meeting expectations.Note 03: There are several ways to implement; this blog is written about one of them.Create one custom class & redefine the standard class (CL_MDG_BS_ECC_HANDLER)Method Responsible: IF_MDG_BS_BP_ACCESS_HANDLER~GET_ENTITY_PROPERTIES.DATA: lv_crequest_type TYPE usmd_crequest_type,
lv_cr_number TYPE usmd_crequest,
lo_app_context TYPE REF TO if_usmd_app_context.

DATA: lo_data TYPE REF TO data,
lt_data TYPE usmd_ts_data_entity,
lt_msg TYPE usmd_t_message,
ls_msg TYPE usmd_s_message,
lt_erp_v TYPE REF TO data.

FIELD-SYMBOLS:
<lt_erpv> TYPE SORTED TABLE,
<ls_erpv> TYPE any,
<lv_erpv> 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_crequest_type
ev_process = lv_process.

lv_crequest_type = iv_crequest_type.

CALL METHOD super->if_mdg_bs_bp_access_handler~get_entity_properties
EXPORTING
iv_entity = iv_entity
is_key = is_key
io_model = io_model
iv_crequest_type = iv_crequest_type
iv_crequest_step = iv_crequest_step
iv_crequest_index = iv_crequest_index
CHANGING
cf_read_only = cf_read_only.

IF iv_crequest_type EQ ‘ZMDGS03’.
io_model->read_entity_data_all(
EXPORTING
i_fieldname = ‘BP_HEADER’
if_active = abap_false
i_crequest = lv_cr_number
IMPORTING
et_message = lt_msg
et_data_entity = lt_data
).

lt_erp_v = VALUE #(
lt_data[ usmd_entity = ‘BP_HEADER’
usmd_entity_cont = ‘BP_VENGEN’
struct = ‘KATTR’ ]-r_t_data OPTIONAL ).

IF lt_erp_v IS NOT INITIAL.
IF iv_entity EQ ‘BP_VENGEN’.
cf_read_only = ‘X’.
ENDIF.
ENDIF.
ENDIF.

ENDIF.SAP S/4HANA   SAP Master Data Governance   ABAP Development  Thank You, Sandeep Suggu.SAP Community Profile | SAP Profile | LinkedIn      Read More Technology Blog Posts by Members articles 

#SAP

#SAPTechnologyblog

You May Also Like

More From Author