Skip to Content

Fill Cost Center Medium text automatically using BADI

Hi All,

I'm trying to fill the Cost Center Medium Text (TXTMI) automatically based on the short text entered.

I'm using method IF_EX_USMD_RULE_SERVICE2~DERIVE for entity CCTR.

I noticed that method io_write_data->write_data will change the medium text ONLY when that field was already populated.

BUT if the medium text is blank and I want to fill it...then it does nothing!

Do you know how can I solve this?

Thanks in advance!


Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on Aug 21, 2016 at 10:32 AM

    Hi Matias,

    The best way to update the medium text based on the short text is in the method IF_EX_USMD_RULE_SERVICE2~DERIVE of the BAdI: Derivations Across Entity Types

    You can do this by create a BAdI implementation for the the BAdI definition USMD_RULE_SERVICE_CROSS_ET

    Code snippet:

    CALL METHOD io_changed_data->get_entity_types


    et_entity = lt_entity.

    CLEAR ls_entity.

    READ TABLE lt_entity INTO ls_entity INDEX 1.

    IF sy-subrc EQ 0.

    l_entity = ls_entity.

    lv_field = l_entity.




    i_fieldname = lv_field

    i_struct = if_usmd_model=>gc_struct_key_txt_langu

    if_table = 'X'

    i_tabtype = if_usmd_model=>gc_tabtype_standard


    er_data = lr_text_transl_table ).



    i_entity = l_entity " Entity Type

    i_struct = if_usmd_model=>gc_struct_key_txt_langu " Type of Data Structure


    er_t_data_mod = lr_text_transl_table " "Modified" Data Records


    ASSIGN lr_text_transl_table->* TO <lt_data_mod>.

    LOOP AT <lt_data_mod> ASSIGNING <ls_data_ins>.

    ASSIGN COMPONENT 'TXTMI' OF STRUCTURE <ls_data_ins> TO <ls_mod> .

    IF sy-subrc IS INITIAL.

    *Check =medium text maintained by user

    IF <ls_mod> IS NOT INITIAL.



    ASSIGN COMPONENT 'TXTSH' OF STRUCTURE <ls_data_ins> TO <ls_mod_ins> .

    IF sy-subrc IS INITIAL.

    <ls_mod> = <ls_mod_ins>.

    lv_update = abap_true.





    IF lv_update IS NOT INITIAL.

    *Update the data back to context

    CALL METHOD io_write_data->write_data


    i_entity = l_entity

    it_data = <lt_data_mod>.


    Below is the MDGIMG node from where you can proceed to create a BAdI Implementation for derivation across entity types.

    Best Regards

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Matias,

      That is interesting. For me it works when I follow below steps:

      1. User opens Single Processing for Cost Center.

      2. User enters the shot description in the tab Object Description

      3. User clicks on Basic Data tab

      4. User enters the mandatory fields - This is optional step (that is, does not affect the derivation)

      5. Click on Check button

      After step 5 if you navigate to the Object Description you will see the medium description populated (derived) with the same value as short description.



  • Posted on Aug 22, 2016 at 08:19 AM

    Hi Matias,

    Could you share the screen shot of CR .



    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.