Penrock
Penrock

Reputation: 143

OData getEntity method fetches only first entity

I have a service with a working getEntitySet method. The output looks like this:

ColumnSet

But when I try to get only a single entity with /ColumnSet(1) my Output fetches only the first entity which is ColumnSet(0)

method COLUMNSET_GET_ENTITY.

 data: ls_key_tab type /iwbep/s_mgw_name_value_pair,
      lv_columnid type string,
      ls_column type zst_column.

 loop at it_key_tab into ls_key_tab.
  if ls_key_tab-name = 'COLUMNID'.
    lv_columnid = ls_key_tab-value.
    endif.
    endloop.

 select single * from zst_column into ls_column where id_num = lv_columnid.


   er_entity-id_num = ls_column-id_num.
   er_entity-id = ls_column-id.
   er_entity-posi = ls_column-posi.
   er_entity-data_id = ls_column-data_id.
   er_entity-headertext = ls_column-headertext.
   er_entity-ui_element_typ = ls_column-ui_element_typ.
   er_entity-enable = ls_column-enable.
   er_entity-enable_ref = ls_column-enable_ref.

   endmethod.

I dont know, why it only shows the first entity.

Upvotes: 1

Views: 1781

Answers (1)

I.B.N.
I.B.N.

Reputation: 1034

Your Key field is IDNUM, not COLUMNID.

 loop at it_key_tab into ls_key_tab.
  if ls_key_tab-name = 'IdNum'.
    lv_columnid = ls_key_tab-value.
  endif.
 endloop.

Upvotes: 2

Related Questions