cancel
Showing results for 
Search instead for 
Did you mean: 

Submit after OData v2 ODataListBinding create method generates nonsense GET query

epamtiosteel
Explorer
0 Kudos
345

Hi everyone,

I have an application with OData v2 no-drafts and Fiori Elements with an extended controller of an Object Page. In the Object Page I have a table with some child elements of the main entity (main one is order, child ones are lines of the order). I need to implement a creation of new lines of the table but the data must be sent to the backend only when I press submit. In the other words, I'm working with inactive or transient context.

For this I'm using the https://sapui5.hana.ondemand.com/sdk/#/api/sap.ui.model.odata.v2.ODataListBinding%23methods/create method.

Creation of inactive context

JavaScript

const oListBinding = this.byId('RequestDetails::responsiveTable').getBinding('items');

// some logic of making oObject

oListBinding.create(oObject, true, { inactive: true });

My issue is the queries generated by FE submit in this case. There are next:

1 ) POST query with data for creation - generated fine.

2) GET request in a same batch which for some reason is using a temporary ID and obviously fails.

An example of the generated batch request:

Batch request payload

An example of the generated batch request:

Batch request payload

--batch_7c9f-04da-961a
Content-Type: multipart/mixed; boundary=changeset_6605-4bb6-f4a6

--changeset_6605-4bb6-f4a6
Content-Type: application/http
Content-Transfer-Encoding: binary

POST PO_QuantityChange('0800000050')/Items HTTP/1.1
X-Requested-With: XMLHttpRequest
Prefer: handling=strict
Content-ID: id-1701071538907-328
sap-messages: transientOnly
sap-contextid-accept: header
Accept: application/json
Accept-Language: en
DataServiceVersion: 2.0
MaxDataServiceVersion: 2.0
Content-Type: application/json
Content-Length: 804

{"aggregator":"1","purchaseOrderLine":"00010-180","plant":"CH90","itemCategory":"5","accountAssignmentCategory":"1","purchaseOrderDeliveryDate":null,"techIndex":"180","custSize":null,"originalQuantity":"120","targetQuantity":null,"contractOpenQuantity":null,"contractCutOffDate":"\/Date(1698796800000)\/","editableFieldControl":3,"lockedBy":null,"Errors":[],"documentCategory":"F","deletionIndicator":null,"documentStatus":null,"purchaseOrder":"0800000050","purchaseOrderLineCriticality":null,"isLocked":false,"customerRequestedDate":null,"planDate":null,"lastProductionDate":null,"vasCutOffDate":null,"firstProductionDate":null,"purchaseOrderStatisticalDeliveryDate":null,"__metadata":{"type":"CreateRequests.POItems_QuantityChange"},"newQuantity":"1111","requestReasonId":"0003","comment":"My Comment"}
--changeset_6605-4bb6-f4a6--

--batch_7c9f-04da-961a
Content-Type: application/http
Content-Transfer-Encoding: binary

GET $id-1701071538907-328?$expand=Parent&$select=Parent HTTP/1.1
sap-cancel-on-close: true
sap-contextid-accept: header
Accept: application/json
Accept-Language: en
DataServiceVersion: 2.0
MaxDataServiceVersion: 2.0
X-Requested-With: XMLHttpRequest


--batch_7c9f-04da-961a--

And obviously the batch is failing because of the 2nd query:

Batch Response

HTTP

--batch_7c9f-04da-961a
content-type: multipart/mixed; boundary=changeset_6605-4bb6-f4a6

--changeset_6605-4bb6-f4a6
content-type: application/http
content-transfer-encoding: binary
content-id: id-1701071538907-328

HTTP/1.1 201 Created
content-type: application/json
location: https://port4004-workspaces-ws-ghq2b.eu10.applicationstudio.cloud.sap/v2/create-requests/POItems_QuantityChange(purchaseOrder='0800000050',purchaseOrderLine='00010-180')
dataserviceversion: 2.0
sap-message: {"code":"201","message":"Ticket 1701071570970 was successfully created for PO line 00010-180","details":[],"severity":"success","target":"/#TRANSIENT#"}
content-length: 1582
content-id: id-1701071538907-328

{"d":{"purchaseOrder":"0800000050","purchaseOrderLine":"00010-180","documentStatus":null,"currency":"USD","aggregator":"1","plant":"CH90","itemCategory":"5","accountAssignmentCategory":"1","purchaseOrderDeliveryDate":null,"originalQuantity":"120","targetQuantity":null,"contractCutOffDate":"/Date(1698796800000)/","scSegmentation":null,"modeOfTransport":"10","customizationStatus":null,"orderClassification":"FR","customerRequestedDate":null,"planDate":"/Date(1706745600000)/","lastProductionDate":"/Date(1706745600000)/","vasCutOffDate":"/Date(1704153600000)/","contractOutlineAgreementNumber":"0046000094","contractAgreementLineItemNumber":"00010","orderPriorityIndicator":null,"deletionIndicator":null,"firstProductionDate":"/Date(1706745600000)/","purchaseOrderStatisticalDeliveryDate":null,"documentCategory":"F","techIndex":"180","manufacturingSize":null,"custSize":null,"finalShipTo":null,"contractOpenQuantity":null,"stagedItem":false,"purchaseOrderLineCriticality":null,"Errors":[],"comment":null,"isLocked":false,"lockedBy":null,"editableFieldControl":3,"isDedicatedOrder":null,"newQuantity":null,"requestReasonId":null,"Parent":{"__deferred":{"uri":"https://port4004-workspaces-ws-ghq2b.eu10.applicationstudio.cloud.sap/v2/create-requests/POItems_QuantityChange(purchaseOrder='0800000050',purchaseOrderLine='00010-180')/Parent"}},"__metadata":{"type":"CreateRequests.POItems_QuantityChange","uri":"https://port4004-workspaces-ws-ghq2b.eu10.applicationstudio.cloud.sap/v2/create-requests/POItems_QuantityChange(purchaseOrder='0800000050',purchaseOrderLine='00010-180')"}}}
--changeset_6605-4bb6-f4a6--
--batch_7c9f-04da-961a
content-type: application/http
content-transfer-encoding: binary

HTTP/1.1 400 Bad Request
content-type: application/json
dataserviceversion: 2.0
content-length: 419

{"error":{"code":"400","message":{"lang":"en","value":"Expected uri token 'ODataIdentifier' could not be found in '$id-1701071538907-328' at position 1"},"severity":"error","target":"/#TRANSIENT#","innererror":{"errordetails":[{"code":"400","message":{"lang":"en","value":"Expected uri token 'ODataIdentifier' could not be found in '$id-1701071538907-328' at position 1"},"severity":"error","target":"/#TRANSIENT#"}]}}}
--batch_7c9f-04da-961a--

The question is is there a way to get rid of the 2nd query? The first one is fully correct.

Thanks in advance.

Accepted Solutions (0)

Answers (1)

Answers (1)

AlexNecula
Active Contributor
0 Kudos

Hi,

Did you try to use the createEntry method of the ODataModel instead?

This, by default, doesn't generate a request until you call the submitChanges method.

Alex

epamtiosteel
Explorer
0 Kudos

Hi Alex,

>> This, by default, doesn't generate a request until you call the submitChanges method.

With the create method of ODataListBinding a request is not generated instantly as well but at least a new line appears in the table which doesn't happen with ODataModel.createEntry.

The issue is that when the submitChanges (which I'm relying on) is triggered then a part of generated request is nonsense.

junwu
Active Contributor
0 Kudos

it is just nonsense to you for now.

I checked and find out that sap standard app is able to handle those kind of request.