2 Replies Latest reply: Feb 29, 2012 2:51 PM by Jörg Sauterleute RSS

BADI IF_EX_ME_PROCESS_PO_CUST, field MEPO1331-ABLAD

Jörg Sauterleute
Currently Being Moderated

Hi BADI friends,

 

I'd lke to change field ABLAD via BADI in purchase order view "shipping".

1) i like to "read" the field ( -> get_shipping_data( )  )

2) i like to "change" if necessary ( -> set_shipping_data ( )   )

 

The problem is that i'm not keen enough in using methods and i don't know how to add structure MEPO1331 in my existing source code ... So if someone could help me in correct declaring / using ls_mepo1331 ...?

 

Existing code (+ not working attempts - ??? -):

 

METHOD if_ex_me_process_po_cust~process_item .
* Business-Add-Inn ME_PROCESS_PO_CUST
* Jörg Sauterleute - 23.12.2005
*
* ----------------------------------------------

  DATA: ls_mepoitem TYPE mepoitem,             "OK
        ls_mepoheader TYPE mepoheader,             "OK
        ls_mepoaccounting TYPE mepoaccounting.     "OK

* ??? DATA: ls_mepo1331 TYPE mepo1331.             " need help --- Shipping data
  ---

* Interfacereferenz auf <if_purchase_order_mm>
  DATA: header_obj TYPE REF TO if_purchase_order_mm.
* Interfacereferenz auf <if_purchase_order_account_mm> über Tabelle
  DATA: it_accountings TYPE purchase_order_accountings, "Tabelle
        accounting_obj TYPE purchase_order_accounting.


* ???  DATA: it_mepo1331 TYPE REF TO (?)if_purchase_order_item_mm.   "need help 
  ---

  INCLUDE mm_messages_mac.
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* 1. Datenbeschaffung
* ######################################################################

* Kopfdaten
  header_obj = im_item->get_header( ).
  ls_mepoheader = header_obj->get_data( ).

* Positionsdaten
  ls_mepoitem = im_item->get_data( ).

* Versanddaten (Position)                                                 "need help 
* ???  call method it_mepo1331->get_shipping_data( ).
* ??? OR
* ??? ls_mepo1331 = im_item->get_shipping_data( ).
  ---


* Kontierungsdaten (Accounting) über Tabelle it_accountings
  it_accountings = im_item->get_accountings( ).
* ...IF eingebaut, weil sonst später Abbruch, wenn sy-subrc <> 0
  IF NOT ls_mepoitem-knttp IS INITIAL.
    LOOP AT it_accountings INTO accounting_obj.
      ls_mepoaccounting = accounting_obj-accounting->get_data( ).
    ENDLOOP.
  ENDIF.

 

 

Please check lines with "need help

Here i need hints/correct code, to get the shipping data.

 

kind regards

Jörg

 

  • Re: BADI IF_EX_ME_PROCESS_PO_CUST, field MEPO1331-ABLAD
    Martin Voros
    Currently Being Moderated

    Hi,

     

    the method get_shipping_data returns structure with type EKPV. How did you get the structure mepo1331. The code to  get shipping data is pretty simple

     

    DATA ls_sdata TYPE ekpv.
    
    ls_sdate = im_item->get_shipping_data( ).

     

    Cheers

    • Re: BADI IF_EX_ME_PROCESS_PO_CUST, field MEPO1331-ABLAD
      Jörg Sauterleute
      Currently Being Moderated

      great this works... thanks a lot Martin.

      Why i tried MEPO1331 ? ... checking technical info in ME23n (F1) this structure is shown.

       

      regards Jörg

       

      P.S. below the finished code (if s.o. needs an example)

       

      METHOD if_ex_me_process_po_cust~process_item .
      * Business-Add-Inn ME_PROCESS_PO_CUST
      * Jörg Sauterleute - 23.12.2005
      *
      * ----------------------------------------------
        DATA: ls_mepoitem TYPE mepoitem.     
        DATA: ls_ekpv TYPE ekpv.             "Position Versanddaten  
        DATA: ls_mepoheader TYPE mepoheader,
              ls_mepoaccounting TYPE mepoaccounting.
      *
      * Interfacereferenz auf <if_purchase_order_mm>
        DATA: header_obj TYPE REF TO if_purchase_order_mm.
      * Interfacereferenz auf <if_purchase_order_account_mm> über Tabelle
        DATA: it_accountings TYPE purchase_order_accountings, 
              accounting_obj TYPE purchase_order_accounting.
      *
      * Include für Ausgabe von Meldungen
      * im BAdI ME_PROCESS_PO_CUST niemals ABAP-Statement MESSAGE verwenden!
        INCLUDE mm_messages_mac.
      *_______________________________________________________________________ 
      * Kopfdaten
        header_obj = im_item->get_header( ).
        ls_mepoheader = header_obj->get_data( ).
      *
      * Positionsdaten
        ls_mepoitem = im_item->get_data( ).
      * Versanddaten Position lesen
        ls_ekpv = im_item->get_shipping_data( ).          " solution
      
      * Kontierungsdaten (Accounting) über Tabelle it_accountings
        it_accountings = im_item->get_accountings( ).
      * ...IF eingebaut, weil sonst später Abbruch, wenn sy-subrc <> 0
        IF NOT ls_mepoitem-knttp IS INITIAL.
          LOOP AT it_accountings INTO accounting_obj.
            ls_mepoaccounting = accounting_obj-accounting->get_data( ).
          ENDLOOP.
        ENDIF.

      ...

          IF ls_mepoheader-reswk = '1600' AND ls_mepoheader-ekorg = '1000' AND NOT ls_mepoitem-matnr IS INITIAL.
                ls_ekpv-ablad = 'Buxheim'.       " ABLAD füllen
                h_change_mepoitem = 'V'.
                h_text = text-037.
          ENDIF.

      ...

         CASE h_change_mepoitem.
            WHEN 'V'.                 
              im_item->set_shipping_data( EXPORTING im_ekpv = ls_ekpv ).  "Versanddaten 
          ENDCASE.
      * Meldungen füllen / ausgeben.
          IF NOT h_text IS INITIAL. mmpur_message_forced 'I' 'ME' '303' h_text '' '' ''. ENDIF.
      
          CLEAR: h_change_mepoitem, h_text.
      
      ENDMETHOD.                    

       

      Edited by: Jörg Sauterleute on Feb 23, 2010 5:24 PM

       

  • Re: BADI IF_EX_ME_PROCESS_PO_CUST, field MEPO1331-ABLAD
    Subhradip Bhadra
    Currently Being Moderated

    Hi,

     

    I am facing same issue while trying to update MEPO1331-ROUTE field. I did the same as mentioned in thread and using same badi and set_shipping_data method to update Route field. But when PO is create Shipment tab is missing due to that changes..

    If in your case it was resolved.....Could you please let me know how did you achieve it and any other changes require or not.

     

    Thanks

    Subhradip

Actions