Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
20,588

Hi everyone,

Below example shows how to pass multiple nested tables as input to odata/gateway service using SEGW approach.

We have  6 tables.


1.      Header (Fields: ID, Name, Message_text)

    • Item1 (Fields: ID, Name1, Address)
      • Item 1.1 (Fields: ID, Name, State, Country)
      • Item 1.2 (Fields: Fname, Mname, LName)
    • Item2 (Fields: ID, Name, City)
      • Item2.1 (Fields: ID,Name,Pincode,Street)


Item1 and item2 are inline to Header table.

Item1.1 and item 1.2 are inline to item1 table.

Item 2.1 is inline to item 2 table

In multi deep insert, we should be able to pass multiple line items in item1 , item 1.1 , item 1.2, item 2 and  item2.1 along with the data in header structure.

  1. e.g.

Input to the service:

   


Output from the service:



Value of Message_text in header structure is changed to
Test1.


Steps to achieve the above scenario:

Step1. Create 6 entity types Header, Item1 and item2,Item1_1,Item1_2,Item2_1.

                  

     

Properties are:

Header:

Item1:

Item1_1:

Item1_2:

Item2:

Item2_1:

*************************************************************************************************************************************************************

Step2. Create entity sets HeaderSet, item1Set, item2Set,item1_1Set,item1_2Set,item2_1Set.

*************************************************************************************************************************************************************

Step3: Create Associations between entity types:


1. Header – item1

2. Header – item2

3. Item1--Item1.1

4. Item1--item1.2

5. Item2--Item2.1

      

Navigation properties get created automatically under entity type: header , Item1 and Item2

       

*************************************************************************************************************************************************************

Step4: Save and Check for any error.

Step5: Generate Runtime classes and Services

Step6: Register Service in gateway hub.

Step7: Go to DPC_Ext class in ABAP Workbench.

Step8: Redefine method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_EXPANDED_ENTITYSET –

This method is redefined to get Request payload of Multi deep insert.

Step9: Inside GET_EXPANDED_ENTITYSET,

ITEM1TOITEM1_1 and ITEM1TOITEM1_2 are names of navigation properties for table item1


ITEM2TOITEM2_1 IS navigation property for table item2


HEADERITEM1 and HEADERITEM2 are navigation properties for table header

Insert data in the Structures.

Add 3 entries in table et_expanded_tech_clause to specify to framework that there are  inline entities to the base entity(values to be inserted are Navigation properties).(Absence of this code will hit the get_expanded_entityset method 6 times for all the entities created.


Insert data in the respective structures and tables(header,item1 and item2,item1.1,item1.2,item2.1) and Append that data in the final


Save and Activate.

Step 10: Form the URL.

HTTP method : GET

Execute (F8).

******************************************************************************************************************************************************

Step11: Use the response from the above request to create request payload of Multi Deep Insert.

(Remove feed tag below first line and end feed tag)

Step12: Once Request payload is generated, redefine method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_DEEP_ENTITY

Inside /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_DEEP_ENTITY,

Declare the output structure.

Read the data sent by the user through request payload into structure ls_headeritem.

Change the message_text of Header structure .

ls_headeritem-message_text = 'Test1'.

Call Copy_data_to_ref and pass ls_header_item as structure.

Step 13: Form the URL.

URL:

/sap/opu/odata/sap/ZGW_CREATEDEEP_66883_SRV/headerSet


Method: POST.

Execute (F8).

This way we can implement such scenarios.

Thanks,

Anjor Wagle.





9 Comments
Labels in this area