Skip to Content

Change header note ME21N depending on content of Account Assignment tab

Hi experts,

I have a requirement to change the header note in ME21N when saving the PO, the header note must be set to the value of a text from a Z-table that stores the PEP element along with its description. The note text must be set following these requirements only if the Account Assignment type is a PROJECT, the screen shot under explains what I mean.

I have read that I have to use the FM READ_TEXT and SET_TEXT and also that I have to use Badi, specifically tha Badi ME_PROCESS_PO_CUST. I am new to badis and I need to know what method of ME_PROCESS_PO_CUST would help me to get access to the data in Account Assignment so that I could get the PEP element to get the description from the Z-table, and then set the header note with that description, is this right? What are the steps to follow?

Any help would be much appreciated.

me21n.png (61.0 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Mar 27, 2017 at 10:07 AM

    Look at PO classic BAdI : ME_PROCESS_PO_CUST

    In a method like PROCESS_ACCOUNT (and PROCES_ITEM if required) you can detect changes to the 'PEP' field (using methods like GET_DATA, GET_PREVIOUS_DATA and even GET_PERSISTENT_DATA in case of ME22N) from the IM_ACCOUNT parameter you can get a reference to item with method GET_ITEM and from this one a reference to header wirth method GET_HEADER.

    values_of_accounting = im_account->get_data( ).
    previous_values_of_accounting = im_account->get_previous_data( ).
    ref_to_item = im_account->get_item( ).
    values_of_item = ref_to_item->get_data( ).
    ref_to_header = ref_toitem->get_header( ).
    values_of_header = ref_header->get_data( ).

    With the header reference you can read and change its long texts with methods of interface IF_LONGTEXTS_MM (GET_TEXT and SET_TEXT)

    But It would be easier to use some text at item level, as you will have to manage change of an item accounting information that was already inserted in header text, find/replace or remove in PO header text. (Or adapt the form used to print/mail the PO) Also what do you code if user 'inadvertently' erase/overwrite the text?

    You could also consider updating the long text once just before the save (in method CHECK) with a loop on items and then on accounting informations.

      list_of_items = im_header->get_items( ).
      loop at list_of_items assigning <item>.
        values_of_item = <item>-item->get_data( ).
        list_of_accountings = <item>-item->get_accountings( ).
        loop at list_of_accountings assigning <accounting>.
          values_of_accounting = <accounting>-accounting->get_data( ).
    Add comment
    10|10000 characters needed characters exceeded

  • Mar 24, 2017 at 10:20 AM

    Your idea could only work in a very restrictive environment, which means you would also need to restrict users to add a second item to a purchase order as this could lead to different header notes while there is just one field available. (why not using item notes?)

    Also you would need to consider what you do with a note that was entered manually by a user.

    Coding questions have to be asked with the tag "ABAP Development" . Long text is a very frequently discussed topic, make sure you searched before asking and make your question be different than any other.

    Add comment
    10|10000 characters needed characters exceeded

    • Well, If think the steps I need to take are:

      1. loop at the items.
      2. for each item get the pep element from the Assignment Account data
      3. get the description of the pep element from the Z-table
      4. append the pep and the description into the note header

      I just need a help on where to start to implement it.

      I am new to ABAP so I am far from 'good ABAPers' that's why I am seeking help here.