Separate ABAP values from database-language text
carrier_code is an ABAP variable; carriercode is a database field. The @ host-variable escape makes that difference explicit in modern ABAP SQL.
WHERE carriercode = @carrier_code
The SQL statement remains a statement with a defined query structure, while the value is bound from ABAP. This is safer and clearer than concatenating user input into dynamic SQL text.
Escaping outside conditions
The escape is also used for ABAP targets and values, for example INTO TABLE @DATA(orders) and WHERE createdat >= @since_date. In older syntax versions, escaping conventions differ; do not mechanically paste the modern @ form into legacy code without checking the language version.
Parameters vs dynamic SQL
Use a typed host variable for a value such as a carrier code or date. Dynamic SQL should be reserved for cases where the query structure itself must vary and must use the language’s safe APIs and validation practices. User values should not determine arbitrary SQL fragments.
Practice
Complete the carrier filter with @carrier_code, collect results, and count them. The browser checker checks patterns only; it does not connect to a database.
Sources
- SAP Samples, ABAP SQL
- SAP Help Portal, ABAP SQL
- SAP Samples, ABAP for Cloud Development
Developer practice · ABAP
Practice: bind a carrier code with @
Use the supplied carrier_code ABAP variable in WHERE with the host-variable escape. Do not put the variable name inside a quoted string.
This choice changes the output pattern checked here: WRITE belongs in a classic executable report, while out->write( ) uses the supplied output reference in an ABAP Cloud class-run method. It does not switch the language version of the other code; check release and API availability in your target system.
Complete the task and include the output statement shown for your selected environment. Variable names can differ if you use them consistently. This browser checker checks structure only; it does not compile or run ABAP.
0 required structures detected · 0 checks
Write your solution, then check its structure.
One possible solution
SELECT FROM zi_dispatch_order
FIELDS dispatchorder, carriercode
WHERE carriercode = @carrier_code
INTO TABLE @DATA(orders).
DATA(result) = lines( orders ).
WRITE result.out->write( result ).These are context-specific output examples. In your own program, use the result variable from your solution and the output mechanism available in that program.
Debug this code
The filter is treating the carrier value incorrectly. Repair the condition so it uses the ABAP variable, not a quoted text literal.
Edit the code, then check for the expected repair. This is a structure check, not an ABAP compiler.
Find the issue, repair it, and check your change.
Diagnosis and repair
Diagnosis: The quoted text is a literal value, not the carrier_code variable. Use the @ host-variable escape and leave the variable unquoted.
DATA(carrier_code) = 'C-17'.
SELECT FROM zi_dispatch_order
FIELDS dispatchorder
WHERE carriercode = @carrier_code
INTO TABLE @DATA(orders).