cancel
Showing results for 
Search instead for 
Did you mean: 

Create_deep_entity

former_member220853
Participant
0 Kudos

Dear All

I want to understand which calls are executed by run time artifacts and in what order

I am trying to test my service

and I get 500 error stating 'SOItem' already exists

<?xml version="1.0" encoding="utf-8" ?>

<code>/IWFND/CM_MGW/012</code>

<message xml:lang="en">Data Object name: 'SOItem' already exists.</message>

- <innererror>

<transactionid>3837C3E2307FF1BF95714437E648951E</transactionid>

<errordetails />

</innererror>

</error>

The way I was running and testing it was

/sap/opu/odata/sap/Z_SALES_SRV/?$format=xml

But when I removed create_deep_entity it started working

Now question is when is create_deep_entity invoked

I  understand that only this method can create or  help in returning hierarchical structure

How do i invoke from URI so that all parent and thieir children gets rendered

and How do I sen argument as well to get children of a particular parent

Any help is highly appreciated

Accepted Solutions (1)

Accepted Solutions (1)

jibin_joy
Contributor
0 Kudos
former_member220853
Participant
0 Kudos

Thanks for reply Jibin

create_deep_entity is called by frameowrk so we do not know when and how will it get invoked

Our requireement is that execute_action method forms that relationship of parent and child and returns the result back

So far I have not been able to get this working. The document mentioned here is obsolete and does not tell when create_deep_entity will be invoked.

There should be some way to get the return data from excuteaction in hierarchical (parent-child format) but doing research so far I have not got any success

Best regards

Gaurav

kammaje_cis
Active Contributor
0 Kudos

Gaurav,

"execute_action" cannot take any request body (to hold parent and children), hence you cannot perform deep insert. It only takes URI parameters.

If you want to create parent and children, you need to use a POST request. If your request's body contains children as well (in addition to parent), then create_deep_entity will be called.

Thanks

Krishna

former_member220853
Participant
0 Kudos

Thanks Krishna I awarded you points

Dear Experts

if we have a scenario like this

We need to return all request and their item details as a nexted tree structure in OData Service

We cannot do that . (I have not seen any guide or example doing the same, documentation is pretty limited )

If that is the case, then it is a big limitation as we encounter this need every now and then

We have to convert our existing architecture which takes care of tree structure very well using json deserialzer and serializer on recommendation of some  Architects.

And if OData Service cannot do the same , then we have to pretty much re-invent the wheel for each parent call odata service then each child call another call for odata service

Thats pretty time consuming and depressing

kammaje_cis
Active Contributor
0 Kudos

Gaurav,

Deep insert: To create parent with the children.

$expand: To query parent with the children.

If you want parent as well as the children, you need to do a $expand.

Here is the syntax for $expand.

http://www.odata.org/documentation/odata-v2-documentation/uri-conventions/#46_Expand_System_Query_Op...

It also has example URIs.

Thanks

krishna

avishek_gorai2
Participant
0 Kudos

Hi Jibin,

This guide gives a coding approach to use create_deep_entity, how do we achieve the same using GW Service builder tool (SEGW). I'm willing to write the code to do this but not sure where to implement the create_deep_entity method, in the DPC class or DPC_EXT class? Please throw some light on this. Also need to understand how the update method will work if we want to update a field of the parent and child entity together.

Appreciate you inputs on this.

Regards,

Avishek.

jibin_joy
Contributor
0 Kudos

Hi Avishek ,

    

    Try to avoid Manuel changes in DPC class because  there is no use since this class will regenerated every time when we have re-generated our project  .

  Do changes in DPC_EXT. same for MPC and MPC_EXT Class.

Updating parent as well as child is not possible .... Alternative is to use Batch request  .

Regards,

Jibin Joy

avishek_gorai2
Participant
0 Kudos

Thanks Jibin, for your inputs. I have started two diffrent threads to discuss the issues of complex mapping using SEGW and mapping write opertions for complex entities. Please give some more inputs on these threads for a comprehensive discussion.

Former Member
0 Kudos

Hi Krishna,

I have redefined the CREATE_DEEP_ENTITY and also placed my logic inside.

I am using the following as my xml input to create a deep insert.

<?xml version="1.0" encoding="UTF-8"?>

<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

<atom:content type="application/xml">

<m:properties>

<d:PurGroup>AR1</d:PurGroup>

<d:PurchOrg>7500</d:PurchOrg>

<d:Vendor>0000100073</d:Vendor>

<d:SkipItemsWithError>X</d:SkipItemsWithError>

<d:DocType>NB</d:DocType>

<d:CoCode>7500</d:CoCode>

<d:PONumber>0</d:PONumber>

</m:properties>

</atom:content>

<atom:link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/POITEMS" type="application/atom+xml;type=feed" title="Z_PURCHASE_ORDER_SRV.PurchaseOrderHeader_PurchaseOrderItemCollection">

<m:inline>

<atom:feed>

<atom:entry>

<atom:content type="application/xml">

<m:properties>

   <d:Plant>7500</d:Plant>

   <d:PurMat>PAPEL</d:PurMat>

   <d:Material>PAPEL</d:Material>

   <d:PoItem>00001</d:PoItem>

   <d:PoNumber>0</d:PoNumber>

</m:properties>

</atom:content>

</atom:entry>

<atom:entry>

<atom:content type="application/xml">

<m:properties>

   <d:Plant>7500</d:Plant>

   <d:PurMat>100-100</d:PurMat>

   <d:Material>100-100</d:Material>

   <d:PoItem>00002</d:PoItem>

   <d:PoNumber>0</d:PoNumber>

</m:properties>

</atom:content>

</atom:entry>

</atom:feed>

</m:inline>

</atom:link>

</atom:entry>

I am getting the following error response.

<?xml version="1.0" encoding="utf-8" ?> 

- <error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code>SY/530</code> 
<message xml:lang="en">Method 'POHEADERCOL_CREATE_ENTITY' not implemented in data provider class.</message> 
- <innererror>
<transactionid>731124E3124BF17B9701000FFE22BF13</transactionid> 
- <errordetails>
- <errordetail>
<code>/IWBEP/CX_MGW_NOT_IMPL_EXC</code> 
<message>Method 'POHEADERCOL_CREATE_ENTITY' not implemented in data provider class.</message> 
<propertyref /> 
<severity>error</severity> 

</errordetail>

</errordetails>

</innererror>

</error>

It is not reaching my CREATE_DEEP_ENTITY method instead it is going to create_entity method.

Pls help

jibin_joy
Contributor
0 Kudos

Hi ,

 

  Just redefine method "POHEADERCOL_CREATE_ENTITY" in  data provider extension class.

Regards,

Jibin Joy

Former Member
0 Kudos

Hi Jibin,

I am attempting a 'CREATE DEEP INSERT' so I think the control should go to CREATE_DEEP_ENTITY method of the DPC_EXT class rather than POHEADERCOL_CREATE_ENTITY.

jibin_joy
Contributor
0 Kudos

Hi Stanley,

  

  We have to just re-define the create entity during deep entity also .

  But dont know the actual reason to redefine this methods.

Regards,

Jibin Joy

Former Member
0 Kudos

Hi Jibin,

I have figured it out.

You don't need to re-define the create entity for create_deep_insert. It is dependent on the navigation property that you specify in URL within the html body.

<atom:link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/POITEMS"type="application/atom+xml;type=feed"title="Z_PURCHASE_ORDER_SRV.PurchaseOrderHeader_PurchaseOrderItemCollection">

The underlined keyword 'POITEMS' should be the navigation property name defined for the entity set.

Thanks

Stan

jibin_joy
Contributor
0 Kudos

Hi Stanley,

Thanks For information

Regards,

Jibin Joy

Former Member
0 Kudos

Hi Stanley,

I also have the same problem as you

http://scn.sap.com/thread/3424594

after I changed navigation property as what you said,

it goes to create_deep_insert method now

but now I have different problem, they don't recognize the child

I am thinking because of the following command

title="Z_PURCHASE_ORDER_SRV.PurchaseOrderHeader_PurchaseOrderItemCollection">

what is 'PurchaseOrderHeader_PurchaseOrderItemCollection' ?

is that your association's name ?

Thank You,

-Martin-

kammaje_cis
Active Contributor
0 Kudos

HI Martin, That was interesting. So what did you change to make it go to Deep_insert method? Can you please  explain a little more.?

Former Member
0 Kudos

Hi Krishna,

I was following on what Stanley said that the URL below in HTML body

<atom:link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/POITEMS"


'POITEMS' - has to be navigation property's name of POHeader entity set.

I updated mine and it went to 'create_deep_insert' method now.

but i still have a problem because they don't recognize the child.

the system only gets header information from my XML.

i don't know what is the problem with my XML.

I am thinking maybe because of the following command

title="Z_PURCHASE_ORDER_SRV.PurchaseOrderHeader_PurchaseOrderItemCollection">

I don't know what is 'PurchaseOrderHeader_PurchaseOrderItemCollection' referring to ?

I am thinking maybe association's name ?

even though it is yes, i still have the same problem.

Thank You,

-Martin Darmawi-

kammaje_cis
Active Contributor
0 Kudos

Hi Martin,

I see that you are hand coding the request body of deep insert. It is a very tedious way.

There is an easy way.

Execute a query on parent and do a $expand on the child. Gateway framework provides a default implementation of $expand so you do not have to code anything special for it.

The result can be copied as the body of your deep insert. Just change the values of various properties.

I never encountered any such problems so far.

Thanks

Krishna

Former Member
0 Kudos

Hi Martin,

You must have defined the structure of child entity within the method 'create_deep_entity'. Make sure the name of the structure declared for the child entity is the same as 'entity type' name defined in the model.

Please have a look at the screenshots.

PurchaseOrderItem and PurchaseOrderSched are the child entities.

I also had the same issue, but when I replaced the name of the structure as shown above it worked.

Let me know if it works for you as well.

Thanks

Stanley

Former Member
0 Kudos

Hi Stanley,

Thanks for your reply. appreciate your input.

Unfortunately, it still does not work.

Basically - i can see 'correct' structure of ls_data that has parent and child.

but i don't still understand why they don't pick up the child information.

Did you do anything else to fix your problem before ?

otherwise if you don't mind - could you please share your metadata and your XML request ?

you also can send to my email address : mdarmawi@gmail.com

so I can check my data model.

Thank You very much.

-Martin-

cgovind
Advisor
Advisor
0 Kudos

Is it possible to separate the creation of Parent and Child ( association entities ). What I mean by this is, can we first just create the Parent entity through the create entity and then call the service only to create the child entity?

former_member220853
Participant
0 Kudos

It is possible

cgovind
Advisor
Advisor
0 Kudos

Hi Gaurav,

Can you advise how do I perform a POST operation on the association entity directly. I have mapped a API to the Create entity of the association. Hence, I expect the Create entity method of the DPC class to be triggered when I directly post the record on the association entity. Could you kindly share the URL?

Thanks,

Chakram Govindarajan

Answers (1)

Answers (1)

kammaje_cis
Active Contributor
0 Kudos

Hi Gaurav,

Create deep entity method is called whenever your payload of the post request contains inline entries. I.e. It contains parent as well as child entities.

Thanks

Krishna