New method GET_PO_DETAIL
Create a new method in the implementation class that will be called from the redefine method GET_OBJECT_DETAILS.
The purpose of this method is to define and encapsulate the logic that is required to retrieve the details for the Object (in this case Purchase Order). The object details will be transferred to OneList and will be visible to the user.
Method Parameters
Parameter Type | Parameter Name | Description | Data Type |
---|---|---|---|
Importing | I_PO_NUMBER | Purchase Order Number | EBELN |
Exporting | E_PO_DETAIL | Purchase Order Detail | /IQX/OL_PURCHASE_ORDER_ST |
Note
The data type of the export parameter should be defined upfront and will determine what information from the object will be retrieved and returned.
Method Implementation
The following ABAP code example can be added to retrieve the object (Purchase Order) details:
METHOD get_po_detail. DATA: lt_header_texts TYPE STANDARD TABLE OF bapiekkotx, lt_items TYPE STANDARD TABLE OF bapiekpo, lt_account_assignment TYPE STANDARD TABLE OF bapiekkn, lt_item_schedules TYPE STANDARD TABLE OF bapieket, lt_item_texts TYPE STANDARD TABLE OF bapiekpotx, lt_item_history TYPE STANDARD TABLE OF bapiekbe, lt_history_totals TYPE STANDARD TABLE OF bapiekbes, lt_item_services TYPE STANDARD TABLE OF bapiesll, lt_item_services1 TYPE STANDARD TABLE OF bapiesll, lt_item_limits TYPE STANDARD TABLE OF bapiesuh, lt_item_confirmations TYPE STANDARD TABLE OF bapiekes, lt_item_srv_accass_values TYPE STANDARD TABLE OF bapieskl, lt_item_contract_limits TYPE STANDARD TABLE OF bapiesuc, lt_services_texts TYPE STANDARD TABLE OF bapieslltx, lt_return TYPE STANDARD TABLE OF bapireturn, lt_search_filter TYPE STANDARD TABLE OF bapif4b, lt_toa01 TYPE STANDARD TABLE OF toa01. DATA: lw_item LIKE LINE OF lt_items, lw_account_assignment LIKE LINE OF lt_account_assignment, lw_item_history LIKE LINE OF lt_item_history, lw_history_totals LIKE LINE OF lt_history_totals, lw_item_texts LIKE LINE OF lt_item_texts, lw_item_services LIKE LINE OF lt_item_services, lw_item_services1 LIKE LINE OF lt_item_services, lw_item_schedules LIKE LINE OF lt_item_schedules, lw_header_texts LIKE LINE OF lt_header_texts. DATA: ls_return LIKE LINE OF lt_return, ls_item TYPE /iqx/ol_purchase_order_item_st, ls_account_assignment TYPE /iqx/ol_po_acct_assignment_st, ls_history_totals TYPE /iqx/ol_po_item_hist_totals_st, ls_item_texts TYPE /iqx/ol_po_item_texts_st, ls_item_services TYPE /iqx/ol_po_item_services_st, ls_item_schedules TYPE /iqx/ol_po_item_schedules_st, ls_item_history TYPE /iqx/ol_po_item_hist_st, ls_header_texts TYPE bapiekkotx, ls_search_filter LIKE LINE OF lt_search_filter, ls_toa01 LIKE LINE OF lt_toa01. DATA: ls_header TYPE bapiekkol, ls_address TYPE bapiaddress, ls_po_detail TYPE /iqx/ol_purchase_order_st. DATA: lv_object_key TYPE swotobjid-objkey, lv_code_value TYPE char30, lv_reset_possibility TYPE char3. DEFINE add_filter. CLEAR ls_search_filter. ls_search_filter-select_fld = &1. ls_search_filter-sign = 'I'. ls_search_filter-option = 'EQ'. ls_search_filter-low = &2. APPEND ls_search_filter TO lt_search_filter. END-OF-DEFINITION. CALL FUNCTION 'BAPI_PO_GETDETAIL' EXPORTING purchaseorder = i_po_number items = 'X' account_assignment = 'X' schedules = 'X' history = 'X' item_texts = 'X' header_texts = 'X' services = 'X' confirmations = 'X' service_texts = 'X' extensions = 'X' IMPORTING po_header = ls_header po_address = ls_address TABLES po_header_texts = lt_header_texts po_items = lt_items po_item_account_assignment = lt_account_assignment po_item_schedules = lt_item_schedules po_item_confirmations = lt_item_confirmations po_item_texts = lt_item_texts po_item_history = lt_item_history po_item_history_totals = lt_history_totals po_item_limits = lt_item_limits po_item_contract_limits = lt_item_contract_limits po_item_services = lt_item_services po_item_srv_accass_values = lt_item_srv_accass_values return = lt_return po_services_texts = lt_services_texts. READ TABLE lt_return INTO ls_return WITH KEY type = 'E'. IF sy-subrc NE 0. lt_item_services1[] = lt_item_services[]. "Fill header data MOVE-CORRESPONDING ls_header TO ls_po_detail. "Get current release code ls_po_detail-rel_code = me->get_po_rel_code( id_po_number = id_po_number ). "Get release code description IF ls_po_detail-rel_code IS NOT INITIAL. ls_po_detail-rel_cod_tx = me->get_rel_cod_desc( iv_rel_grp_code = ls_po_detail-rel_group iv_rel_code = ls_po_detail-rel_code ). ENDIF. "Get release group description IF ls_po_detail-rel_group IS NOT INITIAL. ls_po_detail-rel_grp_tx = me->get_rel_grp_desc( iv_rel_grp_code = ls_po_detail-rel_group ). ENDIF. "Get release strategy description IF ls_po_detail-rel_strat IS NOT INITIAL. ls_po_detail-rel_strat_tx = me->get_rel_strat_desc( iv_rel_grp_code = ls_po_detail-rel_group iv_rel_strat_code = ls_po_detail-rel_strat ). ENDIF. "Get release indicator description IF ls_po_detail-rel_ind IS NOT INITIAL. ls_po_detail-rel_ind_tx = me->get_rel_ind_desc( iv_rel_ind_code = ls_po_detail-rel_ind ). ENDIF. "Get release option description IF ls_po_detail-rel_ind IS NOT INITIAL. ls_po_detail-rel_option_tx = me->get_rel_option_desc( iv_rel_code = ls_po_detail-rel_code iv_rel_group = ls_po_detail-rel_group iv_rel_strategy = ls_po_detail-rel_strat ). ENDIF. "Check reset release possibility. IF ls_po_detail-rel_ind IS NOT INITIAL. ls_po_detail-reset_possibility = me->check_reset_possibility( iv_po_number = ls_po_detail-po_number iv_created_date = ls_po_detail-created_on ). ENDIF. "Get company code description IF ls_po_detail-co_code IS NOT INITIAL. lt_search_filter = me->get_sh_filter( ). add_filter 'BUKRS' ls_po_detail-co_code. lv_code_value = ls_po_detail-co_code. ls_po_detail-co_code_desc = lo_shlp->get_description_by_value( id_search_value = me->get_sh_value( iv_sh_name = 'H_T001' iv_sh_type = 'SH' iv_key_field = 'BUKRS' iv_value_field = 'BUTXT' iv_code_value = lv_code_value ) it_search_filter = lt_search_filter ). ENDIF. "Get purchase group description IF ls_po_detail-pur_group IS NOT INITIAL. lt_search_filter = me->get_sh_filter( ). add_filter 'EKGRP' ls_po_detail-pur_group. lv_code_value = ls_po_detail-pur_group. ls_po_detail-pur_group_desc = lo_shlp->get_description_by_value( id_search_value = me->get_sh_value( iv_sh_name = 'H_T024' iv_sh_type = 'SH' iv_key_field = 'EKGRP' iv_value_field = 'EKGRP' iv_code_value = lv_code_value ) it_search_filter = lt_search_filter ). ENDIF. "Get doc type description IF ls_po_detail-doc_type IS INITIAL. lt_search_filter = me->get_sh_filter( ). add_filter 'BSTYP' 'F'. APPEND ls_search_filter TO lt_search_filter. add_filter 'BSART' ls_po_detail-doc_type. APPEND ls_search_filter TO lt_search_filter. lv_code_value = ls_po_detail-doc_type. ls_po_detail-po_doctype_desc = lo_shlp->get_description_by_value( id_search_value = me->get_sh_value( iv_sh_name = 'H_T161' iv_sh_type = 'SH' iv_key_field = 'BSART' iv_value_field = 'BATXT' iv_code_value = lv_code_value ) it_search_filter = lt_search_filter ). ENDIF. "Fill vendor address data MOVE-CORRESPONDING ls_address TO ls_po_detail-po_address. LOOP AT lt_items INTO lw_item. CLEAR ls_item. * IF lw_item-delete_ind NE 'X'. IF lw_item-delete_ind IS INITIAL. "Fill item data MOVE-CORRESPONDING lw_item TO ls_item. ls_item-currency = ls_po_detail-currency. "Get material description IF ls_item-material IS NOT INITIAL. lt_search_filter = me->get_sh_filter( ). add_filter 'MATNR' ls_item-material. lv_code_value = ls_item-material. ls_item-material_desc = lo_shlp->get_description_by_value( id_search_value = me->get_sh_value( iv_sh_name = 'MAT0M' iv_sh_type = 'SH' iv_key_field = 'MATNR' iv_value_field = 'MAKTG' iv_code_value = lv_code_value ) it_search_filter = lt_search_filter ). ENDIF. "Get plant description IF ls_item-plant IS NOT INITIAL. lt_search_filter = me->get_sh_filter( ). add_filter 'WERKS' ls_item-plant. lv_code_value = ls_item-plant. ls_item-plant_desc = lo_shlp->get_description_by_value( id_search_value = me->get_sh_value( iv_sh_name = 'H_T001W' iv_sh_type = 'SH' iv_key_field = 'WERKS' iv_value_field = 'NAME1' iv_code_value = lv_code_value ) it_search_filter = lt_search_filter ). ENDIF. "Get UoM description IF ls_item-unit IS NOT INITIAL. lt_search_filter = me->get_sh_filter( ). add_filter 'MSEHI' ls_item-unit. lv_code_value = ls_item-unit. ls_item-uom_desc = lo_shlp->get_description_by_value( id_search_value = me->get_sh_value( iv_sh_name = 'H_T006' iv_sh_type = 'SH' iv_key_field = 'MSEHI' iv_value_field = 'MSEH3' iv_code_value = lv_code_value ) it_search_filter = lt_search_filter ). ENDIF. "Get per Unit description IF ls_item-orderpr_un IS NOT INITIAL. lt_search_filter = me->get_sh_filter( ). add_filter 'MSEHI' ls_item-orderpr_un. lv_code_value = ls_item-orderpr_un. ls_item-orderpr_un_desc = lo_shlp->get_description_by_value( id_search_value = me->get_sh_value( iv_sh_name = 'H_T006' iv_sh_type = 'SH' iv_key_field = 'MSEHI' iv_value_field = 'MSEH3' iv_code_value = lv_code_value ) it_search_filter = lt_search_filter ). ENDIF. IF ls_item-net_value IS NOT INITIAL. ls_po_detail-total_amount = ls_po_detail-total_amount + ls_item-net_value. ENDIF. "Fill item account assignment data LOOP AT lt_account_assignment INTO lw_account_assignment WHERE po_item = lw_item-po_item. CLEAR ls_account_assignment. MOVE-CORRESPONDING lw_account_assignment TO ls_account_assignment. "Get cost centre description IF ls_account_assignment-cost_ctr IS NOT INITIAL. lt_search_filter = me->get_sh_filter( ). add_filter 'KOSTL' ls_account_assignment-cost_ctr. lv_code_value = ls_account_assignment-cost_ctr. ls_account_assignment-cost_ctr_desc = lo_shlp->get_description_by_value( id_search_value = me->get_sh_value( iv_sh_name = 'KOSTN' iv_sh_type = 'SH' iv_key_field = 'KOSTL' iv_value_field = 'MCTXT' iv_code_value = lv_code_value ) it_search_filter = lt_search_filter ). ENDIF. "Get GL account description IF ls_account_assignment-g_l_acct IS NOT INITIAL. lt_search_filter = me->get_sh_filter( ). add_filter 'SAKNR' ls_account_assignment-g_l_acct. APPEND ls_search_filter TO lt_search_filter. lv_code_value = ls_account_assignment-g_l_acct. ls_account_assignment-g_l_acct_desc = lo_shlp->get_description_by_value( id_search_value = me->get_sh_value( iv_sh_name = 'SAKO_CORE' iv_sh_type = 'SH' iv_key_field = 'SAKNR' iv_value_field = 'TXT50' iv_code_value = lv_code_value ) it_search_filter = lt_search_filter ). ENDIF. IF ls_account_assignment-profit_ctr IS NOT INITIAL. "Get profit centre description lt_search_filter = me->get_sh_filter( ). add_filter 'KOKRS' ls_account_assignment-co_area. add_filter 'PRCTR' ls_account_assignment-profit_ctr. lv_code_value = ls_account_assignment-profit_ctr. ls_account_assignment-profit_ctr_desc = lo_shlp->get_description_by_value( id_search_value = me->get_sh_value( iv_sh_name = 'PRCTS' iv_sh_type = 'SH' iv_key_field = 'PRCTR' iv_value_field = 'MCTXT' iv_code_value = lv_code_value ) it_search_filter = lt_search_filter ). ENDIF. "Get maintance order description IF ls_account_assignment-order_no IS NOT INITIAL. lt_search_filter = me->get_sh_filter( ). add_filter 'KOKRS' ls_account_assignment-co_area. add_filter 'AUFNR' ls_account_assignment-order_no. lv_code_value = ls_account_assignment-order_no. ls_account_assignment-order_no_desc = lo_shlp->get_description_by_value( id_search_value = me->get_sh_value( iv_sh_name = 'ORDPA' iv_sh_type = 'SH' iv_key_field = 'AUFNR' iv_value_field = 'KTEXT' iv_code_value = lv_code_value ) it_search_filter = lt_search_filter ). ENDIF. "Get account assigment title IF ls_item-acctasscat IS NOT INITIAL. lt_search_filter = me->get_sh_filter( ). add_filter 'KNTTP' ls_item-acctasscat. lv_code_value = ls_item-acctasscat. ls_account_assignment-title = lo_shlp->get_description_by_value( id_search_value = me->get_sh_value( iv_sh_name = 'H_T163K' iv_sh_type = 'SH' iv_key_field = 'KNTTP' iv_value_field = 'KNTTX' iv_code_value = lv_code_value ) it_search_filter = lt_search_filter ). ENDIF. "Get account assigment summary ls_account_assignment-summary = me->get_account_assignment_summary( id_account_assignment = ls_account_assignment ) . APPEND ls_account_assignment TO ls_item-account_assignment. ENDLOOP. "Fill item history data LOOP AT lt_item_history INTO lw_item_history WHERE po_item = lw_item-po_item. CLEAR ls_item_history. MOVE-CORRESPONDING lw_item_history TO ls_item_history. APPEND ls_item_history TO ls_item-history. ENDLOOP. "Fill item history total data LOOP AT lt_history_totals INTO lw_history_totals WHERE po_item = lw_item-po_item. CLEAR ls_history_totals. MOVE-CORRESPONDING lw_history_totals TO ls_history_totals. APPEND ls_history_totals TO ls_item-history_totals. ENDLOOP. "Fill item texts data LOOP AT lt_item_texts INTO lw_item_texts WHERE po_item = lw_item-po_item. CLEAR ls_item_texts. MOVE-CORRESPONDING lw_item_texts TO ls_item_texts. APPEND ls_item_texts TO ls_item-texts. ENDLOOP. "Fill item schedual data LOOP AT lt_item_schedules INTO lw_item_schedules WHERE po_item = lw_item-po_item. CLEAR ls_item_schedules. MOVE-CORRESPONDING lw_item_schedules TO ls_item_schedules. ls_item_schedules-uom_desc = ls_item-uom_desc. APPEND ls_item_schedules TO ls_item-schedules. ENDLOOP. "Fill item service data LOOP AT lt_item_services1 INTO lw_item_services1 WHERE pckg_no = lw_item-pckg_no. LOOP AT lt_item_services INTO lw_item_services WHERE pckg_no = lw_item_services1-subpckg_no. MOVE-CORRESPONDING lw_item_services TO ls_item_services. ls_item_services-currency = ls_item-currency. "Get UoM description IF ls_item_services-base_uom IS NOT INITIAL. lt_search_filter = me->get_sh_filter( ). add_filter 'MSEHI' ls_item_services-base_uom. lv_code_value = ls_item_services-base_uom. ls_item_services-uom_desc = lo_shlp->get_description_by_value( id_search_value = me->get_sh_value( iv_sh_name = 'H_T006' iv_sh_type = 'SH' iv_key_field = 'MSEHI' iv_value_field = 'MSEH3' iv_code_value = lv_code_value ) it_search_filter = lt_search_filter ). APPEND ls_item_services TO ls_item-services. ENDIF. ENDLOOP. ENDLOOP. APPEND ls_item TO ls_po_detail-po_items. ENDIF. ENDLOOP. "Fill PO header texts data LOOP AT lt_header_texts INTO lw_header_texts. CLEAR ls_header_texts. MOVE-CORRESPONDING lw_header_texts TO ls_header_texts. APPEND ls_header_texts TO ls_po_detail-po_texts. ENDLOOP. e_po_detail = ls_po_detail. ENDIF. ENDMETHOD.