Skip to Content
author's profile photo
Former Member

ME21N, BADI ME_PROCESS_PO_CUST, compare delivery address in each line item

Hello all,

When creating or changing purchase orders using the enjoy transactions ME21N and ME22N, I want to force the users to have the same delivery address on every line item. I have found and activated the BADI ME_PROCESS_PO_CUST. I have added some code in method CHECK and put a breakpoint on that code. The transaction is stopping on my breakpoint. So far so good.

Now for my question, how do I access all of the delivery address fields for each of the line items to ensure that they are the same? Since the actual delivery address fields are stored in table ADRC using ADDRNUMBER, it seems like this is the field that I should be comparing for all the line items.

Method CHECK has attribute IM_HEADER. From that method, using that attribute, how do I programmatically get to the delivery address fields (or ADDRNUMBER) for all the line items?

Thanks

Bruce

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • Best Answer
    author's profile photo
    Former Member
    Posted on Jan 30, 2007 at 10:45 PM

    Hi Bruce,

    You can use exit EXIT_SAPMM06E_012 and loop on table TEKPO and check for field ADRN2 - This has the delivery address number. You can then either compare the ADRN2 or check against ADRC to match address line 1, line2 , city , state , etc...as per your requirement.

    Thanks

    Anirban

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Jan 31, 2007 at 03:37 AM

    Hello Bruce

    Assuming that field MEPOITEM-ADRNR is the one you want to check for then here is a possible solution:

    METHOD if_ex_me_process_po_cust~check.
    * define local data
      DATA:
        lt_items      TYPE purchase_order_items,
        ls_item       TYPE purchase_order_item,
    *
        ls_header     TYPE mepoheader,
        ls_detail     TYPE mepoitem,
        lt_details    TYPE tab_mepoitem.
    
    
    
    * Get the order items
      lt_items = im_header->get_items( ).
    
      REFRESH: lt_details.
      LOOP AT lt_items INTO ls_item.
        ls_detail = ls_item-item->get_data( ).
        APPEND ls_detail TO lt_details.
      ENDLOOP.
    
      READ TABLE lt_details INTO ls_detail INDEX 1. " read 1st entry
    * Check for single entry with different address number
      LOOP AT lt_details TRANSPORTING NO FIELDS
              WHERE ( adrnr NE ls_detail-adrnr ).
        EXIT.
      ENDLOOP.
      IF ( syst-subrc = 0 ).
        MESSAGE 'Error: Items do no have same delivery address' TYPE 'E'.
    
        ch_failed = 'X'.
      ENDIF.
    
    
    ENDMETHOD.

    If you use the CHECK function in ME21N then you will see the error message there.

    Regards

    Uwe

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Jan 31, 2007 at 07:02 PM

    Anirban / Uwe,

    Both of your suggestions would work if the address always contains the system assigned address. In our case we allow the users to override the system supplied address with an ad hoc address. The address that they enter on the screen, overlaying the system default address, does not create an address number until the PO is actually committed to the database. At the point where this method is called the address number is blank for any addresses that are manually entered by the user.

    Thanks

    Bruce

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      I finally am getting back to this thread.

      I wasn't able to validate the delivery address is before the purchase order actually posted. Instead I created an implementation of the BADI definition ME_PURCHDOC_POSTED, comparing delivery addresses after the document had posted. At that point if there were any differences sent an e-mail.

      Thanks

      Bruce

  • author's profile photo
    Former Member
    Posted on Aug 21, 2007 at 09:42 PM

    Hello Bruce

    Perhaps the discussion between Peter Müller and me in thread

    may be useful to you.

    Regards

    Uwe

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Uwe,

      <b>szadr_addr1_complete</b> does not exist in our version 4.7. You must be using Netweaver. Is <b>szadr_addr1_complete</b> small enough in scope that it might make sense to create a customer version of this at my site? We won't be on Netweaver for at least 2 years.

      Thanks

      Bruce