Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Deep Entity request Error, System expected the element '{http://www.w3.org/2005/Atom}entry'

k_sood
Active Participant

Hi All,

While doing a Post request from an external tool to the deep entity structure Odata Service, we are getting following error.

Post request is as follows: [This is not complete post Request, in order to localize the error, I am testing with minimum Request data.]

<?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:SalesOrg>1000</d:SalesOrg>
            <d:IvCrmKdNr>8107</d:IvCrmKdNr>
            <d:IvEshopAufnr>265667</d:IvEshopAufnr>
            <d:IvEshopKdnr>35545</d:IvEshopKdnr>
            <d:DocType>ZTA</d:DocType>
            <d:CollectNo>265667</d:CollectNo>
            <d:DistrChan>20</d:DistrChan>
            <d:Division>10</d:Division>
            <d:SalesGrp>D99</d:SalesGrp>
            <d:SalesOff>4030</d:SalesOff>
            <d:ReqDateH>2020-12-02T00:00:00</d:ReqDateH>
            <d:PurchDate>2020-10-19T00:00:00</d:PurchDate>
            <d:PoMethod>30</d:PoMethod>
            <d:Incoterms1>EXW</d:Incoterms1>
            <d:Incoterms2>Dietikon</d:Incoterms2>
            <d:Pmnttrms>ZB01</d:Pmnttrms>
            <d:OrdReason>005</d:OrdReason>
            <d:ShipCond>01</d:ShipCond>
        </m:properties>
    </atom:content>
</atom:entry>

During Debug , I found that the error is coming while Transforming the xml at the following location.

Error coming at the following location of the transformation .

It seems like something is missing in the atom entry tag , but dont know what exactly.

None of the existing refrences to this error have helped so far. Anyone having an Idea on how to resolve this error ?

Br,

Ketan

1 ACCEPTED SOLUTION

k_sood
Active Participant
0 Kudos

Problem is resolved, This failure is not coming anymore.

Solution : WHile making request from an External tool , the body has to be assigned to the variable M_INPUT.

Thanks evanireland and olegbash599 though for hints.

Br,

Ketan

15 REPLIES 15

evanireland
Advisor
Advisor
0 Kudos

Maybe try this (not to suggest that the content you provided looks wrong, but just in case it helps):

<entry xmlns="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"><content>...

k_sood
Active Participant
0 Kudos

Thanks for your reply , it did not help. still the same error is coming.

Anything else which could be tried ?

Br,

Ketan

evanireland
Advisor
Advisor
0 Kudos

If the backend supports OData JSON format, perhaps you could try that instead of Atom?

Can you share the metadata document?

0 Kudos

Alright Thanks. Will Try with Json Request.

.xml file is not permitted to upload here. Enclosed the txt file to view in notepad++ .

.metadata.txt

Thanks for having a look.

Br,

Ketan

evanireland
Advisor
Advisor
0 Kudos

Try like this (entry should have id, title and updated sub-elements)

<?xml version="1.0" encoding="utf-8"?> <entry xmlns="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" xmlns:g="http://www.opengis.net/gml"> <id>odata:new</id> <title type="text">Salesorder</title> <author> <name/> </author> <updated>2020-12-04T02:19:09.367Z</updated> <category scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" term="ZSD_SOCREATE_SRV.Salesorder"/> <content type="application/xml"> <m:properties> ... </m:properties> </content> </entry>

evanireland
Advisor
Advisor
0 Kudos

Repasting with "CODE" wrapper for better formatting:

<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="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" xmlns:g="http://www.opengis.net/gml">
    <id>odata:new</id>
    <title type="text">Salesorder</title>
    <author>
        <name/>
    </author>
    <updated>2020-12-04T02:19:09.367Z</updated>
    <category scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" term="ZSD_SOCREATE_SRV.Salesorder"/>
    <content type="application/xml">
        <m:properties>
            ...
        </m:properties>
    </content>
</entry>

k_sood
Active Participant
0 Kudos

Hi evanireland

Thanks for your reply. I have first tried this locally in SEGW and I am getting following Error .

This is actually True, I have Implemented this Deep Entity creation using the following link and there was no need to implement the create entity method .

Step by Step development for CREATE_DEEP_ENTITY operation | SAP Blogs

Thanks for any further help.

Input Request that I just Tried is as follows:

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

<entry xmlns="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" xmlns:g="http://www.opengis.net/gml">

    <id>odata:new</id>

    <title type="text">Salesorder</title>

    <author>

        <name/>

    </author>

    <updated>2020-12-14T02:19:09.367Z</updated>

    <category scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" term="ZSD_SOCREATE_SRV.Salesorder"/>

    <content type="application/xml">

        <m:properties>

            <d:SalesOrg>1000</d:SalesOrg>

            <d:IvCrmKdNr>8107</d:IvCrmKdNr>

            <d:IvEshopAufnr>265667</d:IvEshopAufnr>

            <d:IvEshopKdnr>35545</d:IvEshopKdnr>

            <d:DocType>ZTA</d:DocType>

            <d:CollectNo>265667</d:CollectNo>

            <d:DistrChan>20</d:DistrChan>

            <d:Division>10</d:Division>

            <d:SalesGrp>D99</d:SalesGrp>

            <d:SalesOff>4030</d:SalesOff>

            <d:ReqDateH>2020-12-02T00:00:00</d:ReqDateH>

            <d:PurchDate>2020-10-19T00:00:00</d:PurchDate>

            <d:PoMethod>30</d:PoMethod>

            <d:Incoterms1>EXW</d:Incoterms1>

            <d:Incoterms2>Dietikon</d:Incoterms2>

            <d:Pmnttrms>ZB01</d:Pmnttrms>

            <d:OrdReason>005</d:OrdReason>

            <d:ShipCond>01</d:ShipCond>

        </m:properties>

    </content>

</entry>

evanireland
Advisor
Advisor
0 Kudos

I am not familiar with the ABAP backend OData stuff, but I note that the blog you quoted also has a comment: "Call will go to Create_Deep_Entity method based on the association and navigation properties inside your payload.""

Your latest payload doesn't seem to have any inline child entities, so it isn't considered a "deep insert", so perhaps that's why it is trying to call SALESORDERSET_CREATE_ENTITY.

k_sood
Active Participant
0 Kudos

Hi evanireland ,

Thanks for your reply, I added one Navigation block and now the error is again the same as in the beginning. i.e. mentioned in the original Question . system expected the element.....

SALESORDERSET_CREATE_ENTITY Error is not coming now.

Previously this error was coming only while posting from External tool but now this Error is coming also while testing through SEGW .

Here is the new request.

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

<entry xmlns="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" xmlns:g="http://www.opengis.net/gml">

    <id>odata:new</id>

    <title type="text">Salesorder</title>

    <author>

        <name/>

    </author>

    <updated>2020-12-14T02:19:09.367Z</updated>

    <category scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" term="ZSD_SOCREATE_SRV.Salesorder"/>

    <content type="application/xml">

        <m:properties>

            <d:SalesOrg>1000</d:SalesOrg>

            <d:IvCrmKdNr>8107</d:IvCrmKdNr>

            <d:IvEshopAufnr>265667</d:IvEshopAufnr>

            <d:IvEshopKdnr>35545</d:IvEshopKdnr>

            <d:DocType>ZTA</d:DocType>

            <d:CollectNo>265667</d:CollectNo>

            <d:DistrChan>20</d:DistrChan>

            <d:Division>10</d:Division>

            <d:SalesGrp>D99</d:SalesGrp>

            <d:SalesOff>4030</d:SalesOff>

            <d:ReqDateH>2020-12-02T00:00:00</d:ReqDateH>

            <d:PurchDate>2020-10-19T00:00:00</d:PurchDate>

            <d:PoMethod>30</d:PoMethod>

            <d:Incoterms1>EXW</d:Incoterms1>

            <d:Incoterms2>Dietikon</d:Incoterms2>

            <d:Pmnttrms>ZB01</d:Pmnttrms>

            <d:OrdReason>005</d:OrdReason>

            <d:ShipCond>01</d:ShipCond>

        </m:properties>

    </content>

<atom:link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/SalesorderToHeaderinx" type="application/atom+xml;type=feed" title="ZSD_SOCREATE_SRV.Salesorder_Headerin">
    <m:inline>
     <atom:feed>
      <atom:entry>
        <atom:content type="application/xml">
          <m:properties>
            <d:DocType>X</d:DocType>
            <d:CollectNo>X</d:CollectNo>
            <d:SalesOrg>X</d:SalesOrg>
            <d:DistrChan>X</d:DistrChan>
            <d:Division>X</d:Division>
            <d:SalesGrp>X</d:SalesGrp>
            <d:SalesOff>X</d:SalesOff>
            <d:ReqDateH>X</d:ReqDateH>
            <d:PurchDate>X</d:PurchDate>
            <d:PoMethod>X</d:PoMethod>
            <d:Incoterms1>X</d:Incoterms1>
            <d:Incoterms2>X</d:Incoterms2>
            <d:Pmnttrms>X</d:Pmnttrms>
            <d:OrdReason>X</d:OrdReason>
            <d:ShipCond>X</d:ShipCond>
          </m:properties>
        </atom:content>
      </atom:entry>
     </atom:feed>
    </m:inline>
</atom:link>
</entry>

I also tried to give the type as -> type = "application/xml" instead of type="application/atom+xml

<atom:link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/SalesorderToHeaderinx" type="application/xml;type=feed" title="ZSD_SOCREATE_SRV.Salesorder_Headerin">

Br,

Ketan

olegbash599
Active Participant
0 Kudos

My recommendation is firstly implement reading with navigation (association) and then you will get deep entity structure in response.

After that you could use function "Use as a Request" and you could compare what is exactly is not the same.

k_sood
Active Participant
0 Kudos

Hi olegbash599 ,

I did a Get request in SEGW and then did a "use as request" . This is what i have as request now.

Now How do i use create a request.

<feed xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xml:base="http://server:8000/sap/opu/odata/SAP/ZSD_SOCREATE_SRV/">
 <id>http://server:8000/sap/opu/odata/SAP/ZSD_SOCREATE_SRV/SalesorderSet</id>
 <title type="text">SalesorderSet</title>
 <updated>2020-12-15T09:40:39Z</updated>
 <author>
  <name/>
 </author>
 <link href="SalesorderSet" rel="self" title="SalesorderSet"/>
</feed>

Br,

Ketan

0 Kudos

Do the request exact with navigation.

It seems you are doing request only to Get Entity Set, but not Get entity Set with navigation.

it should be like:

/sap/opu/odata/SAP/ZSD_SOCREATE_SRV/SalesorderSet('KEY1_HEAD')/SalesOrderItemsSet

k_sood
Active Participant
0 Kudos

Hi olegbash599 ,

I have implemented deep entity creation using the following blogand there is no Implementation about reading the entity with its child structure.

Step by Step development for CREATE_DEEP_ENTITY operation | SAP Blogs

Dont know what Key should I be giving here.

Br,

Ketan

k_sood
Active Participant
0 Kudos

Problem is resolved, This failure is not coming anymore.

Solution : WHile making request from an External tool , the body has to be assigned to the variable M_INPUT.

Thanks evanireland and olegbash599 though for hints.

Br,

Ketan

evanireland
Advisor
Advisor
0 Kudos

This:

<atom:link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/SalesorderToHeaderinx" type="application/atom+xml;type=feed" title="ZSD_SOCREATE_SRV.Salesorder_Headerin"><m:inline><atom:feed><atom:entry>

should perhaps be:

<atom:link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/SalesorderToHeaderinx" type="application/atom+xml;type=entry" title="ZSD_SOCREATE_SRV.Salesorder_Headerin"><m:inline><atom:entry>

(and remove the end tag for </atom:feed>)

Explanation: SalesorderToHeaderinx is a single-valued navigation property in your metadata, so should use an entry not encloded in a feed (A feed is used for collections).