cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a sales order using DEEP ENTITY for my Odata service

Pavan_Golesar
Active Participant

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

Accepted Solutions (1)

Accepted Solutions (1)

sreehari_vpillai
Active Contributor
0 Kudos

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

Pavan_Golesar
Active Participant
0 Kudos

hi Sreehari V Pillai,

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

sreehari_vpillai
Active Contributor
0 Kudos

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

AshwinDutt
Active Contributor
0 Kudos

Hello Pavan,

In the blog, DPC_EXT class has only one method Create_Deep_Entity which is redefined and other methods are are nor redefined and are grayed out.

Observe carefully.

Create_Entity is for flat structures and Create_Deep_Entity is for Deep Structures.

Regards,

Ashwin

EkanshCapgemini
Active Contributor
0 Kudos

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:

  1. I must say that the question is too COLORFUL .
  2. I just looked at the last line and could not stop grinning.

Regards,

Ekansh

Pavan_Golesar
Active Participant
0 Kudos

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

Pavan_Golesar
Active Participant
0 Kudos

     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

AshwinDutt
Active Contributor
0 Kudos

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

sreehari_vpillai
Active Contributor
0 Kudos

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.

AshwinDutt
Active Contributor
0 Kudos

Hello Pavan,

Yes its one of the way and should be able to trigger Deep Entity Method

Regards,

Ashwin

Pavan_Golesar
Active Participant
0 Kudos

Thanks alot.... quite simple and easy reply.. thanks.. now my query's solution is more clear ...

Regards,

Pavan G

Pavan_Golesar
Active Participant
0 Kudos

Hi Ekansh,

    Thanks for noticing. ... btw having implemented my CREATE_DEEP_ENTITY method, I am just having a query... are we suppose to keep the name of the navigation property same as the items table???

I mean the NavHeaderToItem .....

I mean

Regards,

Pavan G

AshwinDutt
Active Contributor
0 Kudos

Hello Pavan,

Yes it should be same.

Regards,

Ashwin

Pavan_Golesar
Active Participant
0 Kudos

Hi Ashwin Dutt R,


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

   

AshwinDutt
Active Contributor
0 Kudos

Hello Pavan,

Use ITEMSNAVIG as the name of the items table while declaring the deep structure in the Creatr_Deep_Entity.

Regards,

Ashwin

Pavan_Golesar
Active Participant
0 Kudos

Hello Ashwin Dutt R,



     I found recreate navigation property a quick task.. hey hope I am going right way......

Pavan_Golesar
Active Participant
0 Kudos

Hello Ashwin,

    do we have to keep the entityset name (for items) same same as the navigation property ..????

Regards,

Pavan Golesar

AshwinDutt
Active Contributor
0 Kudos

No, Navigation and EntitySet/EntityType names should be different.

Not only for this, It applies for every single property you define in GW Model in SEGW. Names should be Unique and should make sense.

Pavan_Golesar
Active Participant
0 Kudos

Hi Ashwin,


Ashwin Dutt R wrote:

Hello Pavan,

Yes it should be same.

Regards,

Ashwin

can you specify in which context you ment this.... I guess you were saying this with declaring the "deep structure" .....

Regards,

pavan golesar

AshwinDutt
Active Contributor
0 Kudos

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.

Answers (0)