Skip to Content

Odata with multilevel expand entity set issue

It has 3 entity sets 1 POHeaderSet 2 POItemSet 3 POScheduleSet cardinality of header to item is 1 : N and Item to schedule is 1:M

URL :/sap/opu/odata/sap/ZPO_ODATA_149_SRV/POHeaderSet?$expand=PurchaseOrderN/PurchaseSchedule&$format=json

where PurchaseOrderN and PurchaseSchedule are my navigation properties. Issue is when I execute this code. My header and schedule items are displayed correctly in JSON format but in line items only the first 2 fields are fetched and the remaining 3 are incorrect and blank. why isn't the complete data displayed. Please help me to find this issue.

method /iwbep/if_mgw_appl_srv_runtime~get_expanded_entityset.





types: ld_poitem type standard table of zcl_zpo_odata_149_mpc=>ts_poitem ,

       ld_poschedule type standard table of zcl_zpo_odata_149_mpc=>ts_poschedule .



types: begin of ld_complex.

          include           type zcl_zpo_odata_149_mpc=>ts_poheader.

          types:  purchaseordern type STANDARD TABLE OF zcl_zpo_odata_149_mpc=>ts_poitem with default key.

          types : purchaseschedule type standard table of zcl_zpo_odata_149_mpc=>ts_poschedule with default key,



  end of ld_complex.



data:  it_complex type STANDARD TABLE OF ld_complex,

      wa_complex type ld_complex,

      it_ekko type standard table of zekko_149,

      it_ekpo type standard table of zekpo_149,

      it_eket type standard table of zeket_149,

      wa_ekko type zekko_149,

      wa_ekpo type zekpo_149,

      wa_eket type zeket_149,

         lv_techname1        LIKE LINE OF           et_expanded_tech_clauses,

       lv_index1 type sy-tabix,

       lv_index2 type sy-tabix.









select mandt

       ebeln

       ernam

       lifnr

  from zekko_149

  into table it_ekko.



if sy-subrc = 0 .

  select mandt

         ebeln

         ebelp

         txz01

         matnr

   into table it_ekpo

    from zekpo_149



    for all entries in it_ekko

    where ebeln = it_ekko-ebeln .

if sy-subrc = 0.



  select mandt

         ebeln

         ebelp

         etenr

  into table it_eket

    from zeket_149

    for all entries in it_ekpo

    where ebeln = it_ekpo-ebeln

          and ebelp = it_ekpo-ebelp.



  endif.

  endif.





loop at it_ekko into wa_ekko.

  clear wa_complex.

  wa_complex-mandt = wa_ekko-mandt.

  wa_complex-ebeln = wa_ekko-ebeln.

  wa_complex-ernam = wa_ekko-ernam.

  wa_complex-lifnr = wa_ekko-lifnr.



lv_index1 = sy-tabix.



loop at it_ekpo into wa_ekpo from lv_index1 where ebeln = wa_ekko-ebeln .

  append wa_ekpo to wa_complex-purchaseordern.

  lv_index2 = sy-tabix.



  loop at it_eket into wa_eket from lv_index2 where ebeln = wa_ekko-ebeln

                                                and ebelp = wa_ekpo-ebelp.

      append wa_eket to wa_complex-purchaseschedule.

      endloop.

  endloop.



  append wa_complex to it_complex.



endloop.





 lv_techname1 = 'PurchaseOrderN/PurchaseSchedule'.

 INSERT lv_techname1 INTO TABLE et_expanded_tech_clauses.







if iv_entity_set_name = 'POHeaderSet'

  OR iv_entity_set_name = 'POItemSet' OR iv_entity_set_name = 'POScheduleSet'



    AND io_expand->compare_to_tech_names( 'PurchaseOrderN/PurchaseSchedule') EQ

   io_expand->gcs_compare_result-match_equals .





Clear er_entityset.

copy_data_to_ref(

  exporting

  is_data = it_complex

  changing

  cr_data = er_entityset



  ).

  endif.
odata1.png (87.8 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers