on 08-20-2014 5:18 AM
Hi,
I know that this Topic was raised million times, but still raising this query. I have already consulted http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e0d92637-3d0d-2f10-ebb2-efc1f40a8... link.
Requirement: Create Header and Item Odata THROUGH SEGW.
Steps I have followed:
1. Created Header and Item Structure and have added them in the Export Parameters of an RFC.
2. Created the RFC and have populated the the internal tables corresponding to the Header and Item structures.
3. Go to Transaction SEGW and Imported the Header from the RFC. Then created Read and Query mapping for Header.
4. Go to Transaction SEGW and Imported the Item from the RFC. Then created Read and Query mapping for Item.
5. Created an association between "ID" of Header with "ID" of Item. Cardinality- 1:N
Observation:
Now when I run the Odata and execute /sap/opu/odata/sap/ZTEST_SRV/HDRSet(2)/ITEMSet, I get all the Items from the Item table for Each and every Header. But I guess for every header corresponding Items should have been enlisted.
Is there any step that I am missing?
Important: In the MPC class(ZCL_TEST_MPC), I could see a method named DEFINE_ASSOCIATION. I have put an external Breakpoint in it, but this breakpoint is not triggered.
-Regards
Dhrubajyoti
Hello Rakshit,
Usually we pass Header value and expect header & only its item data to be shown in the GW response. For that,
Create association and Navigation between Header & Item Entities ( 1 to N ).
Implement Get_Expand_Entity and call the logic accordingly inside it.
Create a deep structure which can hold the response and send it back to GW with also sending proper expand clause values ( i.e., your navigation properties ).
Example URL : https://<server>:<port>/.../<service_name>/SalesOrders(SalesorderNum='<your sales order number value>')?$expand=SalesOrderItems
Same way if at all if u have a BE logic to get all the headers and their items data, then approach would be,
Create association and Navigation between Header & Item Entities ( N to N ), as you need to get multiple Headers and their corresponding Items Data.
Implement Get_Expand_EntitySet and call logic inside it.
Create a deep structure which can hold the response and send it back to GW with also sending proper expand clause values ( i.e., your navigation properties ).
Example URL : https://<server>:<port>/.../<service_name>/SalesOrders?$expand=SalesOrderItems
Regards,
Ashwin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
/sap/opu/odata/sap/ZTEST_SRV/HDRSet?$expand=ITEMSet or
/sap/opu/odata/sap/ZTEST_SRV/HDRSet(1)?$expand=ITEMSet
But I have not Implemented EXPANDED ENTITY SET
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hii Dhru,
In addition to the steps followed, you have to create navigation property using association created.
You have to implement Get_expand_entityset method in DPC method for multiple headers and corresponding items and for single header and corresponding items you have to implement GET_EXPANDENTITY method.
The URL is as format below :
/sap/opu/odata/sap/<service name>/<Header entity set>/?$expand=<navigation property from header to item>&$filter= eq '<ID>' '<value>'
Example URL : https://<server>:<port>/.../<service_name>/SalesOrders?$expand=SalesOrderItems
For reference :
https://help.sap.com/saphelp_gateway20sp08/helpdata/en/ca/c683e803494b77a2e1290b987556e2/content.htm
For get_expanded_entity_set method implementation please refer the below URL
http://scn.sap.com/community/gateway/blog/2014/07/18/implementing-expand-entityentity-set
Regards,
Lokeswar Reddy byni.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
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.