on 07-07-2015 10:46 AM
Hi techies,
I'm currently working on sales order creation using the odata service I created.
(I have a working Sales order get list(GET_ENTITYSET) and Sales order get details(GET_ENTITY) of sales order..)
Yes, I am well aware 'for creating of sales order' we just redefine the CREATE_ENTITY.
but here I will have to go for 'CREATE_DEEP_ENTITY'(as here its sales order header with line items)
and I HAVE also CREATE A NAVIGATIOIN PROPERTY (ItemsNavig) THAT FETCHES BOTH HEADER AND ITEMS DATA...
Problem:
,so I have a the expansion of sales order and relative line items working, now if i click on 'USE AS REUEST' making http response as a http request, If sales order has two line items and i want to create just one line item instead of two line items then its problem...
Note: I am confused in deep insert as well (CREATE_DEEP_ENTITY).
please correct me if i went wrong on any line.
Thanks ,
Regards,
Pavan G
Message was edited by: Vishal Sikka
Hi pavan,
Deep insert allows you to create a header and multiple items in a single payload. For example, take your Header entity set name is "MyHeaderSet" and Items as "MyItemsSet". Your navigation to header to item as "myNavToItem".
So your payload for the deep insert would be like
{
Header1 : "Value',
Header2: "Value",
MyItemsSet : [
{ item entity},
{ item entity},
]
}
.
the POST url should be "/HeaderSet" ..
more info
http://help.sap.com/saphelp_nw74/helpdata/en/11/a426519eff236ee10000000a445394/content.htm
Sree
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for quick reply.. and ya, i had already went through the above provided links was wondering why we have to redefine so many methods ??
Why not just redefine the "create_deep_entity one"
please correct me if I m wrong...
-Pavan Golesar
You just redefine only CREATE_DEEP_ENTITY. Others are not required to be re defined. But the goodness of re defining others are , you can easily get the request payload structure easily with some sample data. When i write, i used to redefine GET_ENTITY, GET_ENTITYSET etc, so that i can trigger the navigation call and retrieve the payload.
Sree
Hi Pavan,
Yes, you can only redefine 'CREATE_DEEP_ENTITY' method. The other redefinitions given in that link are used to define the data type. You can define the deep data type in deep_entity method ABAP Code itself. It would be like:
TYPES: BEGIN OF ty_deep.
INCLUDE TYPE zcl_zgw_so_srv_mpc=>ts_SOHeader.
TYPES: NavHeaderToItem TYPE ty_t_item,
END OF ty_deep.
PS:
Regards,
Ekansh
yes sree,
Sreehari V Pillai wrote:
You just redefine only CREATE_DEEP_ENTITY. Others are not required to be re defined. But the goodness of re defining others are , you can easily get the request payload structure easily with some sample data. When i write, i used to redefine GET_ENTITY, GET_ENTITYSET etc, so that i can trigger the navigation call and retrieve the payload.
Sree
I do have association created with navigation property as 'ItemsNavig' and also redefine the method of get entity and get entityset...
can you put some light how can get the job done with the get expanded entity..???
Okk, so can I say 'we simply get the navigation property working' and the HTTP response of get_expanded_entity for 'use as request ' (change the http request as per requirement )and use 'post' method ..???? Is it correct way?? (assuming that the create deep entity is redifine)
Ashwin Dutt R wrote:
Create_Entity is for flat structures and Create_Deep_Entity is for Deep Structures.
Regards,
Ashwin
Hello Pavan,
Payload can be created manually as well. Its easy in JSON Format.
You need not to depend always on Expand_Entity_Set or Expand_Entity operation to generate payload. Just to test you can create manually as well.
pass Header,
Content-Type - application/json
Sample ->
{
"Id":"01",
"Name":"Ashwin",
"Name2":"Dutt",
"HeaderItemO":[ {"IdO":"10","NameO":"TestO1"},
{"IdO":"20","NameO":"TestO2"} ],
"HeaderItemT":[ {"IdT":"10","NameT":"TestT1"},
{"IdT":"20","NameT":"TestT2"} ]
}
Where HeaderItemO and HeaderItemT are navigation properties define in the GW model between Parent and Child Entities.
Regards,
Ashwin
Step A :
if you implement GET_ENTITY of "MYHeader" , GET_ENTITYSET of "MyItems1" & "MyItems2" and GET_ENTITY of "MyItems3" you are ready to execute all the above navigation. So your output structure of call "/MyHeader('KeyValue')?$expand=Nav1,Nav2,Nav3" would be as below .
{
MyHeaderCol1 : "Value" ,
MyHeaderCol2 : "Value",
MyHeaderCol3 : "Value",
Nav1 : [
{ //MyItems1 entity } ...
] ,
Nav2 : [
{ //MyItems2 entity } ...
] ,
Nav3 : {
//MyItems3 entity
}
}
Post this payload to "/MyHeader" . It will hit your CREATE_DEEP_ENTITY.
once its hit, you can delete the redefinition made in step A.
Sreehari.
SO HERE BELOW I HAVE A NAVIGATION PROPERTY NAME AS: ItemsNavig
and sales order items name as: "SalesOrderItem"...
So its wrong ..... I need to recreate the navigation property name as "SalesOrderItem"... is that what you suggest in this case.??????????
Thanks,
Pavan Golesar
Hello Ashwin Dutt R,
I found recreate navigation property a quick task.. hey hope I am going right way......
I meant in SEGW any property name ( be it Navigation Property/ Entity Type/ Entity Names and other properties ) defined should be unique.
For Create_Deep_entity, in DPC_EXT class while defining Deep Structure, name used to define the Item table should be same as the Navigation Property defined in the GW Model in SEGW.
Hope its clear now.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.