Show TOC

Implementing the GET_ENTITY and GET_ENTITYSET MethodsLocate this document in the navigation structure

Use

The most common methods that need to be implemented are those for retrieving the entity collection (GET_ENTITYSET) and details about a specific entity (GET_ENTITY). In this cookbook, we use the goods issue entity.

An example implementation for the corresponding methods within the ZHS_CL_GOODSISSUE class is shown below. Some dummy data is filled into the result table or the result structure respectively.

method ZHS_IF_GOODSISSUE~GET_ENTITYSET.
*&---------------------------------------------------------------------*
*&  Include           Generated code based on
*&               /IWBEP/MGW_GEN_TEMPL_RT_CDC_ES
*&  Name of entity is passed to this template (as entity)!
*&  Name of the model provider class is passed to this template
*&   (as mp_class_name)!
*&---------------------------------------------------------------------*
  DATA ls_goodsissue TYPE ZHS_CL_MOD_EPM=>TS_GOODSISSUE.

* Create some dummy data.

  CLEAR ls_goodsissue.
  CLEAR et_resulttable.

*Add here your goodsissue(s) (type TS_GOODSISSUE) to the table et_resulttable...
  ls_goodsissue-SALESORDERNUMBER = 'Sales Order Number 1'.       "Type
  ls_goodsissue-BUYERID = 'Buyer ID 1'.       "Type
  ls_goodsissue-BUYERNAME = 'Buyer Name 1'.       "Type
  "ls_goodsissue-BUYERKEY = .       "Type
  "ls_goodsissue-SALESORDERKEY = .       "Type
  ls_goodsissue-GOODSISSUEKEY = '1'.       "Type
  "ls_goodsissue-CHANGEDON = .       "Type
  "ls_goodsissue-ROOTTITLE = .       "Type
  "ls_goodsissue-CREATEDON = .       "Type

  APPEND ls_goodsissue TO et_resulttable.

  ls_goodsissue-SALESORDERNUMBER = 'Sales Order Number 2'.       "Type
  ls_goodsissue-BUYERID = 'Buyer ID 2'.       "Type
  ls_goodsissue-BUYERNAME = 'Buyer Name 2'.       "Type
  ls_goodsissue-GOODSISSUEKEY = '2'.       "Type

  APPEND ls_goodsissue TO et_resulttable.

endmethod.
 
method ZHS_IF_GOODSISSUE~GET_ENTITY.
*&---------------------------------------------------------------------*
*&  Include           Generated code based on
*&                  template /IWBEP/MGW_GEN_TEMPL_DP_CDC_EN
*&  Name of entity is passed to this template (as entity)!
*&  Name of model provider class is passed to this template (as mp_class_name)!
*&---------------------------------------------------------------------*
  DATA ls_goodsissue TYPE ZHS_CL_MOD_EPM=>TS_GOODSISSUE.

* Create some dummy data.
  DATA ls_key LIKE LINE OF it_key_tab.

  READ TABLE it_key_tab INTO ls_key INDEX 1.

  CASE ls_key-value.
    WHEN '10'.
*Add here your goodsissue(s) (type TS_GOODSISSUE) to the table et_resulttable...
      ls_goodsissue-SALESORDERNUMBER = 'Sales Order Number 1'.       "Type
      ls_goodsissue-BUYERID = 'Buyer ID 1'.       "Type
      ls_goodsissue-BUYERNAME = 'Buyer Name 1'.       "Type
*  ls_goodsissue-BUYERKEY = .       "Type
*  ls_goodsissue-SALESORDERKEY = .       "Type
      ls_goodsissue-GOODSISSUEKEY = '1'.       "Type
*  ls_goodsissue-CHANGEDON = .       "Type
*  ls_goodsissue-ROOTTITLE = .       "Type
*  ls_goodsissue-CREATEDON = .       "Type
    WHEN '20'.
      ls_goodsissue-SALESORDERNUMBER = 'Sales Order Number 2'.       "Type
      ls_goodsissue-BUYERID = 'Buyer ID 2'.       "Type
      ls_goodsissue-BUYERNAME = 'Buyer Name 2'.       "Type
      ls_goodsissue-GOODSISSUEKEY = '2'.       "Type
  ENDCASE.

  es_goodsissue = ls_goodsissue.
endmethod.
 
Result

The GET_ENTITY and GET_ENTITYSET methods are implemented. Next, register the service for use at runtime.