Quantcast
Channel: SCN : All Content - SAP Gateway
Viewing all articles
Browse latest Browse all 2823

Issue with GET_EXPANDED_ENTITYSET

$
0
0

Hello,

 

I have a requirement where I have to implement multi level expansion of entity-set for below both URI. 

 

  1. /sap/opu/odata/sap/ZZPHOENIX_004_SRV/SalesOrderSet/?$expand=OrderToItems
  2. /sap/opu/odata/sap/ZPHOENIX_004_SRV/SalesOrderSet/?$expand=OrderToItems/ItemToMaterial.

1.jpg

For OrderToItems/ItemToMaterial below code is working fine but when I am trying to call $expand = OrderToItems then it is going in LOOP. I am not sure why.

 

Below is my code in GET_EXPANDED_ENTITYSET method.

 

DATA:  BEGIN OF t_orderitems.             INCLUDE              TYPE  zcl_zphoenix_004_mpc_ext=>ts_salesorderitem.     DATA: itemtomaterial TYPE  zcl_zphoenix_004_mpc_ext=>ts_material,           END OF t_orderitems.     DATA:  BEGIN OF t_expand_so.             INCLUDE             TYPE zcl_zphoenix_004_mpc_ext=>ts_salesorder.     DATA: ordertoitems  LIKE TABLE OF t_orderitems,          END OF t_expand_so.     DATA: lt_expand_so   LIKE  TABLE OF t_expand_so,           ls_expand_so   LIKE t_expand_so,           ls_item        LIKE t_orderitems.     DATA: lt_vbak  TYPE TABLE OF vbak,           ls_vbak  LIKE LINE OF lt_vbak,           lt_vbap  TYPE TABLE OF vbap,           ls_vbap  TYPE  vbap,           l_max_rows    TYPE i VALUE 20.     DATA: lv_matnr TYPE matnr,           ls_mara  TYPE mara.     CONSTANTS: lc_expand_itemtomaterial  TYPE string VALUE 'ORDERTOITEMS/ITEMTOMATERIAL',                lc_expand_ordertoitems    TYPE string VALUE 'ORDERTOITEMS'.     SELECT * FROM vbak INTO TABLE lt_vbak UP TO l_max_rows ROWS ORDER BY erdat DESCENDING.     IF sy-subrc EQ 0.       SELECT * FROM vbap INTO TABLE lt_vbap FOR ALL ENTRIES IN lt_vbak WHERE vbeln = lt_vbak-vbeln.     ENDIF.
 * Data processing logic     LOOP AT lt_vbak INTO ls_vbak.       MOVE-CORRESPONDING ls_vbak TO ls_expand_so  .       LOOP AT lt_vbap INTO ls_vbap WHERE vbeln = ls_vbak-vbeln.         MOVE-CORRESPONDING ls_vbap TO ls_item  .         lv_matnr = ls_vbap-matnr.         CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'           EXPORTING             input  = lv_matnr           IMPORTING             output = lv_matnr.         SELECT SINGLE * FROM mara INTO ls_mara WHERE matnr = lv_matnr.         MOVE-CORRESPONDING ls_mara TO ls_item-itemtomaterial.         APPEND ls_item  TO ls_expand_so-ordertoitems.         CLEAR: ls_item.       ENDLOOP.       APPEND ls_expand_so  TO lt_expand_so.       CLEAR: ls_expand_so, lv_matnr.     ENDLOOP.
 * Fill EE_ENTITYSET     copy_data_to_ref(       EXPORTING         is_data = lt_expand_so       CHANGING         cr_data = er_entityset ).
 * Insert Navigation property into ET_EXPANDED_TECH_CLAUSES     INSERT lc_expand_ordertoitems   INTO TABLE et_expanded_tech_clauses.
 INSERT lc_expand_itemtomaterial INTO TABLE et_expanded_tech_clauses.

I have already checked below blogs but not able to understand this. Can someone suggest how to implement GET_EXPANDED_ENTITYSET method for a scenario A->B and A->B->C (where A and B is associated and B and C is associated)

 

Let's code association/navigation and data provider expand in OData service!

Multi-Level Expansion with GET_EXPANDED_ENTITYSET

 

Thanks,

~Rahul


Viewing all articles
Browse latest Browse all 2823

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>