Developer

Implementing the SALESORDERITEMS_GET_ENTITYSET Method

Implement the GET_ENTITYSET method for the SalesOrderItems entity.

Procedure

  1. From the Class Interface screen, scroll down to the SALESORDERITEMS_GET_ENTITYSET method, place the cursor in the row, and click the Redefine button.
  2. Implement the method using this code:
    method SALESORDERITEMS_GET_ENTITYSET.
    data: lt_range type table of BAPI_EPM_SO_ID_RANGE,
    ls_range type BAPI_EPM_SO_ID_RANGE,
    lv_so_id(10) type N.
    field-symbols: <fs_key> type /iwbep/s_mgw_name_value_pair.
    * limit access to SalesOrderItmes  through a navigation path or $expand option.
    if it_navigation_path is initial.
    * If it's not, raise an exception.
    RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception
    EXPORTING
    textid = /iwbep/cx_mgw_busi_exception=>business_error_unlimited
    message_unlimited = 'SalesOrderItems can only be accessed from
    a Sales Order navigation path or using the $expand=Items option.'.
    else.
    * There is a navigation path. Read only items for a particular SO
    * SO ID should be in it_key_tab.
    read table it_key_tab assigning <fs_key> index 1.
    lv_so_id = <fs_key>-value.
    ls_range-sign = 'I'.
    ls_range-option = 'EQ'.
    ls_range-low = lv_so_id.
    append ls_range to lt_range.
    CALL FUNCTION 'BAPI_EPM_SO_GET_LIST'
    * EXPORTING
    * MAX_ROWS =
    TABLES
    * SOHEADERDATA =
    SOITEMDATA = et_entityset
    SELPARAMSOID = lt_range
    * SELPARAMBUYERNAME =
    * SELPARAMPRODUCTID =
    * RETURN =
    .
    endif.
    endmethod.
  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.