Show TOC

Implementing the SALESORDERS_GET_ENTITYSET MethodLocate this document in the navigation structure

Implement the GET_ENTITYSET method for the SalesOrders entity.

Procedure

  1. From the Class Interface screen, scroll down to the SALESORDERS_GET_ENTITYSET method, place the cursor in the row, and click the Redefine button.
  2. Implement the method using this code:
    method SALESORDERS_GET_ENTITYSET.
    field-symbols: <fs_key> type /iwbep/s_mgw_name_value_pair.
    data: ls_company_name type SNWD_COMPANY_NAME.
    data: lt_range type table of BAPI_EPM_CUSTOMER_NAME_RANGE,
    ls_range type BAPI_EPM_CUSTOMER_NAME_RANGE,
    lv_bp_id(10) type N.
    * Return all SalesOrders if no navigation path.
    if it_navigation_path is initial.
    CALL FUNCTION 'BAPI_EPM_SO_GET_LIST'
    * EXPORTING
    * MAX_ROWS =
    TABLES
    SOHEADERDATA = et_entityset
    * SOITEMDATA =
    * SELPARAMSOID =
    * SELPARAMBUYERNAME =
    * SELPARAMPRODUCTID =
    * RETURN =
    .
    else.
    * Navigation path from BusinessPartners. Return sales orders for a specific business partner.
    * However, can only lookup using "Company Name", not BP_ID. So need
    * to get Company Name using BP_ID first.
    read table it_key_tab assigning <fs_key> index 1.
    lv_bp_id = <fs_key>-value.
    * Look up buyer name based on BP_ID
    select single company_name
    from snwd_bpa
    into ls_company_name
    where bp_id = lv_bp_id.
    ls_range-sign = 'I'.
    ls_range-option = 'EQ'.
    ls_range-low = ls_company_name.
    append ls_range to lt_range.
    CALL FUNCTION 'BAPI_EPM_SO_GET_LIST'
    * EXPORTING
    * MAX_ROWS =
    TABLES
    SOHEADERDATA = et_entityset
    * SOITEMDATA =
    * SELPARAMSOID =
    SELPARAMBUYERNAME = lt_range
    * SELPARAMPRODUCTID =
    * RETURN =
    .
    endif.
    endmethod.

    For sales orders, the resulting list of sales order entities depends primarily on whether a navigation path (from BusinessPartners) is followed or not. If so, the key of the BusinessPartner instance must be passed in to retrieve sales orders that belong to that business partner.

    The function you want to use to return the sales order list, BAPI_EPM_SO_GET_LIST, has a selection parameter for the buyer name (or company name), not the BP_ID. A duplicate company name may return sales orders that belongs to a different buyer. If there is no navigation path, all sales orders entities are returned.

  3. Click the Activate icon.

  4. If you see any warnings, recheck the code, correct any mistakes, then click Activate again.
  5. Click Back to return to the Class Interface screen.