cancel
Showing results for 
Search instead for 
Did you mean: 

How to use POST method in URL with $Expand

0 Kudos

Hi

I want to do the POST for Gateway Service URL.  ( but it with $Expand addition)

The URL works correctly for GET method.

URL looks like this

http://XXX.XX:500/sap/opu/odata/sap/ZTEST_ORDER_SRV/ORDDetail(Userid='xyz',WorkType='36') ?$expand =ORDPerset,ORDHistorySet.

This works fine for GET method which gives multiple records for in Parts entity set (ORDPartset ), History Entity set (ORDHistoryset).

Work type is the key field for Parts entity set (ORDPartset ), History Entity set (ORDHistoryset) .

Requirement: If I use POST method and Pass worktype as '37', then it should be updated in these Parts entity set (ORDPartset ), History Entity set (ORDHistoryset) .

(Parts entity set (ORDPartset ), History Entity set (ORDHistoryset) is related to separate  custom tables.

So finally entityset will update these custom tables)

So please let me know how to use the POST method in this case.

Thanks,

Shreedhar Gangadhar

Accepted Solutions (0)

Answers (2)

Answers (2)

AshwinDutt
Active Contributor
0 Kudos

Hello Shree,

Through $expand you cannot perform POST operation having Deep Structure ( Header & Item Relation ).

You need to implement appropriate logic Create_Deep_entity Method in DPC_EXT class and then send your Header and Child Items as part of PAYLOAD in POST operation.

For this you need to Model your GW Service by creating Association and Navigation between the Header and Item Entities with correct cardinality.

Refer this and you should be able to POST both Header and Items in one go ->

Regards,

Ashwin

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos


Hi Shreedhar,

you have to use deep insert.

For this you have to implement the method /iwbep/if_mgw_appl_srv_runtime~create_deep_entity.

Using the SAP Gateway client you can first retrieve a result via expand as you have shown and use the payload using the "use as request" option to perform a POST that will trigger the deep insert method.

Regards,

Andre