on 03-11-2015 8:12 AM
Hi experts,
I'm using "GWPAM add-in Visual Studio" to add reference for SAP NW Gateway service for C# code.
I was successfully with GET method, POST method with header level only.
But with complex business data (Header - Items) the add-in did not generate XML request that I desire.
I appreciate all your solutions.
Thank you.
Hi,
Please confirm if you’re trying same thing “Created new project of type(C#) and adding proxy
using “Add SAP Service Reference “feature from Visual Studio and you are performing Create or Update operation (?) in your application .
As per your comment get operation is working for you also and your able to see complex types data.
I just tried get operation with below sample service
https://vmw3815.wdf.sap.corp:44309/sap/opu/odata/sap/ZMATERIALS_DATA_SRV/Materials(1018)
This has complex type “matpkgdata” ["ZMATERIALS_DATA_SRV.pkgmatdata]
The get operation sample code is as follows , as you said I am able to see complex types with below
code.
ZMATERIALS_DATA_SRV.ZMATERIALS_DATA_SRV serviceContext; string url = string ApplicationConfigReader.ConfigFilePath = new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath; ServiceDetails this.serviceContext ZMATERIALS_DATA_SRV.Material outputTest = new var where cuurentMaterial.matid == 1018 select cuurentMaterial).FirstOrDefault(); ; outputTest.matid = outputTest.description = outputTest.matpkgdata = |
If you confirm above points i.e are you using “Add SAP Service Reference” and Create/Update operations are not working , then will try to share one sample for you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
serviceContext.SaveChanges(SaveChangesOptions.Batch),
I have attached Fiddler Request and Response for deep insert.
Please observe Fiddler , Our Proxy (SAP Reference ) how generates XML in single request.
I hope this information helps you......
POST User-Agent: Microsoft ADO.NET Data Services DataServiceVersion: 1.0;NetFx MaxDataServiceVersion: 2.0;NetFx Accept-Language: en-US sap-client: RequestID: a8a7efbf98084757a4c8291ae07e677c Authorization: Basic TmFzZWVtczpJbml0aWFsMQ== x-requested-with: xmlhttprequest X-CSRF-Token: Accept: application/atom+xml,application/xml Accept-Charset: UTF-8 Content-Type: multipart/mixed; Host: vmw3815.wdf.sap.corp:44309 Cookie: SAP_SESSIONID_G3T_100=lHxqL6CH9GlGEDo3AkJVu3xdJFPH_RHkgGkAUFa0PPA%3d; Content-Length: 3544 Expect: 100-continue
--batch_61329f02-367f-46bd-b5bd-80086c5ce1b4 Content-Type: multipart/mixed; boundary=changeset_553a6b61-0d22-4dfe-80dd-4dffc17f1ccd
--changeset_553a6b61-0d22-4dfe-80dd-4dffc17f1ccd Content-Type: application/http Content-Transfer-Encoding: binary
POST Content-ID: 1 Content-Type: application/atom+xml;type=entry Content-Length: 1351
<?xml version="1.0" encoding="utf-8" <entry <title /> <author> <name /> </author> <id /> <content <d:basicuom <d:cdate <d:matid <matgrppkg <matrefpkg <d:matstatus <d:mattype <d:mdate <d:netweight </content> </entry> --changeset_553a6b61-0d22-4dfe-80dd-4dffc17f1ccd Content-Type: application/http Content-Transfer-Encoding: binary
POST Content-ID: 2 Content-Type: application/atom+xml;type=entry Content-Length: 1351
<?xml version="1.0" encoding="utf-8" <entry xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" <title /> <author> <name /> </author> <id /> <content <d:basicuom <d:cdate <d:matid <matgrppkg <matrefpkg <d:matstatus <d:mattype <d:mdate <d:netweight </content> </entry> --changeset_553a6b61-0d22-4dfe-80dd-4dffc17f1ccd-- --batch_61329f02-367f-46bd-b5bd-80086c5ce1b4--
|
Regards,
Showkath.
First of all, thank you for your help.
I know Batch mode but it isn't what I need, because Batch just for multiple flat data.
For example, if you know PO (Purchase Order) in SAP you will see you can't use Batch to create a PO with multiple items.
More over, your Fiddler request is not a Deep insert case, it only create 2 Materials. Complex data as you mentioned in Fiddler request is just a way to group flat data into a structure.
I'm looking forward to hearing from you.
I was initially confused when you said complex object.
The only way to do deep insert using DataServiceContext is to use Batch mode. While the OData protocol supports deep
insert, DataServiceContext (WCF DS) does not have that support in it. For doing Batch, call ctx.SaveChanges(SaveChangesOptions.Batch).
I added an answer below(#3).
#1 . Similar thread I have found here : http://scn.sap.com/thread/3169101
#2 . Deep Insert suggestion: Add-In returns xml ,Try to POST the same format that you would GET with $expand.
Using System.Data.Services.Client; // ........QueryOperationResponse<Z_PORDER_SRV.PurchaseOrderHeader> purchaseOrder= serviceContext.PurchaseOrderHeaderCollection.AddQueryOption("$filter","PONumber eq '1'") .Expand("PurchaseOrderItem").Execute()as QueryOperationResponse<Z_PORDER_SRV.PurchaseOrderHeader>; Example : <?xml <atom:entry <atom:content <m:properties> <d:TotalValueAtRelase>0.00</d:TotalValueAtRelase> <d:PurchaseOrgGroup>AR1</d:PurchaseOrgGroup> <d:PurchaseOrganization>7500</d:PurchaseOrganization> <d:VendorAccountNumber>0000100073</d:VendorAccountNumber> <d:PurchaseDocStatus>9</d:PurchaseDocStatus> <d:PurchaseDocType>NB</d:PurchaseDocType> <d:PurchaseDocCategory>F</d:PurchaseDocCategory> <d:CompanyCode>7500</d:CompanyCode> <d:PONumber>1</d:PONumber> </m:properties> </atom:content> <atom:link <m:inline> <atom:feed> <atom:entry> <atom:content <m:properties> <d:Plant>7500</d:Plant>
<d:Material>000000000000001108</d:Material> <d:POItem>00001</d:POItem> <d:PONumber>0</d:PONumber>
<d:WeightUnit />
<d:NetValue>0.0000</d:NetValue>
<d:PriceUnit>0</d:PriceUnit> <d:NetPrice>2.8200</d:NetPrice>
<d:Unit>ST</d:Unit> <d:Quantity>4.000</d:Quantity>
<d:MaterialGroup>001</d:MaterialGroup> </m:properties> </atom:content> </atom:entry> </atom:feed> </m:inline> </atom:link> </atom:entry> |
#3 . Deep insert using DataServiceContext : The only way to do deep insert using DataServiceContext is to use Batch mode. While the OData protocol supports deepinsert, DataServiceContext does not have that support in it.
Z_PORDER_SRV.PurchaseOrderHeader newPOHeader = new Z_PORDER_SRV.PurchaseOrderHeader(); List<Z_PORDER_SRV.PurchaseOrderItem> newPOitems = foreach { serviceContext.AddRelatedObject(newPOHeader, "PurchaseOrderItem", newPOHeader.PurchaseOrderItem.Add(newPOItem); } serviceContext.SaveChanges(SaveChangesOptions.Batch); |
But as you said deep insert seems a cleaner approach to me, as the issue of dealing with the new parent key value can presumably be dealt with by the controller action method.
#4 . Have a look here :
How do I update an OData entity and modify its
navigation properties in one request?
#5. You can make use of .net libraries available. Libraries | Open Data Protocol
http://scn.sap.com/thread/3535275
#6. Create a sales order using the deep insert create request
with ODataModel in SAP UI5
application
#7. You could refer to this link for this part of the OData spec.
OData Version 4.0 Part 1: Protocol
Hope this helps.
Regards,
Showkath Naseem.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.