Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BADI ME_PROCESS_PO_CUST~POST how to read Item service data

former_member182379
Contributor
0 Likes
10,812

Hi,

  In the Service Purchase order, I want to add some validation on the basis of service item, this is working fine at method PROCESS_ITEM

as I am able to read the service data as per below code

    lr_po_item_handle ?= im_item.

     CALL METHOD lr_po_item_handle->get_data

       IMPORTING

         ex_data = ls_mepoitem

       EXCEPTIONS

         failure = 1

         OTHERS  = 2.

     if ls_mepoitem-PSTYP = '9' and

        ls_mepoitem-BANFN is NOT INITIAL and

        ls_mepoitem-bnfpo is NOT INITIAL.

     CALL METHOD lr_po_item_handle->if_services_mm~get_srv_data

       EXPORTING

         im_packno = ls_mepoitem-packno

       IMPORTING

         ex_esll   = lt_esll

     "  ex_esuh   =

      " ex_esuc   =

       "ex_eskl   =

       EXCEPTIONS

         failure   = 1

         OTHERS    = 2.

       delete lt_esll where pln_packno is INITIAL.

but this get triggered when press enter, but if we click directly on 'SAVE' button after changing the quantity at service level,

method 'PROCESS_ITEM'  does not getting trigger

so same logic I want to add in POST method, in this I am able to read the line items details as per below logic.


     lr_po_header_handle ?= im_header.

     CALL METHOD lr_po_header_handle->if_purchase_order_mm~get_items

       RECEIVING

         re_items = lt_po_items.   " Table with PO Items

      loop at lt_po_items into ls_po_items.

        clear : ls_mepoitem.

        ls_mepoitem = ls_po_items-item->get_data( ).

        append ls_mepoitem to lt_mepoitem.

       endloop.

NOW in lt_mepoitem I am getting all the line item details,

How to read the service data from here?

regards,

zafar

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
4,625

Don't use method POST but use CHECK (read BAdI documentation)


lt_items = im_header->get_items( ).

LOOP AT lt_items INTO ls_items.

  " same code than PROCESS_ITEM

  lr_item_handle ?= ls_items-item.

  " etc.

ENDLOOP.

Regards,

Raymond

4 REPLIES 4
Read only

jhilden
Explorer
0 Likes
4,625

Here is a snippet of what I have in that method:

* for item data

   DATA: zcl_po        TYPE REF TO cl_po_header_handle_mm.

   DATA: lt_mepoitem   TYPE STANDARD TABLE OF mepoitem.

   DATA: ls_mepoitem   TYPE mepoitem.

   DATA: ls_items       TYPE purchase_order_item.

   DATA : lt_items      TYPE purchase_order_items.

*--------------------------------------------------**

* Extract PO Item Information **

*--------------------------------------------------**

     REFRESH : lt_items.

     lt_items = zcl_po->if_purchase_order_mm~get_items( ).

     IF NOT lt_items IS INITIAL.

       LOOP AT lt_items INTO ls_items.

         ls_mepoitem = ls_items-item->get_data( ).

         APPEND ls_mepoitem TO lt_mepoitem.

         CLEAR ls_mepoitem.

       ENDLOOP.



<<CALL a custom function with the lt_mepoitem table >>



ENDIF.

   ENDIF.


Hope it helps.

Jeremy

Read only

SimoneMilesi
Active Contributor
0 Likes
4,625

First of all, attention placing code in POST method!

If you are planning to do some change /messages/checks, better implement method CHECK, triggered just before method POST.

Coming to your question, you work exactly in the same way


LOOP AT lt_po_items INTO ls_po_items.

   CLEAR : ls_mepoitem.

   ls_mepoitem = ls_po_items-item->get_data( ).

   IF ls_mepoitem-pstyp = '9' AND

       ls_mepoitem-banfn IS NOT INITIAL AND

       ls_mepoitem-bnfpo IS NOT INITIAL.

     CALL METHOD ls_po_items-item->if_services_mm~get_srv_data

       EXPORTING

         im_packno = ls_mepoitem-packno

       IMPORTING

         ex_esll   = lt_esll

            "  ex_esuh   =

             " ex_esuc   =

              "ex_eskl   =

       EXCEPTIONS

         failure   = 1.

ENDLOOP.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
4,626

Don't use method POST but use CHECK (read BAdI documentation)


lt_items = im_header->get_items( ).

LOOP AT lt_items INTO ls_items.

  " same code than PROCESS_ITEM

  lr_item_handle ?= ls_items-item.

  " etc.

ENDLOOP.

Regards,

Raymond

Read only

0 Likes
4,625

Thanks all for your reply, the issue solve I have done it as per reply from Raymond.

lt_items = im_header->get_items( ).

LOOP AT lt_items INTO ls_items.

  " same code than PROCESS_ITEM

  lr_item_handle ?= ls_items-item.

  " etc.

ENDLOOP.



Regards,

Zafar