on 07-21-2015 10:07 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Everything looks fine but still not sure why Item details are not read from payload.
Can you regenerate objects again and clear cache and test one more time ?
You can just try creating the whole thing again freshly ( Entities, Association and Navigation ) in a different project and add code and test again.
Hi Gowtham,
Can you try defining the deep structure in a different manner like this-
* Represents full Sales Order structure - header with one of more items
DATA: BEGIN OF ty_s_so.
INCLUDE TYPE zcl_zsalesorder_mpc=>ts_so_header.
DATA: SO_ITEMSet TYPE TABLE OF zcl_zsalesorder_mpc=>ts_so_item WITH DEFAULT KEY,
END OF ty_s_so.
DATA: ls_so TYPE ty_s_so.
It is not the best approach to declare structures, but it works for me. Also, try changing the cardinality of the header-to-item to 1-to-M.
Let me know if it still doesn't work.
Cheers,
-NK
Hi Gowtham,
Can you set an external debugger at the line
io_data_provider->read_entry_data( IMPORTING es_data = ls_so ). in your method?
Check if ls_so-SO_ITEMSet has data in it. If it does, check if it proceeds to ls_soitem.
If it doesnt proceed to ls_soitem, declare ls_item of type ty_s_so.
Let me know if this works,
-NK
Hi Gowtham,
Apologies for overlooking that, and for the delay in replying as well.
In case you don't get data in the SO_ITEMSet, You probably catch an exception while debugging. Can you drill down the exception and see what the error message is caught?
Also, can you check what io_expand contains?
Post both screenshots for that.
Cheers,
-NK
Hi Gowtham,
Can you comment the line
if lv_compare_result EQ /iwbep/if_mgw_odata_expand=>gcs_compare_result-match_equals.
and keep this as uncommented
io_data_provider->read_entry_data( IMPORTING es_data = ls_so ).
after the line
lv_compare_result = io_expand->compare_to( lc_soitems ).
I want to see what exception is caught in your io_expand, over where there should be something related to your child-set SO_ITEMSet and where the data goes exactly.
Post the screenshot of the error message which you get when you press f5 after you catch the exception, and go inside it.
Cheers,
-NK
Hi Gowtham,
This is a wierd error. Looks like some BSP dump. Don't try to go around it by commenting the compare line, instead post this question separately.
Meanwhile, can you double click on io_expand after the execution of the line
lv_compare_result = io_expand->compare_to( lc_soitems ).
Post what happens inside the io_expand's mt_children, lets see if the item data is there or not.
Cheers,
-NK
Hi Gowtham,
in data declaration part for header and line items.
DATA: BEGIN OF ty_s_so.
INCLUDE TYPE zcl_zsalesorder_mpc=>ts_so_header.
DATA: SO_ITEMSET TYPE TABLE OFzcl_zsalesorder_mpc=>ts_so_item WITH DEFAULT KEY,
END OF ty_s_so.
In constants declaration:
constants: lc_soitems type string value 'SO_ITEMSET'.
Provide navigation name completely in capital letters.
Now keep debugging point and check whether u r able to get the line items into SO_ITEMSET.
Regards,
Venu
Hi Gowtham,
in data declaration part for header and line items.
DATA: BEGIN OF ty_s_so.
INCLUDE TYPE zcl_zsalesorder_mpc=>ts_so_header.
DATA: SO_ITEM TYPE TABLEOFzcl_zsalesorder_mpc=>ts_so_item WITH DEFAULTKEY,
END OF ty_s_so.
In constants declaration:
constants: lc_soitems type string value 'SO_ITEM'.
Provide navigation name completely in capital letters.
Change your navigation property name as item property name as shown in below screen shot.
Now keep debugging point and check whether u r able to get the line items into SO_ITEMSET.
Regards,
Venu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Raja,
SO_ITEMSet ( Navigation Property ) to be used as the name to define the item table in Deep Structure ( ty_s_so ).
....
types: SO_ITEMSet type ty_t_soitem,
......
Constant value for lc_soitems which is maintained in code is SO_ITEMS.
Value to be maintained is 'SO_ITEMSet'.
Please check this.
Regards,
Ashwin
Oh i c!!!! thanks for this information Ashwin, its giving me the value E as shown in the snap shot below,
but i couldn't able execute the line no.52 (io_data_provider) the debugger is closing suddenly and i am getting the error in the browser as
{
"error": {
"code": "005056A509B11ED1B9BF9F46AA8E82ED",
"message": {
"lang": "en",
"value": "In the context of Data Services an unknown internal server error occured"
}
}
}
METHOD /iwbep/if_mgw_appl_srv_runtime~create_deep_entity.
**TRY.
*CALL METHOD SUPER->/IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_DEEP_ENTITY
* EXPORTING
* IV_ENTITY_NAME =
* IV_ENTITY_SET_NAME =
* IV_SOURCE_NAME =
* IO_DATA_PROVIDER =
* IT_KEY_TAB =
* IT_NAVIGATION_PATH =
* IO_EXPAND =
** io_tech_request_context =
** IMPORTING
** er_deep_entity =
* .
** CATCH /iwbep/cx_mgw_busi_exception .
** CATCH /iwbep/cx_mgw_tech_exception .
**ENDTRY.
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.
TYPES: cx_mgw_busi_exception TYPE REF TO /iwbep/cx_mgw_busi_exception.
DATA: ls_so TYPE ty_s_so,
ls_item TYPE zcl_zsalesorder_mpc=>ts_so_item,
lv_compare_result TYPE /iwbep/if_mgw_odata_expand=>ty_e_compare_result.
DATA: lv_soid TYPE bapivbeln-vbeln,
ls_sohdr TYPE bapisdhd1,
ls_soitem TYPE bapisditm,
lt_soitem TYPE STANDARD TABLE OF bapisditm,
ls_partner TYPE bapiparnr,
lt_partner TYPE STANDARD TABLE OF bapiparnr,
lt_return TYPE bapirettab,
lr_return TYPE REF TO bapiret2,
lx_busi_exc TYPE cx_mgw_busi_exception,
lo_meco TYPE REF TO /iwbep/if_message_container.
constants: lc_soitems TYPE string VALUE 'SO_ITEMSet'.
* Validate whether the current request including the inline SOItem data matches
lv_compare_result = io_expand->compare_to( lc_soitems ).
* Upon match, access data from IO_DATA_PROVIDER
if lv_compare_result EQ /iwbep/if_mgw_odata_expand=>gcs_compare_result-match_equals.
io_data_provider->read_entry_data( IMPORTING es_data = ls_so ).
* Move data into BAPI structure
" Header data
ls_sohdr-CURRENCY = ls_so-CURRENCY.
ls_sohdr-DOC_TYPE = ls_so-DOC_TYPE.
ls_sohdr-DOC_DATE = ls_so-DOC_DATE.
ls_sohdr-SALES_ORG = ls_so-SALES_ORG.
ls_sohdr-DISTR_CHAN = ls_so-DIST_CHANNEL.
ls_sohdr-DIVISION = ls_so-DIVISION.
ls_sohdr-SALES_GRP = ls_so-SALES_GRP.
ls_sohdr-SALES_OFF = ls_so-SALES_OFF.
ls_sohdr-REQ_DATE_H = ls_so-REQ_DATE_H.
ls_sohdr-PURCH_DATE = ls_so-PURCH_DATE.
ls_sohdr-INCOTERMS1 = ls_so-INCOTERMS1.
ls_sohdr-INCOTERMS2 = ls_so-INCOTERMS2.
ls_sohdr-PMNTTRMS = ls_so-PMNTTRMS.
ls_sohdr-PRICE_DATE = ls_so-PRICE_DATE.
ls_sohdr-PURCH_NO_C = ls_so-PURCH_NO_C.
" Item data
loop at ls_so-SO_ITEMSet into ls_item.
ls_soitem-itm_number = ls_item-ITEM_NO.
ls_soitem-material = ls_item-MAT_NO.
ls_soitem-plant = ls_item-Plant.
ls_soitem-TARGET_QTY = ls_item-Quantity.
ls_soitem-TARGET_QU = ls_item-TARGET_QU.
ls_soitem-ITEM_CATEG = ls_item-ITEM_CATEG.
ls_soitem-PURCH_NO_C = ls_item-PURCH_NO_C.
ls_soitem-PURCH_DATE = ls_item-PURCH_DATE.
ls_soitem-INCOTERMS1 = ls_item-INCOTERMS1.
ls_soitem-INCOTERMS2 = ls_item-INCOTERMS2.
ls_soitem-PMNTTRMS = ls_item-PMNTTRMS.
ls_soitem-PRICE_DATE = ls_item-PRICE_DATE.
ls_soitem-SALES_UNIT = ls_item-SALES_UNIT.
ls_soitem-DIVISION = ls_item-DIVISION.
ls_soitem-CURRENCY = ls_item-CURRENCY.
append ls_soitem to lt_soitem.
endloop.
" Fill Partner table with one entry - Sold-to Party
ls_partner-partn_role = 'AG'.
ls_partner-partn_numb = '0000001111'.
append ls_partner to lt_partner.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
* SALESDOCUMENTIN =
order_header_in = ls_sohdr
* ORDER_HEADER_INX =
* SENDER =
* BINARY_RELATIONSHIPTYPE =
* INT_NUMBER_ASSIGNMENT =
* BEHAVE_WHEN_ERROR =
* LOGIC_SWITCH =
* TESTRUN =
* CONVERT = ' '
IMPORTING
SALESDOCUMENT = lv_soid
tables
RETURN = lt_return
ORDER_ITEMS_IN = lt_soitem
* ORDER_ITEMS_INX =
order_partners = lt_partner
* ORDER_SCHEDULES_IN =
* ORDER_SCHEDULES_INX =
* ORDER_CONDITIONS_IN =
* ORDER_CONDITIONS_INX =
* ORDER_CFGS_REF =
* ORDER_CFGS_INST =
* ORDER_CFGS_PART_OF =
* ORDER_CFGS_VALUE =
* ORDER_CFGS_BLOB =
* ORDER_CFGS_VK =
* ORDER_CFGS_REFINST =
* ORDER_CCARD =
* ORDER_TEXT =
* ORDER_KEYS =
* EXTENSIONIN =
* PARTNERADDRESSES =
* NFMETALLITMS =
.
READ TABLE lt_return INDEX 1 REFERENCE INTO lr_return.
IF lr_return->*-type NE 'S'.
lo_meco = mo_context->get_message_container( ).
lo_meco->add_messages_from_bapi(
it_bapi_messages = lt_return
iv_determine_leading_msg = /iwbep/if_message_container=>gcs_leading_msg_search_option-first
).
CREATE OBJECT lx_busi_exc
EXPORTING
message_container = lo_meco.
RAISE EXCEPTION lx_busi_exc.
ELSE.
COMMIT WORK.
ls_so-so_id = lv_soid.
ENDIF.
copy_data_to_ref(
EXPORTING
is_data = ls_so
CHANGING
cr_data = er_deep_entity
).
ENDIF.
ENDMETHOD.
Ashwin,
FYI...
To skip the cx_no_check into lo_exception error i have also tried the coding as
lv_compare_result = io_expand->compare_to( lc_soitems ).
* Upon match, access data from IO_DATA_PROVIDER
if lv_compare_result EQ /iwbep/if_mgw_odata_expand=>gcs_compare_result-match_equals.
TRY .
io_data_provider->read_entry_data( IMPORTING es_data = ls_so ).
CATCH cx_no_check.
ENDTRY.
Where i could proceed with io_data_provider now but now also i am getting the header details and my item deep structure remains empty as
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Krishna,
As mentioned, can we have any other way than the manual removal of the unnecessary entries like associations, navigations etc from the HTTP REQUEST...???
so that when the Fiori app uses this OData service, then this unnecessary entries already removed...
Best Regards,
Pavan Golesar.
Hi Krishna,
I have tried with json format and deleting navigation and association properties, but it failed which gives me error as
{
"error": {
"code": "/IWCOR/CX_DS_EP_PROPERTY_ERROR/005056A509B11ED1BF822D2D09171A04",
"message": {
"lang": "en",
"value": "Property 'results' is invalid"
},
"innererror": {
"transactionid": "42932FE53A76F1069A3F005056BE7049",
"errordetails": []
}
}
}
Request body input:
{
"d": {
"results": [
{
"__metadata": {
"id": "http://hostname:port/sap/opu/odata/sap/ZSALESORDER_SRV/SO_HEADERS('4970')",
"uri": "http://hostname:port/sap/opu/odata/sap/ZSALESORDER_SRV/SO_HEADERS('4970')",
"type": "ZSALESORDER_SRV.SO_HEADER",
},
"SO_ID": "0",
"CURRENCY": "EUR",
"DOC_TYPE": "OR",
"DOC_DATE": "20150721",
"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": "20150721",
"PURCH_NO_C": "TEST ORDER",
"SO_ITEMSet": {
"results": [
{
"__metadata": {
"id": "http://hostname:port/sap/opu/odata/sap/ZSALESORDER_SRV/SO_ITEMS(SO_ID='4970',ITEM_NO='000010')",
"uri": "http://hostname:port/sap/opu/odata/sap/ZSALESORDER_SRV/SO_ITEMS(SO_ID='4970',ITEM_NO='000010')",
"type": "ZSALESORDER_SRV.SO_ITEM"
},
"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": "20150721",
"INCOTERMS1": "CIP",
"INCOTERMS2": "Nürnberg",
"PMNTTRMS": "ZB01",
"PRICE_DATE": "20150721",
"SALES_UNIT": "ST",
"DIVISION": "00",
"CURRENCY": "EUR"
}
]
}
}
]
}
}
I meant like this.
{
"SO_ID": "0",
"CURRENCY": "EUR",
"DOC_TYPE": "OR",
"DOC_DATE": "20150721",
"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": "20150721",
"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": "20150721",
"INCOTERMS1": "CIP",
"INCOTERMS2": "Nürnberg",
"PMNTTRMS": "ZB01",
"PRICE_DATE": "20150721",
"SALES_UNIT": "ST",
"DIVISION": "00",
"CURRENCY": "EUR"
}
]
}
Below should work. Check ->
{
"SO_ID": "0",
"CURRENCY": "EUR",
"DOC_TYPE": "OR",
"DOC_DATE": "20150721",
"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": "20150721",
"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": "20150721",
"INCOTERMS1": "CIP",
"INCOTERMS2": "Nürnberg",
"PMNTTRMS": "ZB01",
"PRICE_DATE": "20150721",
"SALES_UNIT": "ST",
"DIVISION": "00",
"CURRENCY": "EUR"
}]
}
Hi Ashwin,
Ya think its partially working. it gives an error
{
"error": {
"code": "CX_SY_CONVERSION_NO_DATE_TIME/67AA6842BAA80B7DE10000000A15523C",
"message": {
"lang": "en",
"value": "Value 21/07/2015 does not represent a valid date/time"
},
"innererror": {
"transactionid": "89962FE52DD0F1259A3F005056BE7049",
"errordetails": []
}
}
}
I have tried the date with 20150721 , 20072015, 20.07.2015, 20/07/2015... but its still the same
Use the below and check please ->
{
"SO_ID": "0",
"CURRENCY": "EUR",
"DOC_TYPE": "OR",
"DOC_DATE": "2014-08-21T00: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": "2014-08-21T00: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": "2014-08-21T00:00:00",
"INCOTERMS1": "CIP",
"INCOTERMS2": "Nürnberg",
"PMNTTRMS": "ZB01",
"PRICE_DATE": "2014-08-21T00:00:00",
"SALES_UNIT": "ST",
"DIVISION": "00",
"CURRENCY": "EUR"
}]
}
Krishna,
I have gone to the blog written by you
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pavan,
I tried adding this line in the payload starting but it failed.
<?xml version="1.0" encoding="UTF-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
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>
</atom:entry>
Hello Raja,
You need to carefully add at all the required places.
Please have a look at the sample which i have shared and construct your payload in XML same as that with your data. This should resolve the issue.
Trouble shoot as below. Do it one by one.
First construct Payload for Header and one item and check if its hitting and able to read data inside Create_Deep_Entity.
Next add 2nd item to the existing payload now and check. Next again add 3rd item to the existing payload and check.
Construct the JSON payload which is easy as shown in the sample and is fast and less prone to errors.
Regards,
Ashwin
User | Count |
---|---|
81 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.