Skip to Content
avatar image
Former Member

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

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_field1

Req_field2

Req_Deep_Structure (Deep Structure)

2. Actual Response (Type created for method CREATE_DEEP_ENTITY)

Req_field1

Req_field2

Req_Deep_Structure

Res_Tab1

Res_Tab2

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

Req_field1

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_field1

Req_field2

Req_Deep_Structure

Req_Deep_Structure-field1

Req_Deep_Structure-field2

Req_Deep_Structure-field_table(flat structure)

Res_Deep_structure

Res_Deep_Structure-field1

Res_Deep_Structure-field2

Res_Deep_Structure-Deep_structure

Deep_structure-field1

Deep_structure-field2

Deep_structure-Deeper_structure

Deeper_structure-field1

Deeper_structure-field2

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)

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Apr 26 at 07:19 AM

    Hi,

    i do not understand your

    Req_field1
    
    Req_field2

    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 ).
     WHEN OTHERS.
     ENDCASE.
     IF er_deep_entity IS INITIAL. "Aka creation failed
          RAISE EXCEPTION TYPE /iwbep/cx_mgw_tech_exception.
     ENDIF.
    ENDMETHOD.

    And in my CREATE_DEEP_PIR, if everything has gone right

    copy_data_to_ref(
     EXPORTING
     is_data = deeppir
     CHANGING
     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.

    Add comment
    10|10000 characters needed characters exceeded

    • 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.