cancel
Showing results for 
Search instead for 
Did you mean: 

Automatically populate Material Long text in SAP MDG-M

Former Member
0 Kudos

Hi Gurus,

Can you please help me with the logic to automatically populate Material Long text in SAP MDG-M? I am able to auto populate material short text using some characterics values. I need the logic for Material long text.

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_bscdattxt

          i_struct   
= if_usmd_gov_api_entity=>gc_struct_key_txt "gc_struct_key_txt_langu

          i_tabtype  
= if_usmd_model_ext=>gc_tabtype_standard

       
IMPORTING

          er_data    
= lrt_entity_data.

      
ASSIGN lrt_entity_data->* TO <lt_description1>.

In <lt_description1> I am not getting NOTEBSCDA field. So I am not able to populate the value for this field with long text.

I am using below coe to write data but it is not working.



     
CALL METHOD io_write_data->write_data

       
EXPORTING

          i_entity    
= if_mdg_bs_mat_gen_c=>gc_entity_bscdattxt

          it_key      
= lt_key

          it_attribute
= lt_attribute1

          it_data     
= <lt_description1>.

Please help me with the proper code. Quick response will be appreciated.

Accepted Solutions (1)

Accepted Solutions (1)

d024348
Employee
Employee
0 Kudos

Hi, try using GC_STRUCT_KEY_ATTR instead of gc_struct_key_txt

Regards, Ingo Bruß

Former Member
0 Kudos

Thanks Ingo, it really worked. Thanks a lot again! You rock Man!

Arnab.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Arnab,

can you please help me how to implement the BADI to read the characteristics name and characteristics values and then populate that to material long text in SAP MDG - M.

Former Member
0 Kudos

Hi Giridhar,

Go to SE18 and input the BAdi 'USMD_RULE_SERVICE'. You'll get 2 BAdis inside. 'USMD_RULE_SERVICE_CROSS_ET' has an example implementation 'MDG_BS_MAT_CLF2DESCRIPTION'. Copy that when you are creating your custom implementation. You can get the idea on how short text is populated.

Use below code to update long text:

***--Update Long Text

        CALL METHOD io_model->create_data_reference

          EXPORTING

            i_fieldname = if_mdg_bs_mat_gen_c=>gc_fieldname_bscdattxt

            i_struct    = if_usmd_gov_api_entity=>gc_struct_key_attr

            i_tabtype   = if_usmd_model_ext=>gc_tabtype_standard

          IMPORTING

            er_data     = lrt_entity_data.

        ASSIGN lrt_entity_data->* TO <lt_description1>.

***--Insert description in logon language

        INSERT INITIAL LINE INTO TABLE <lt_description1> ASSIGNING <ls_description1>.

        ls_description1-material = <lv_matnr>.

        ls_description1-langucode = sy-langu.

         CONCATENATE lv_class_desc lc_semicolon INTO ls_description1-notebscda.

 

        MOVE-CORRESPONDING ls_description1 TO <ls_description1>.

        CREATE DATA lr_descr_struc1 LIKE LINE OF <lt_description1>.

        lo_structdescr1 ?= cl_abap_structdescr=>describe_by_data_ref( p_data_ref = lr_descr_struc1 ).

        LOOP AT lo_structdescr1->components ASSIGNING <lf_component1>.

          INSERT <lf_component1>-name INTO TABLE lt_attribute1.

        ENDLOOP.

        CALL METHOD io_write_data->write_data

          EXPORTING

            i_entity     = if_mdg_bs_mat_gen_c=>gc_entity_bscdattxt

            it_key       = lt_key

            it_attribute = lt_attribute1

            it_data      = <lt_description1>.

Hope this will resolve your query.

Former Member
0 Kudos

Thanks Arnab

when i copy the badi implemented i am getting error Assert condition violated error in UI. can you please tell me how to resolve below error.

Former Member
0 Kudos

Hi Giridhar,

Please debug the code or take help from an ABAP er. There might be some code that is setting sy-subrc NE 0 and ASSERT command is there in the code. Can't confirm without debugging.

Thanks,

Arnab.