cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

S/4HANA API for A_JournalEntryItemBasic changes order of results if $select fields

litox
Explorer
0 Kudos
610

When I query using the REST API the A_JournalEntryItemBasic resource of the API_JOURNALENTRYITEMBASIC_SRV service, if I change the list of fields to retrieve, using the $select parameter, then the order of the results change. Even if I add an $orderby !

For example, I expect that a GET request to this two URLs return the same record (same ID, same URI) but represented with a different set of fields. Because I'm passing `$top=1` so only the first result should be returned:

  1. GET https://sandbox.api.sap.com//s4hanacloud/sap/opu/odata/sap/API_JOURNALENTRYITEMBASIC_SRV/A_JournalEntryItemBasic?%24top=1&%24select=ID%2CLedger%2CLedgerName%2CSourceLedger%2CLedg
    erFiscalYear%2CControllingArea%2CControllingAreaName%2CCompanyCode%2CCompanyCodeName%2CGLAccount%2CGLAccountName&%24orderby=Ledger
  2. GET https://sandbox.api.sap.com//s4hanacloud/sap/opu/odata/sap/API_JOURNALENTRYITEMBASIC_SRV/A_JournalEntryItemBasic?%24top=1&%24select=WBSElement%2CWBSElementDescription%2CPartnerCo
    mpanyCode%2CPartnerCompanyCodeName%2CCostCtrActivityType%2CCostCtrActivityTypeName%2COrderID%2CLedger&%24orderby=Ledger

But two different URIs are returned. First:

{'__metadata': {'id': "https://sandbox.api.sap.com/s4hanacloud/sap/opu/odata/sap/API_JOURNALENTRYITEMBASIC_SRV/A_JournalEntryItemBasic('.1~0C.3~0L.4~2018.5~A000.7~1010.9~0000000001')",
  'uri': "https://sandbox.api.sap.com/s4hanacloud/sap/opu/odata/sap/API_JOURNALENTRYITEMBASIC_SRV/A_JournalEntryItemBasic('.1~0C.3~0L.4~2018.5~A000.7~1010.9~0000000001')",
  'type': 'API_JOURNALENTRYITEMBASIC_SRV.A_JournalEntryItemBasicType'},
 'ID': '.1~0C.3~0L.4~2018.5~A000.7~1010.9~0000000001',
 'Ledger': '0C',
 'LedgerName': 'Management Accounting',
 'SourceLedger': '0L',
 'LedgerFiscalYear': '2018',
 'ControllingArea': 'A000',
 'ControllingAreaName': 'Controlling Area A000',
 'CompanyCode': '1010',
 'CompanyCodeName': 'BestRun DE',
 'GLAccount': '1',
 'GLAccountName': 'Paybls Domestic'}

And second:

{'__metadata': {'id': "https://sandbox.api.sap.com/s4hanacloud/sap/opu/odata/sap/API_JOURNALENTRYITEMBASIC_SRV/A_JournalEntryItemBasic('.1~0C.71~.73~.75~.77~')",
  'uri': "https://sandbox.api.sap.com/s4hanacloud/sap/opu/odata/sap/API_JOURNALENTRYITEMBASIC_SRV/A_JournalEntryItemBasic('.1~0C.71~.73~.75~.77~')",
  'type': 'API_JOURNALENTRYITEMBASIC_SRV.A_JournalEntryItemBasicType'},
 'Ledger': '0C',
 'WBSElement': '',
 'WBSElementDescription': '',
 'PartnerCompanyCode': '',
 'PartnerCompanyCodeName': '',
 'CostCtrActivityType': '',
 'CostCtrActivityTypeName': '',
 'OrderID': ''}

The OData specification says:

Select System Query Option ($select): A data service URI with a $select System Query Option identifies the same set of entities as a URI without a $select query option; however, the presence of a $select query option specifies that a response from the data service SHOULD return a subset, as identified by the value of the $select query option, of the properties that would have been returned had the URI not included a $select query option.

What am I missing?

 

UPDATE:
Apparently what I take as a row ID is actually a GENERATED_ID : a special property name used in OData services to uniquely identify aggregated or grouped data records. When you request aggregated data in an OData service, a GENERATED_ID property is automatically created for each resulting group. This ID serves as a unique key for that aggregated record, allowing you to request the same aggregated data again by referencing this ID.

So now, I don't know how to identify rows and thus how to match two rows from different queries. Can I rely on the order of the results?

View Entire Topic
junwu
SAP Champion
SAP Champion
0 Kudos

what you are trying achieve?

because you are using different select, you can consider you working on completely different entityset.... what to match????

litox
Explorer
0 Kudos
I want to retrieve data from a resource with 145 fields (A_JournalEntryItemBasic). The request fails every time.
litox
Explorer
0 Kudos
I want to retrieve data from a resource with 145 fields (A_JournalEntryItemBasic). The request fails every time. So I want to implement an horizontal pagination: fetch a subset of fields every time. But then I have to merge those horizontal slices to reconstruct the complete rows.
junwu
SAP Champion
SAP Champion
0 Kudos
any error log for the failure?
litox
Explorer
0 Kudos
Trying to retrieve all fields:
litox
Explorer
0 Kudos
HTTP Request: GET https://sandbox.api.sap.com/s4hanacloud/sap/opu/odata/sap/API_JOURNALENTRYITEMBASIC_SRV/A_JournalEnt... "HTTP/1.1 500 Internal Server Error. <?xml version="1.0" encoding="utf-8"?><error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><code>DBSQL_SQL_INTERNAL_DB_ERROR</code><message>Runtime Error: 'DBSQL_SQL_INTERNAL_DB_ERROR'. The OData request processing has been abnormally terminated. Analyze the runtime error using Feed Reader in ABAP development tools for Eclipse or using transaction /IWFND/ERROR_LOG or /IWBEP/ERROR_LOG or ST22. Create a support ticket on the application component of the OData service for errors in services delivered by SAP.</message><timestamp>20251006204302</timestamp></error>
junwu
SAP Champion
SAP Champion
0 Kudos
why not report a incident to sap?