Skip to Content

Getting different Request and Response Structures in a Deep Entity Set In a POST operation.

Apr 26 at 06:57 AM


avatar image
Former Member

There are two parts to the question.

a. From what I understand when using the CREATE_DEEP_ENTITY method in the DPC, the structure created for the Deep Entity includes the Request structure and the Required Response structure(which would be a table making it a deep structure). The Actual Response would return this combination of the Request and Response. Is there a possibility of not sending the full request structure along with the response structure? i.e.

1. Request



Req_Deep_Structure (Deep Structure)

2. Actual Response (Type created for method CREATE_DEEP_ENTITY)






3. Required Response (this is the data that is required)


Res_Tab1 (flat structure)

Res_Tab2 (flat structure)

b. Is there a possibility to have a three level deep entity structure in the response getting the response for the deepest table i.e.






Req_Deep_Structure-field_table(flat structure)










Deeper_structure-field_tab(flat Structure) -- I need this to be shown in the output

Here I want to output the table Deeper_structure-field_tab in a POST call.

Is there a way to use $expand (like in a get call to achieve this)? or any other possibility?

(All elements starting from 'Req' represent the Request and 'Res' represent the Response)

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Simone Milesi Apr 26 at 07:19 AM


i do not understand your



in "CREATE_DEEP_ENTITY" you just receive the data as deep entity (the number of levels you handle is up to your design: for a single and specific case i have a 4 level entity: Inforecord-Period-Condition-Scale ).
That's all you need.

The $Expand is used to indentify which Sub-structures you want to get in GET_DEEP_ENTITY / GET_DEEP_ENTITYSET methods, not in create.

Take in mind that the CREATE method could just receive a partial structure (even if i suggest you to define your full deep entity one) and then you can check if the mandatory fields are defined.

i share here a snippet of my 4 level structure and how i handled it, hoping this could help in your issue (otherwise, please, forgive me and explain a bit better what you need: it's early morning and i still need my coffee).

Deep Entity defintion on _DPC_EXT class

types: BEGIN OF ty_deep_condition .
     INCLUDE TYPE zcl_zpurchinforecord_mpc=>ts_inforecordcondition.  
TYPES: scalelink TYPE TABLE OF zcl_zpurchinforecord_mpc=>ts_inforecordscale WITH DEFAULT KEY,
END OF ty_deep_condition .
types: tty_deep_condition TYPE TABLE OF ty_deep_condition .
types: BEGIN OF ty_deep_period.
INCLUDE TYPE zcl_zpurchinforecord_mpc=>ts_inforecordperiod.
TYPES: conditionlink TYPE TABLE OF ty_deep_condition WITH DEFAULT KEY,
END OF ty_deep_period .
types: tty_deep_period TYPE TABLE OF ty_deep_period .
types: BEGIN OF ty_deep_info.
INCLUDE TYPE zcl_zpurchinforecord_mpc=>ts_inforecord .
TYPES: periodlink TYPE TABLE OF ty_deep_period WITH DEFAULT KEY,
END OF ty_deep_info .

The POST Deep Entity Implementation

METHOD /iwbep/if_mgw_appl_srv_runtime~create_deep_entity.
 DATA: deeppir TYPE ty_deep_info.
 CASE iv_entity_set_name.
     WHEN 'InfoRecordSet'.
* Transform data into the internal structure
     io_data_provider->read_entry_data( IMPORTING es_data = deeppir ).
      create_deep_pir( CHANGING deeppir = deeppir
                                er_deep_entity = er_deep_entity ).
 IF er_deep_entity IS INITIAL. "Aka creation failed
      RAISE EXCEPTION TYPE /iwbep/cx_mgw_tech_exception.

And in my CREATE_DEEP_PIR, if everything has gone right

 is_data = deeppir
 cr_data = er_deep_entity ).

So, i can receive partial information (i.e. i do not have the Inforecord Number since i'm gonna create it) and fill / change data during the building process, sending back the updated structure.

Show 3 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Simone,

Thank you and apologies for getting you to respond this early. Maybe I can rephrase what I asked.

For the first part, I partially understood what you meant. I am doing exactly that. Using method io_data_provider->read_entry_data to get the deep entity (which contains both the request and response parts) Before calling copy_data_to_ref, I tried deleting the request data which caused a problem and it threw a 500 server response error(I believe because of a date field was present in the request and it can't take 00000000 as it's default).

My question is would it be possible to completely remove the request tags from the output and only send response parts across. Is there a method that gets triggered which would help us in redefining the output structure (like the define method of the Model Provider Class).

For the second part of the question, I understand that $expand is used only in GET calls but would it be possible to achieve that functionality in a POST call. Currently we get a deferred output for any table after the first level.

Parts of the response.






DEEP_STRUCTURE-TABLE --- this comes out as a deferred output. In a GET call I would have used $expand=DEEP_STRUCTURE/TABLE to get the output for the table too.I want to achieve that in a POST call

Thanks again.



Ok, now with caffeine in my blood, i can understand a bit better :P
I start from the easy part, the second question: it's useless.

In POST you just pass the structures you need, without EXPAND.

Using my example (i see only now the code messed the definition layout and i'll fix as i finish this reply), if i do not want to handle the SCALE structure, i just avoid to pass it from my client.

In the response, my personal suggestion, is to fill always the full structure, leaving to the client the choice on what fields to use.

For the first question, i do not think it will work because, from hours of debug (sigh!), our CREATE_DEEP_ENTITY method is the last one in a long stack of calls where the structure itself is defined, so the Gateway (at least in my 731) expects a specific structure (the one defined by the call) as output, filled or not, but that structure.

Former Member
Simone Milesi

So for the second part if the client wants to get hold of the DEEP_STRUCTURE table, how would the JSON request look like?


"Request_field1" : "ABCD",

"Request_struct" :


"struct_field1" : "CDE",

"struct_field2" : "20180426"


"Request_deep1" : [


"field1" : "1",

"field2" : "10.000",

"table1" : [


"Name" : "NAME1",

"Value" : "SIMONE"



"Name" : "ID",

"Value" : "0001"





"Response_deep_structure" : [ "this is a deep structure containing another table TAB1 and I need that also in the response" ],

"Response_deep_structure_2" : [ ]


From what I understand the client needs all the fields in 'Response_deep_structure' including TAB1 in the response.

Thanks again for taking the time to respond.