
When a RAP request or OData query fails in SAP S/4HANA, the generated SQL can help explain what happened at the database layer. SAP documents a way to retrieve it from SALV_TRACE.
Record the failing request
- Start transaction SALV_TRACE to open the ALV Trace Tool.
- In Trace Activation, choose Trace On/Off and confirm that the status is Active.
- Reproduce the exact failing action, such as the UI search or OData request.
- Return to SALV_TRACE, turn tracing off, and confirm the status is Inactive. Choose Refresh List.

Open the generated SQL
Open the trace set recorded while you reproduced the issue. Locate the failing entry, typically highlighted in red, and find the task SADL Dynamic SQL Executor – SQL SELECT.
On that row, double-click Input in the Data column. The XML Viewer opens, where you can copy the SQL statement for analysis.

Keep the SQL together with the request details and any corresponding ST22 dump so you can correlate the evidence. Review trace output for sensitive values before sharing it outside your support team.

