on 2018 Jul 10 10:41 AM
Hi all,
I am trying to implement a multi level expand (EntityA$expand=EntityB/EntityC) but it is not working for the entity C - it is returning blank).
I can see in debug that the entityset, from the expand method, is being overwritten by a 5 column entity set from standard SAP (only showing entity A and ToItems (Entity B)).
My expand logic is filling the data correctly.
Results:
URL:
../TrolleyHeaderSet?$expand=ToItems/ToMaterials
SEGW:
Association:
Debug:
Expand code:
CASE iv_entity_set_name.
WHEN 'TrolleyHeaderSet'.
DATA: "lt_expand TYPE STANDARD TABLE OF zswm_gw_trolley_expand,
lt_filters TYPE /iwbep/t_mgw_select_option,
ls_filter TYPE /iwbep/s_mgw_select_option,
lv_filter TYPE zewm_zone.
lv_expand_tech_clause = io_tech_request_context->get_expand( ).
TRANSLATE lv_expand_tech_clause TO UPPER CASE.
DATA: BEGIN OF ty_expand.
INCLUDE TYPE zcl_zgw_picking_soluti_mpc_ext=>ts_trolleyheader.
DATA: toitems TYPE zcl_zgw_picking_soluti_mpc_ext=>tt_trolleyitems,
tomaterials TYPE zcl_zgw_picking_soluti_mpc_ext=>tt_trolleymaterials,
END OF ty_expand.
DATA: lt_trolleys TYPE STANDARD TABLE OF zswm_trolley_ctrl,
lt_trolley_header TYPE zcl_zgw_picking_soluti_mpc_ext=>tt_trolleyheader,
lt_trolley_item TYPE zcl_zgw_picking_soluti_mpc_ext=>tt_trolleyitems,
lt_trolley_mats TYPE zcl_zgw_picking_soluti_mpc_ext=>tt_trolleymaterials,
lt_expand LIKE STANDARD TABLE OF ty_expand.
DATA: ls_trolley_header TYPE zcl_zgw_picking_soluti_mpc_ext=>ts_trolleyheader,
ls_trolley_item TYPE zcl_zgw_picking_soluti_mpc_ext=>ts_trolleyitems,
ls_materials TYPE zcl_zgw_picking_soluti_mpc_ext=>ts_trolleymaterials,
ls_expand LIKE LINE OF lt_expand.
SELECT * FROM ztwm_trolleyctrl INTO CORRESPONDING FIELDS OF TABLE lt_trolleys.
IF sy-subrc <> 0.
RETURN.
ENDIF.
LOOP AT lt_trolleys ASSIGNING FIELD-SYMBOL(<fs_trolleys>).
MOVE-CORRESPONDING <fs_trolleys> TO ls_trolley_header.
APPEND ls_trolley_header TO lt_trolley_header.
MOVE-CORRESPONDING <fs_trolleys> TO ls_trolley_item.
APPEND ls_trolley_item TO lt_trolley_item.
ENDLOOP.
lt_trolley_mats = zcl_wm_picking_solution=>get_materials( ).
SORT lt_trolley_header BY trolley_type ASCENDING.
SORT lt_trolley_item BY trolley_id ASCENDING trolley_type ASCENDING.
SORT lt_trolley_mats BY trolley_id ASCENDING trolley_type ASCENDING material ASCENDING.
DELETE ADJACENT DUPLICATES FROM lt_trolley_header.
LOOP AT lt_trolley_header ASSIGNING FIELD-SYMBOL(<fs_header>).
MOVE-CORRESPONDING <fs_header> TO ls_expand.
LOOP AT lt_trolley_item ASSIGNING FIELD-SYMBOL(<fs_item>) WHERE trolley_type = <fs_header>-trolley_type.
APPEND <fs_item> TO ls_expand-toitems.
ENDLOOP.
LOOP AT lt_trolley_mats ASSIGNING FIELD-SYMBOL(<fs_material>) WHERE trolley_type = <fs_header>-trolley_type.
APPEND <fs_material> TO ls_expand-tomaterials.
ENDLOOP.
APPEND ls_expand TO lt_expand.
CLEAR ls_expand.
ENDLOOP.
WHEN OTHERS.
RETURN.
ENDCASE.
copy_data_to_ref(
EXPORTING
is_data = lt_expand
CHANGING
cr_data = er_entityset ).
APPEND lv_expand_tech_clause TO et_expanded_tech_clauses.
Request clarification before answering.
Hi James!
Nice to talk to you again.
Not sure what version of Gateway you have but have you tried looking at some relevant SAP notes - this one in particular 2087759 - Empty result on $expand although data exists
If not valid, does it work when you select for EntityB expanding on EntityC?
Oli
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
70 | |
21 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.