Skip to Content

Create_deep_entity issue

Hi Experts,

I am creating a deep entity with one header and 4 items. I am using postman rest client in chrome browser. I am fetching the data by GET method and the URL for GET method is http://hostname:port/sap/opu/odata/sap/ZSALESORDER_SRV/SO_HEADERS?$filter=SO_ID eq '0000004970' &$expand=SO_ITEMSet , i have copied the response along with x-csrf token and replacing the token with its value and content-type = application/atom+xml. Now changing the method to POST and in the request body i have paste the code as below.


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

<feed xml:base="http://hostname:portname/sap/opu/odata/sap/ZSALESORDER_SRV/"

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">

<id>http://hostname:portname/sap/opu/odata/sap/ZSALESORDER_SRV/SO_HEADERS</id>

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

<updated>2015-07-21T06:46:49Z</updated>

  <author>

  <name/>

  </author>

  <link href="SO_HEADERS" rel="self" title="SO_HEADERS"/>

  <entry>

<id>http://hostname:portname/sap/opu/odata/sap/ZSALESORDER_SRV/SO_HEADERS('4970')</id>

  <title type="text">SO_HEADERS('4970')</title>

<updated>2015-07-21T06:46:49Z</updated>

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

  <link href="SO_HEADERS('4970')" rel="edit" title="SO_HEADER"/>

  <link href="SO_HEADERS('4970')/SO_ITEMSet" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/SO_ITEMSet" type="application/atom+xml;type=feed" title="SO_ITEMSet">

<m:inline>

<feed xml:base="http://hostname:portname/sap/opu/odata/sap/ZSALESORDER_SRV/">

<id>http://hostname:portname/sap/opu/odata/sap/ZSALESORDER_SRV/SO_HEADERS('4970')/SO_ITEMSet</id>

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

<updated>2015-07-21T06:46:49Z</updated>

<author>

<name/>

</author>

<link href="SO_HEADERS('4970')/SO_ITEMSet" rel="self" title="SO_ITEMS"/>

<entry>

  <id>http://hostname:portname/sap/opu/odata/sap/ZSALESORDER_SRV/SO_ITEMS(SO_ID='4970',ITEM_NO='000010')</id>

<title type="text">SO_ITEMS(SO_ID='4970',ITEM_NO='000010')</title>

<updated>2015-07-21T06:46:49Z</updated>

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

<link href="SO_ITEMS(SO_ID='4970',ITEM_NO='000010')" rel="edit" title="SO_ITEM"/>

<content type="application/xml">

<m:properties>

<d:SO_ID>0</d:SO_ID>

<d:ITEM_NO>10</d:ITEM_NO>

<d:MAT_NO>100-100</d:MAT_NO>

<d:PLANT>1000</d:PLANT>

<d:TARGET_QTY>4</d:TARGET_QTY>

<d:TARGET_QU>ST</d:TARGET_QU>

<d:ITEM_CATEG>TAN</d:ITEM_CATEG>

<d:PURCH_NO_C>TEST ORDER</d:PURCH_NO_C>

<d:PURCH_DATE>20150728</d:PURCH_DATE>

<d:INCOTERMS1>CIP</d:INCOTERMS1>

<d:INCOTERMS2>Nürnberg</d:INCOTERMS2>

<d:PMNTTRMS>ZB01</d:PMNTTRMS>

<d:PRICE_DATE>20150721</d:PRICE_DATE>

<d:SALES_UNIT>ST</d:SALES_UNIT>

<d:DIVISION>00</d:DIVISION>

<d:CURRENCY>EUR</d:CURRENCY>

</m:properties>

</content>

</entry>

<entry>

  <id>http://hostname:portname/sap/opu/odata/sap/ZSALESORDER_SRV/SO_ITEMS(SO_ID='4970',ITEM_NO='000020')</id>

<title type="text">SO_ITEMS(SO_ID='4970',ITEM_NO='000020')</title>

<updated>2015-07-21T06:46:49Z</updated>

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

<link href="SO_ITEMS(SO_ID='4970',ITEM_NO='000020')" rel="edit" title="SO_ITEM"/>

<content type="application/xml">

<m:properties>

<d:SO_ID>0</d:SO_ID>

<d:ITEM_NO>20</d:ITEM_NO>

<d:MAT_NO>100-100</d:MAT_NO>

<d:PLANT>1000</d:PLANT>

<d:TARGET_QTY>3</d:TARGET_QTY>

<d:TARGET_QU>ST</d:TARGET_QU>

<d:ITEM_CATEG>TAN</d:ITEM_CATEG>

<d:PURCH_NO_C>TEST ORDER</d:PURCH_NO_C>

<d:PURCH_DATE>20150728</d:PURCH_DATE>

<d:INCOTERMS1>CIP</d:INCOTERMS1>

<d:INCOTERMS2>Nürnberg</d:INCOTERMS2>

<d:PMNTTRMS>ZB01</d:PMNTTRMS>

<d:PRICE_DATE>20150721</d:PRICE_DATE>

<d:SALES_UNIT>ST</d:SALES_UNIT>

<d:DIVISION>00</d:DIVISION>

<d:CURRENCY>EUR</d:CURRENCY>

</m:properties>

</content>

</entry>

<entry>

  <id>http://hostname:portname/sap/opu/odata/sap/ZSALESORDER_SRV/SO_ITEMS(SO_ID='4970',ITEM_NO='000030')</id>

<title type="text">SO_ITEMS(SO_ID='4970',ITEM_NO='000030')</title>

<updated>2015-07-21T06:46:49Z</updated>

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

<link href="SO_ITEMS(SO_ID='4970',ITEM_NO='000030')" rel="edit" title="SO_ITEM"/>

<content type="application/xml">

<m:properties>

<d:SO_ID>0</d:SO_ID>

<d:ITEM_NO>30</d:ITEM_NO>

<d:MAT_NO>100-100</d:MAT_NO>

<d:PLANT>1000</d:PLANT>

<d:TARGET_QTY>2</d:TARGET_QTY>

<d:TARGET_QU>ST</d:TARGET_QU>

<d:ITEM_CATEG>TAN</d:ITEM_CATEG>

<d:PURCH_NO_C>TEST ORDER</d:PURCH_NO_C>

<d:PURCH_DATE>20150728</d:PURCH_DATE>

<d:INCOTERMS1>CIP</d:INCOTERMS1>

<d:INCOTERMS2>Nürnberg</d:INCOTERMS2>

<d:PMNTTRMS>ZB01</d:PMNTTRMS>

<d:PRICE_DATE>20150721</d:PRICE_DATE>

<d:SALES_UNIT>ST</d:SALES_UNIT>

<d:DIVISION>00</d:DIVISION>

<d:CURRENCY>EUR</d:CURRENCY>

</m:properties>

</content>

</entry>

<entry>

  <id>http://hostname:portname/sap/opu/odata/sap/ZSALESORDER_SRV/SO_ITEMS(SO_ID='4970',ITEM_NO='000040')</id>

<title type="text">SO_ITEMS(SO_ID='4970',ITEM_NO='000040')</title>

<updated>2015-07-21T06:46:49Z</updated>

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

<link href="SO_ITEMS(SO_ID='4970',ITEM_NO='000040')" rel="edit" title="SO_ITEM"/>

<content type="application/xml">

<m:properties>

<d:SO_ID>0</d:SO_ID>

<d:ITEM_NO>40</d:ITEM_NO>

<d:MAT_NO>100-100</d:MAT_NO>

<d:PLANT>1000</d:PLANT>

<d:TARGET_QTY>1</d:TARGET_QTY>

<d:TARGET_QU>ST</d:TARGET_QU>

<d:ITEM_CATEG>TAN</d:ITEM_CATEG>

<d:PURCH_NO_C>TEST ORDER</d:PURCH_NO_C>

<d:PURCH_DATE>20150728</d:PURCH_DATE>

<d:INCOTERMS1>CIP</d:INCOTERMS1>

<d:INCOTERMS2>Nürnberg</d:INCOTERMS2>

<d:PMNTTRMS>ZB01</d:PMNTTRMS>

<d:PRICE_DATE>20150721</d:PRICE_DATE>

<d:SALES_UNIT>ST</d:SALES_UNIT>

<d:DIVISION>00</d:DIVISION>

<d:CURRENCY>EUR</d:CURRENCY>

</m:properties>

</content>

</entry>

</feed>

</m:inline>

  </link>

  <link href="SO_HEADERS('4970')/$links/SO_ITEMSet" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/SO_ITEMSet" type="application/xml" title="SO_ITEMSet"/>

  <content type="application/xml">

<m:properties>

<d:SO_ID>0</d:SO_ID>

<d:CURRENCY>EUR</d:CURRENCY>

<d:DOC_TYPE>OR</d:DOC_TYPE>

<d:DOC_DATE>20150721</d:DOC_DATE>

<d:SALES_ORG>1000</d:SALES_ORG>

<d:DIST_CHANNEL>10</d:DIST_CHANNEL>

<d:DIVISION>00</d:DIVISION>

<d:SALES_GRP>130</d:SALES_GRP>

<d:SALES_OFF>1030</d:SALES_OFF>

<d:REQ_DATE_H m:null="true"/>

<d:PURCH_DATE m:null="true"/>

<d:INCOTERMS1>CIP</d:INCOTERMS1>

<d:INCOTERMS2>Nürnberg</d:INCOTERMS2>

<d:PMNTTRMS>ZB01</d:PMNTTRMS>

<d:PRICE_DATE>20150721</d:PRICE_DATE>

<d:PURCH_NO_C>TEST ORDER</d:PURCH_NO_C>

</m:properties>

  </content>

  </entry>

</feed>

For POST method, the URL is http://hostname:port/sap/opu/odata/sap/ZSALESORDER_SRV/SO_HEADERS when i execute it the break point not triggered in the create_deep_entitty method and i am getting the error as


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

<error 
    xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
    <code>CX_ST_MATCH_ELEMENT/544FAE4641562346A1372144E7396586</code>
    <message xml:lang="en">System expected the element '{http://www.w3.org/2005/Atom}entry'</message>
    <innererror>
        <transactionid>5A7D2FE5FAE1F1609A3F005056BE7049</transactionid>
        <errordetails/>
    </innererror>
</error>

Please help me to resolve this issue.

Thanks,

Gowtham

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • avatar image
    Former Member
    Jul 21, 2015 at 09:21 AM

    Hello Raja,

    Problem with the Payload. Please check.

    Refer the below sample for your reference ->

    <?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:Id>100</d:Id>

    <d:Name>Test</d:Name>

    <d:Name2>Test Header2</d:Name2>

    </m:properties>

    </atom:content>

    <atom:link

    rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/HeaderItemO"

    type="application/atom+xml;type=feed"

    title="ZASH_TEST_FOR_PREP_DEMO_SRV.Header_ItemO">

    <m:inline>

    <atom:feed>

    <atom:entry>

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

    <m:properties>

    <d:IdO>10</d:IdO>

    <d:NameO>Test Item11</d:NameO>

    </m:properties>

    </atom:content>

    </atom:entry>

    <atom:entry>

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

    <m:properties>

    <d:IdO>20</d:IdO>

    <d:NameO>Test Item12</d:NameO>

    </m:properties>

    </atom:content>

    </atom:entry>

    </atom:feed>

    </m:inline>

    </atom:link>

    <atom:link

    rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/HeaderItemT"

    type="application/atom+xml;type=feed"

    title="ZASH_TEST_FOR_PREP_DEMO_SRV.Header_ItemT">

    <m:inline>

    <atom:feed>

    <atom:entry>

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

    <m:properties>

    <d:IdT>10</d:IdT>

    <d:NameT>Test Item21</d:NameT>

    </m:properties>

    </atom:content>

    </atom:entry>

    <atom:entry>

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

    <m:properties>

    <d:IdT>20</d:IdT>

    <d:NameT>Test Item22</d:NameT>

    </m:properties>

    </atom:content>

    </atom:entry>

    </atom:feed>

    </m:inline>

    </atom:link>

    </atom:entry>

    You can have JSON payload as well ->

    {

    "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 the navigation properties defined in GW Model.

    Regards,

    Ashwin

    Add comment
    10|10000 characters needed characters exceeded

    • Hello Gowtham,

                     OK, I PREASSUMED­čśł THAT THE PAYLOAD YOU HAD SHOWN IS A HTTP RESPONSE, SO I SUGGESTED FOR THE SAME ,


      ANYWAYS, DEAR PLEASE TRY FOR JSON ...



      Best Regards,

      Pavan Golesar

      Message was edited by: Pavan Golesar

  • Jul 21, 2015 at 09:23 AM

    Hello Gowtham,

        Looking at the Payload, it seem the Sales Order Document Number is Empty on HTTP Response..

    please verify the Mapping (As you are getting the item data, so it might be a issue of Mapping in SEGW..)

    Best Regards,

    Pavan Golesar

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 21, 2015 at 09:23 AM

    Gowtham,

    Gateway is failing to parse the XML. I would suggest to try with Json as it is very simple. Once you copy the $expand json response as request body, remove all the unnecessary  entries like associations, navigations etc.

    Add comment
    10|10000 characters needed characters exceeded

    • Gowtham Raja M Krishna Kishor Kammaje

      Krishna,

      I have gone to the blog written by you Troubleshooting a SAP Netweaver Gateway Service

      i have changed all the date field into abap internal type 'date', regenerated objects and clear cache... but i could not able to get the items data saved in to its deep structure ls_so-SO_Itemset......

      i not sure whether the request body is correct or not... but form the request body header details are working fine.

      {

               "SO_ID" : "0",

               "CURRENCY" : "EUR",

               "DOC_TYPE" : "TA",

               "DOC_DATE" : "2015-07-24T00:00:00",

               "SALES_ORG" : "1000",

               "DIST_CHANNEL" : "10",

               "DIVISION" : "00",

               "SALES_GRP" : "130",

               "SALES_OFF" : "1030",

               "REQ_DATE_H" : null,

               "PURCH_DATE" : null,

               "INCOTERMS1" : "CIP",

               "INCOTERMS2" : "Nürnberg",

               "PMNTTRMS" : "ZB01",

               "PRICE_DATE" : "2015-07-24T00:00:00",

               "PURCH_NO_C" : "test order",

               "SO_ITEMSet" : [

                   {

                     "SO_ID" : "0",

                     "ITEM_NO" : "000010",

                     "MAT_NO" : "100-100",

                     "PLANT" : "1000",

                     "TARGET_QTY" : "1",

                     "TARGET_QU" : "ST",

                     "ITEM_CATEG" : "TAN",

                     "PURCH_NO_C" : "test order",

                     "PURCH_DATE" : null,

                     "INCOTERMS1" : "CIP",

                     "INCOTERMS2" : "Nürnberg",

                     "PMNTTRMS" : "ZB01",

                     "PRICE_DATE" : "2015-07-24T00:00:00",

                     "SALES_UNIT" : "ST",

                     "DIVISION" : "00",

                     "CURRENCY" : "EUR"

                   }

                 ]

               }

      Please help.

  • Jul 22, 2015 at 09:26 AM

    Hi,

    I could able to create the header now but not item details. Please refer the below snap shots.

    I dont know why this deep structue so_items is empty or am i lagging anywhere?


    Debugger.jpg (400.9 kB)
    Debugger2.jpg (415.4 kB)
    soitems_empty.jpg (337.0 kB)
    Add comment
    10|10000 characters needed characters exceeded

  • Jul 23, 2015 at 06:10 AM

    Hi Experts,

    The issue not yet resolved. The input in postman rest client is in json format as

    {

                    "SO_ID": "0",

                    "CURRENCY": "EUR",

                    "DOC_TYPE": "TA",

                    "DOC_DATE": "2015-07-23T00:00:00",

                    "SALES_ORG": "1000",

                    "DIST_CHANNEL": "10",

                    "DIVISION": "00",

                    "SALES_GRP": "130",

                    "SALES_OFF": "1030",

                    "REQ_DATE_H": null,

                    "PURCH_DATE": null,

                    "INCOTERMS1": "CIP",

                    "INCOTERMS2": "Nürnberg",

                    "PMNTTRMS": "ZB01",

                    "PRICE_DATE": "2015-07-23T00:00:00",

                    "PURCH_NO_C": "TEST ORDER",

    "SO_ITEMSet":[{

                                "SO_ID": "0",

                                "ITEM_NO": "000010",

                                "MAT_NO": "100-100",

                                "PLANT": "1000",

                                "TARGET_QTY": "4",

                                "TARGET_QU": "ST",

                                "ITEM_CATEG": "TAN",

                                "PURCH_NO_C": "TEST ORDER",

                                "PURCH_DATE": "2015-07-23T00:00:00",

                                "INCOTERMS1": "CIP",

                                "INCOTERMS2": "Nürnberg",

                                "PMNTTRMS": "ZB01",

                                "PRICE_DATE": "2015-07-23T00:00:00",

                                "SALES_UNIT": "ST",

                                "DIVISION": "00",

                                "CURRENCY": "EUR"

    }]

    }

    When i start debugging, the header data alone displaying in its structure but the item details are empty as shown below

    My structure for ls_so is

    TYPES: ty_t_soitem TYPE STANDARD TABLE OF zcl_zsalesorder_mpc=>ts_so_item WITH DEFAULT KEY.

    * Represents full Sales Order structure - header with one of more items

    TYPES:  BEGIN OF ty_s_so.

                     INCLUDE TYPE zcl_zsalesorder_mpc=>ts_so_header.

                     TYPES: SO_ITEMSet TYPE ty_t_soitem,

                  END OF ty_s_so.

    DATA: ls_so type ty_s_so.

    My doubt is am i giving the correct json format for items in the browser input. if it is correct i dont why the item details alone is empty in the structure so_itemset.

    Please help me

    Thanks,

    Gowtham


    soitems_empty.jpg (138.2 kB)
    Add comment
    10|10000 characters needed characters exceeded