Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Need to get items of purchase order, in POO

Hi all,

i need to get items of a purchase order, i use class CL_PO_HEADER_HANDLE_MM, i execute the method GET_ITEMS but the result is empty. I don't understand how this class work.

Thanks for your help.

replied

Hello

The sample report ZUS_SDN_PO_HEADER_HANDLE_MM demonstrates how to use class CL_PO_HEADER_HANDLE_MM (and IF_PURCHASE_ORDER_MM).

*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_PO_HEADER_HANDLE_MM
*&
*&---------------------------------------------------------------------*
*& Report demonstrate the usage of class CL_PO_HEADER_HANDLE_MM
*&---------------------------------------------------------------------*
*& Thread: Need to get items of purchase order, in POO
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1064610"></a>
*&---------------------------------------------------------------------*

REPORT  zus_sdn_po_header_handle_mm.


DATA: go_po_header   TYPE REF TO cl_po_header_handle_mm,
      go_po_order    TYPE REF TO if_purchase_order_mm,
      gc_items       TYPE i.

DATA: gt_items       TYPE purchase_order_items,
      gs_item        TYPE purchase_order_item,
      gs_item_data   TYPE mepoitem,
      gt_item_data   TYPE STANDARD TABLE OF mepoitem.

DATA: go_table       TYPE REF TO cl_salv_table.

PARAMETERS:
  p_ebeln   TYPE ebeln  DEFAULT '3000000045'.

START-OF-SELECTION.

  CREATE OBJECT go_po_header
    EXPORTING
      im_po_number = p_ebeln
    EXCEPTIONS
      failure      = 1
      OTHERS       = 2.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


  " initialization
  CALL METHOD go_po_header->po_initialize
*    EXPORTING
*      im_document =
      .

  " Read purchase order
  CALL METHOD go_po_header->po_read
    EXPORTING
      im_tcode     = 'ME23N'
      im_trtyp     = 'A'
      im_aktyp     = 'A'
      im_po_number = p_ebeln
*      im_document  =
*    IMPORTING
*      ex_result    =
      .

  " Casting to purchase order
  go_po_order ?= go_po_header.





  gt_items = go_po_order->get_items( ).
  LOOP AT gt_items INTO gs_item.
    gs_item_data = gs_item-item->get_data( ).

    APPEND gs_item_data TO gt_item_data.
  ENDLOOP.


  TRY.
      CALL METHOD cl_salv_table=>factory
*    EXPORTING
*      list_display   = IF_SALV_C_BOOL_SAP=>FALSE
*      r_container    =
*      container_name =
        IMPORTING
          r_salv_table   = go_table
        CHANGING
          t_table        = gt_item_data.

      go_table->display( ).
    CATCH cx_salv_msg .
  ENDTRY.


END-OF-SELECTION.

Regards

Uwe

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question