on 07-07-2015 8:22 AM
Hi Gurus,
The requirement is to set the Plant as default in the MDG-M UI screen. I have tried to add the default plant in the BADi 'USMD_RULE_SERVICE', Interface 'IF_EX_USMD_RULE_SERVICE~DERIVE_ENTITY'.
CASE id_entitytype.
WHEN 'MARCATP'. "#EC NOTEXT
IF lines( ct_data ) EQ 1.
ASSIGN ct_data TO <lt_data>.
LOOP AT <lt_data> ASSIGNING <ls_data>.
IF <ls_data> IS ASSIGNED.
ASSIGN COMPONENT 'WERKS' OF STRUCTURE <ls_data> TO <lv_werks>.
IF <lv_werks> IS ASSIGNED AND <lv_werks> IS INITIAL.
GET PARAMETER ID 'RWK' FIELD lv_ref_werks.
<lv_werks> = lv_ref_werks.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDCASE.
The problem is Entity type 'MARCATP' is not getting triggered while the first time Create Material screen appreas. Hence my code is not working.
Can you please help?
Hello Arnab,
This can still be achieved by cross entity BAdI. I did this using the below code:
lv_entity = <Entity>
* Get the material number from read data
io_changed_data->read_data(
EXPORTING
i_entity = lv_entity " Entity Type
IMPORTING
er_t_data_ins = DATA(lr_ins_data) " newly added data records
er_t_data_upd = DATA(lr_upd_data) " data records changed
).
ASSIGN lr_ins_data->* TO <lt_ins_mat_data>.
CHECK <lt_ins_mat_data> IS ASSIGNED and <lt_ins_mat_data> IS INITIAL.
* You might have to add extra condition to make sure you are inserting it only for the first time, check could be, say having insert data for material itself. -> because that happens only when you launch.
lv_fieldname = <entity>.
io_model->create_data_reference(
EXPORTING
i_fieldname = lv_fieldname
i_struct = if_usmd_gov_api_entity=>gc_struct_key_attr
i_tabtype = if_usmd_model_ext=>gc_tabtype_standard
IMPORTING
er_data = DATA(lr_data_tab)
).
ASSIGN lr_data_tab->* TO <lt_new_marc>.
* Insert the data into the new <lt_new_marc> table
* Write derived plant data to the material being created.
io_write_data->write_data(
EXPORTING
i_entity = if_mdg_bs_mat_gen_c=>gc_entity_marcbasic
it_data = <lt_new_marc>
).
But yes, you can achieve your use case by normal rule service BAdI as well.
Best Regards,
Avinash Bolisetty
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Arnab,
Firstly, if you are trying to add data of plant, based on data of another entity plant data ATP, this is not the BAdI that we have to use.
Correct solution, as someone already suggested is to use this cross entity BAdI. We get a better control there. Even if the entity you are looking for isn't getting filled in the first run of check cycle, you get insert data, update -> old and new and delete data wrt to each entity in every run of check cycle. Then, just use something like the below code to add whatever entity data you need to add.
io_write_data->write_data(
EXPORTING
i_entity = if_mdg_bs_mat_gen_c=>gc_entity_mardstor
it_data = <lt_new_mard_stor>
).
This should definitely address the use case.
In case there's some specific use case because of which you still want to stick to rule service BAdI itself, then we can start with checking
1. if the derivations are set to active for this CR type and CR step.
2. If active at CR Type and CR step level, make sure they are not disabled for the entity in question.
3. Also, rule service isn't a multiple use BAdI. Check if that is having any impact.
and finally, if nothing else is working, you can start with debugging from cl_usmd_conv_som_gov_api->check method and see why your BAdI alone isn't getting triggered.
Hope this helps.
Best Regards,
Avinash Bolisetty
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Avinash,
Thanks for your detailed response. My requirement is not to populate Plant based on some value. The requirement is to default Plant to some value so that User can see a default plant when he first open the Create Material screen in MDG. As BRF+ derivation is not working for Plant (it is working for Material Basic data like Base Unit of Measure) I need the BAdi to pre populate the value into the UI.
Rule service BAdi is definitely getting triggered for me, but I don't have the appropriate entity to populate Plant in the first place.
Hope the requirement is clear now. Appreciate your further input.
try this badi USMD_RULE_SERVICE_CROSS_ET
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.