cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

MDG BP_CENTRAL data from buffer

flvia_s
Participant
0 Kudos
2,378

Dear experts,

While execution NWBC tcode, I am trying to read the fields BU_TYPE and BU_GROUP from the buffer in the MDG System, but they keep comming empty. This is what I am currently doing in the code:

CONSTANTS: lc_bp_central TYPE USMD_ENTITY VALUE 'BP_CENTRL'.


data(lr_delta_buffer) = cl_usmd_delta_buffer=>get_instance( ).

lr_delta_buffer->read_data( EXPORTING i_entity = lc_bp_central i_struct = if_usmd_model_ext=>gc_struct_key_attr
IMPORTING er_t_data_ins = data(lr_t_ins_bp_ctrl)
er_t_data_upd = data(lr_t_upd_bp_ctrl)
er_t_data_del = data(lr_t_del_bp_ctrl)
er_t_data_mod = data(lr_t_mod_bp_ctrl)
er_t_data_old = data(lr_t_old_bp_ctrl) ).

Am I too far from the correct answer? 😉

Thank you in advance!

Alm

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks for the reply. The 'USMD_RULE_SERVICE' BADI triggers only when there is a change in data during a roundtrip. In your specific case, even if it gets called during creation of BP, it would always be blank. During change of a BP, however you would see it getting filled.

bpawanchand
Active Contributor
0 Kudos

Hi Silva,

There are other ways to fetch the data of the change request but one of the simple way to fecth the current data within the change request would be

cl_usmd_gov_api=>get_instance(
  EXPORTING
    iv_model_name =   'BP'                " Data Model
  RECEIVING
    ro_gov_api    =  DATA(lr_gov_api)                 " Governance API
).

lr_gov_api->if_usmd_gov_api_cr_data~get_crequest_data(
  EXPORTING
    iv_crequest_id          = iv_cr                 " Change Request
  IMPORTING
    et_entity_data_inactive =  data(lt_cr_data)                " Data for Entity Types
).

data(ls_bupa) = lt_cr_data[ usmd_entity = 'BP_HEADER' STRUCT = 'KATTR' usmd_entity_cont = ' '].  " Data must be in ls_bupa

Regards

Pavan

flvia_s
Participant
0 Kudos

Dear Pavan,

I tried implemmenting your solution, but I cannot use this API in my BADI, I am receiving a short dump.
In the code, there is a comment from SAP why it does not allow me to get the instance cl_usmd_gov_api=>get_instance:


* programming error: gov api must not be instanciated after / used from outside convenience api"
ASSERT cl_usmd_conv_som_gov_api=>check_instance_exists( iv_model_name ) = abap_false.

Thank you very much for your inputs!
BR,
Alm

bpawanchand
Active Contributor
0 Kudos

Yes you are correct , you cannot instantiate the GOV api again in this badi implementation.But if you keenly observe there is already an instance of CL_USMD_MODEL_EXT which will be the part of signature where you also have access to the methods to read entity data BP_HEADER of structure type KATTR .

Former Member
0 Kudos

The NWBC tcode is to launch all the MDG roles you have which in turn launches all the MDG access like Material, Customer, Supplier, Business Partner and FI views. Can you please share what exact steps are you performing and what is the exact use-case?

flvia_s
Participant
0 Kudos

Dear Partha,

Thank you very much for your message.
In this case we are creating a new Organization BP, trying to read the data through BADI USMD_RULE_SERVICE.

BR,
Alm