cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the latest text value? (MDG BAdI USMD_RULE_SERVICE_CROSS_ET)

queue
Explorer
0 Kudos

Dear experts,

Can you please help me with the logic to get the latest value which the user input to text(lang+text) fields?

I am using
BAdI USMD_RULE_SERVICE_CROSS_ET
Method IF_EX_USMD_RULE_SERVICE2~DERIVE.

Code:

CALL METHOD io_model->create_data_reference
EXPORTING
i_fieldname = if_mdg_bs_mat_gen_c=>gc_fieldname_material
i_struct = if_usmd_gov_api_entity=>gc_struct_key_txt_langu
i_tabtype = if_usmd_model_ext=>gc_tabtype_standard
IMPORTING
er_data = lrt_desc_data.

ASSIGN lrt_desc_data->* TO <lt_description>.

CREATE DATA lrs_desc LIKE LINE OF <lt_description>.

IF lrs_desc IS INITIAL.
RETURN.
ENDIF.

ASSIGN lrs_desc->* TO FIELD-SYMBOL(<ls_description>).

io_model->read_char_value(
EXPORTING
i_fieldname = if_mdg_bs_mat_gen_c=>gc_fieldname_material
it_sel = lt_sel
if_no_flush = abap_false

IMPORTING
et_data = <lt_description>
et_message = lt_message ).

As a result, I could get the value which is "BEFORE the latest input".

For example, when a user change text from "AA" to "ABC", I could get "AA" as a text value in stead of "ABC".
Could you please advise me how to get the latest text values?

Thank you
Yuko

View Entire Topic
studencp
Participant

Hi,

you have the values in the parameter IO_CHANGED_DATA of the method, you are trying to read them from IO_MODEL and there the values are passed after the BAdI is triggered.

In this BAdI if you need "fresh data", first read it from IO_CHANGED_DATA and if it is not there (means it was not changed since last flush) then get it from IO_MODEL

queue
Explorer
0 Kudos

Hi pstudenc,

I really appreciate your prompt answer.
I changed source code as follows;

io_changed_data->read_data(
Exporting
i_entity = if_mdg_bs_mat_gen_c=>gc_entity_material
i_struct = if_usmd_gov_api_entity=>gc_struct_key_txt_langu
Importing
er_t_data_mod = lrt_description).

Then it works as I expected!!

Thank you 🙂
Yuko