Symptom
- Custom logic has been implemented using either BAdI SD_SLS_MODIFY_ITEM or SD_SLS_MODIFY_HEAD.
- Values stored in custom fields are calculated by selecting data from the standard CDS views, e.g.: I_SalesOrderItem.
- The implementation doesn't work in creation, but works correctly in any edition made afterwards.
- It also works correctly in test mode.
Environment
SAP S/4HANA Cloud Public Edition
Cause
In the BAdI implementation, the bellow condition is used when fetching data from the CDS View:
... WHERE salesdocument = @salesdocumentitem-salesdocument ...
This code is trying to filter the CDS View results by the number of the sales document currently being created, however, the sales document number hasn't been generated yet. Additionally, since the sales document hasn't been created, the data is not yet persisted in the database, so it also cannot be accessed through CDS Views.
To read transactional data from CDS View during the creation of sales order is currently a missing functionality.
Resolution
It is recommended that, when implementing custom logic inside a Sales BAdI, field values required for output or downstream processing should be read directly from the importing parameters available within the BAdI call context, such as SALESDOCUMENT for header-level data or SALESDOCUMENTITEMS for item-level data. These parameters carry the current in-memory state of the document and do not depend on the database commit cycle.
In case the importing parameters are not available to be used, consider creating a feature request for this business requirement. This will inform the responsible developers as to what additional functionality should be considered for future releases.
Follow the steps to create the request:
1. Get started by opening SAP Customer Influence.
2. Register and accept the Terms of Use.
3. Choose a session of interest.
4. Create and submit the improvement request.
5. Take a look at existing improvement requests and start voting and commenting.
See Also
KBA 2963059 - How to Submit Feature Requests for SAP S/4HANA Cloud Product
Keywords
BAdI, SD_SLS_MODIFY_ITEM, SD_SLS_MODIFY_HEAD, CDS View, sales order creation, transactional data, custom logic, SAP S/4hHANA Cloud Public Edition, condition types, feature request, test mode, sales order, custom field, creation , KBA , SD-SLS-EXT-2CL , Extensibility (Public Cloud) , Problem
SAP Knowledge Base Article - Public