Show TOC

Redefining the DPC Implementation ClassLocate this document in the navigation structure

Procedure

You add your own code to the selected method for an operation of the selected entity set.

To redefine the method for an operation:

  1. Expand the Service Implementation folder to display its entity sets.

  2. Expand the entity set, SALESORDERCOLLECTION, to display the methods for its operations.

  3. Right click the method, GETENTITYSET (QUERY) and choose Go to ABAP Workbench.

    If the method has not been redefined, a message displays and a list of methods is presented in the display mode in the transaction SE24.

  4. Choose the method in the Class Builder screen:

    It displays the following:

    method SALESORDERCOLLEC_GET_ENTITYSET.

    RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc

    EXPORTING

    textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented

    method = 'SALESORDERCOLLEC_GET_ENTITYSET'.

    endmethod.

  5. Redefine the method for the query, SALESORDERCOLLEC_GET_ENTITYSET, as follows:

    DATA: ls_salesorder LIKE LINE OF et_entityset,

    lt_soheaderdata TYPE STANDARD TABLE OF bapi_epm_so_header,

    ls_soheaderdata TYPE bapi_epm_so_header, lv_maxrows TYPE bapi_epm_max_rows.

    CALL FUNCTION 'BAPI_EPM_SO_GET_LIST' * EXPORTING * MAX_ROWS = TABLES soheaderdata = lt_soheaderdata.

    * SOITEMDATA =

    * SELPARAMSOID =

    * SELPARAMBUYERNAME =

    * SELPARAMPRODUCTID =

    * RETURN =

    LOOP AT lt_soheaderdata INTO ls_soheaderdata.

    CLEAR ls_salesorder. ls_salesorder-salesorderid = ls_soheaderdata-so_id.

    ls_salesorder-customerid = ls_soheaderdata-buyer_id.

    ls_salesorder-customername = ls_soheaderdata-buyer_name.

    ls_salesorder-status = ls_soheaderdata-lifecycle_status.

    ls_salesorder-totalsum = ls_soheaderdata-gross_amount.

    ls_salesorder-netsum = ls_soheaderdata-net_amount.

    ls_salesorder-tax = ls_soheaderdata-tax_amount.

    ls_salesorder-currency = ls_soheaderdata-currency_code.

    ls_salesorder-note = ls_soheaderdata-note.

    ls_salesorder-createdat = ls_soheaderdata-created_at.

    APPEND ls_salesorder TO et_entityset.

    ENDLOOP.

  6. Redefine the method for Read, SALESORDERCOLLEC_GET_ENTITY, as follows:

    DATA: lv_so_id TYPE snwd_so_id,

    ls_so_id TYPE bapi_epm_so_id,

    ls_headerdata TYPE bapi_epm_so_header,

    ls_message TYPE scx_t100key,

    lt_return TYPE STANDARD TABLE OF bapiret2,

    ls_return TYPE bapiret2.

    FIELD-SYMBOLS: <ls_key> TYPE /iwbep/s_mgw_name_value_pair.

    LOOP AT it_key_tab ASSIGNING <ls_key>.

    CASE <ls_key> -name.

    WHEN 'SalesOrderID' OR ''.

    lv_so_id = <ls_key> -value.

    ENDCASE.

    ENDLOOP.

    IF lv_so_id IS INITIAL.

    ls_message-msgid = 'SY'.

    ls_message-msgno = '002'.

    ls_message-attr1 = 'Sales Order not found'.

    RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception

    EXPORTING

    textid = ls_message. ENDIF.

    ls_so_id-so_id = lv_so_id.

    CALL FUNCTION 'BAPI_EPM_SO_GET_DETAIL'

    EXPORTING

    so_id = ls_so_id

    IMPORTING

    headerdata = ls_headerdata

    TABLES

    * ITEMDATA =

    return =

    lt_return.

    IF NOT lt_return IS INITIAL.

    READ TABLE lt_return INTO ls_return INDEX 1.

    ls_message-msgid = ls_return-id. ls_message-msgno = ls_return-number.

    ls_message-attr1 = ls_return-message_v1.

    ls_message-attr2 = ls_return-message_v2.

    ls_message-attr3 = ls_return-message_v3.

    ls_message-attr4 = ls_return-message_v4.

    RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception

    EXPORTING

    textid = ls_message.

    ENDIF.

    er_entity-salesorderid = ls_headerdata-so_id.

    er_entity-customerid = ls_headerdata-buyer_id.

    er_entity-customername = ls_headerdata-buyer_name.

    er_entity-status = ls_headerdata-lifecycle_status.

    er_entity-totalsum = ls_headerdata-gross_amount.

    er_entity-netsum = ls_headerdata-net_amount.

    er_entity-tax = ls_headerdata-tax_amount.

    er_entity-currency = ls_headerdata-currency_code.

    er_entity-note = ls_headerdata-note.

    er_entity-createdat = ls_headerdata-created_at.

  7. Save the your changes before you make any other selection.