Extract SQL from a RAP Request Using SALV_TRACE

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

  1. Start transaction SALV_TRACE to open the ALV Trace Tool.
  2. In Trace Activation, choose Trace On/Off and confirm that the status is Active.
  3. Reproduce the exact failing action, such as the UI search or OData request.
  4. Return to SALV_TRACE, turn tracing off, and confirm the status is Inactive. Choose Refresh List.
SALV_TRACE activation controls showing trace inactive and a sample user
Trace activation controls. Source: SAP KBA 3730990.

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.

SADL Dynamic SQL Executor SQL SELECT row with Input highlighted
Open Input for the SQL SELECT task. Source: SAP KBA 3730990.

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.

SAP Note

SAP Note 3730990

You May Also Like

Leave a Reply?