
The /IWFND/CL_MGW_ABS_DATA base class must be sub-classed on the SAP NetWeaver Gateway hub. This class is part of the /IWFND/MGW_GSR_CORE package containing OData Channel-specific generic service interfaces.
Proceed as follows:
Create an OData Channel runtime class for the goods issue example, calling it ZHS_CL_MGW_EPM_GI_RT. Depending on which CRUD (Create, Read, Update, Delete) operations are supported, the corresponding methods must be overwritten.
Note
The following example code returns dummy data for the goods issue example. For a complete implementation, see the corresponding delivered version contained in the package /IWFND/EPM_GOODS_ISSUE.
Syntax
method /IWFND/IF_MGW_APPL_RUNTIME~GET_ENTITY.
* Types Declaration
TYPES: BEGIN OF ty_head_gi_expand,
gi_node_key TYPE /iwfnd/epm_gi_header_guid,
so_guid TYPE /iwfnd/epm_so_guid,
so_id TYPE /iwfnd/epm_so_id,
dly_note_number TYPE /iwfnd/epm_delivery_note_no,
buyer_guid TYPE /iwfnd/epm_buyer_guid,
buyer_name TYPE /iwfnd/epm_company_name,
buyer_id TYPE /iwfnd/epm_partner_id,
created_at TYPE /iwfnd/epm_created_at,
changed_at TYPE /iwfnd/epm_changed_at ,
root_title TYPE string,
goodsissueitem_target TYPE /iwfnd/t_epm_gi_item,
END OF ty_head_gi_expand.
* Variable Declaration
DATA : lv_entity_name TYPE string.
* Structure Declaration
DATA: ls_gi_item TYPE /iwfnd/s_epm_gi_item,
ls_head_gi_expand TYPE ty_head_gi_expand.
* Field Symbol Seclaration
<fs_entity> TYPE any.
lv_entity_name = iv_entity_name.
TRANSLATE lv_entity_name TO UPPER CASE.
IF lv_entity_name EQ 'GOODSISSUE'.
"For GI Header read with $expand
"Create dummy data.
CLEAR ls_head_gi_expand.
ls_head_gi_expand-buyer_guid = '12345678-aaaa-bbbb-cccc-ddddeeeeffff'.
ls_head_gi_expand-buyer_id = ''.
ls_head_gi_expand-buyer_name = 'Duck'.
ls_head_gi_expand-gi_node_key = '12345678-aaaa-bbbb-cccc-ddddeeeeffff'.
ls_head_gi_expand-root_title = 'Root'.
ls_head_gi_expand-so_guid = '12345678-aaaa-bbbb-cccc-ddddeeeeffff'.
ls_head_gi_expand-so_id = '12345678-aaaa-bbbb-cccc-ddddeeeeffff'.
CREATE DATA er_entity LIKE ls_head_gi_expand.
ASSIGN er_entity->* TO <fs_entity>
<fs_entity> ls_head_gi_expand.
ELSEIF lv_entity_name EQ 'GOODSISSUEITEM'.
"Create dummy data.
CLEAR ls_gi_item.
ls_gi_item-gi_item_node_key = '12345678-aaaa-bbbb-cccc-ddddeeeeffff'.
ls_gi_item-gi_node_key = '12345678-aaaa-bbbb-cccc-ddddeeeeffff'.
ls_gi_item-product_guid = '12345678-aaaa-bbbb-cccc-ddddeeeeffff'.
ls_gi_item-product_name = 'soap'.
ls_gi_item-quantity = '1'.
ls_gi_item-quantity_desc = 'small'.
ls_gi_item-quantity_unit = 'number'.
ls_gi_item-so_item_guid = '12345678-aaaa-bbbb-cccc-ddddeeeeffff'.
ls_gi_item-so_item_pos = '23'.
CREATE DATA er_entity LIKE ls_gi_item.
ASSIGN er_entity->* TO <fs_entity>
<fs_entity> = ls_gi_item.
ENDIF.
endmethod.
Syntax
method /IWFND/IF_MGW_APPL_RUNTIME~GET_ENTITYSET.
* Types Declaration
TYPES: BEGIN OF ty_head_gi_expand,
gi_node_key TYPE /iwfnd/epm_gi_header_guid,
so_guid TYPE /iwfnd/epm_so_guid,
so_id TYPE /iwfnd/epm_so_id,
dly_note_number TYPE /iwfnd/epm_delivery_note_no,
buyer_guid TYPE /iwfnd/epm_buyer_guid,
buyer_name TYPE /iwfnd/epm_company_name,
buyer_id TYPE /iwfnd/epm_partner_id,
created_at TYPE /iwfnd/epm_created_at,
changed_at TYPE /iwfnd/epm_changed_at ,
root_title TYPE string,
goodsissueitem_target TYPE /iwfnd/t_epm_gi_item,
END OF ty_head_gi_expand.
* Variable Declaration
DATA: lv_entity_name TYPE string.
*Structure Declaration
DATA: ls_item_gi TYPE /iwfnd/s_epm_gi_item,
ls_head_gi_expand TYPE ty_head_gi_expand.
*Internaltable Declaration
DATA: lt_item_gi TYPE STANDARD TABLE OF /iwfnd/s_epm_gi_item,
lt_head_gi_expand TYPE STANDARD TABLE OF ty_head_gi_expand.
*Field Symbol Declaration
FIELD-SYMBOLS : <fs_entityset> TYPE any.
lv_entity_name = iv_entity_name.
TRANSLATE lv_entity_name TO UPPER CASE.
"For GI Header query
IF lv_entity_name EQ 'GOODSISSUE'.
" Create some dummy data for the EPM goods issue example.
CLEAR lt_head_gi_expand.
CLEAR ls_head_gi_expand.
ls_head_gi_expand-gi_node_key = 'GI Key'.
ls_head_gi_expand-buyer_id = 'Buyer ID'.
ls_head_gi_expand-buyer_guid = '12345678-aaaa-bbbb-cccc-ddddeeeeffff'.
ls_head_gi_expand-buyer_name = 'Duck'.
ls_head_gi_expand-so_guid = '12345678-aaaa-bbbb-cccc-ddddeeeeffff'.
ls_head_gi_expand-so_id = 'SO ID'.
INSERT ls_head_gi_expand INTO TABLE lt_head_gi_expand.
CREATE DATA er_entityset LIKE lt_head_gi_expand.
ASSIGN er_entityset->* TO <fs_entityset>.
<fs_entityset> = lt_head_gi_expand.
"For navigating to GoodsIssueItem Collection
ELSEIF lv_entity_name EQ 'GOODSISSUEITEM'.
" Create some dummy data for the EPM goods issue example.
CLEAR lt_item_gi.
CLEAR ls_item_gi.
ls_item_gi-gi_item_node_key = '12345678-aaaa-bbbb-cccc-ddddeeeeffff'.
ls_item_gi-gi_node_key = '12345678-aaaa-bbbb-cccc-ddddeeeeffff'.
ls_item_gi-product_guid = '12345678-aaaa-bbbb-cccc-ddddeeeeffff'.
ls_item_gi-product_name = 'soap'.
ls_item_gi-quantity = '1'.
ls_item_gi-quantity_desc = 'small'.
ls_item_gi-quantity_unit = 'number'.
ls_item_gi-so_item_guid = '12345678-aaaa-bbbb-cccc-ddddeeeeffff'.
ls_item_gi-so_item_pos = 'Item Pos'.
INSERT ls_item_gi INTO TABLE lt_item_gi.
CREATE DATA er_entityset LIKE lt_item_gi.
ASSIGN er_entityset->* TO <fs_entityset>.
<fs_entityset> = lt_item_gi.
ENDIF.
endmethod.
Syntax
method /IWFND/IF_MGW_APPL_RUNTIME~EXECUTE_ACTION.
* Executes a function import call.
CASE iv_action_name.
WHEN 'GOODSISSUE_OP'.
" Do something here...
WHEN OTHERS.
ENDCASE.
endmethod.
Register the OData runtime class implementation; for details see Registering Object Models and Services.
At runtime the corresponding runtime implementation is chosen, specifically the technical name of the Consumption Model.
The OData Channel runtime class has been created. Next, configure the runtime using the IMG.