Bring related rows together with a join
An order stores a carrier code; a carrier entity stores the carrier’s display name. An inner join returns rows only where the join condition matches on both sides.
State the relationship
SELECT FROM zi_dispatch_order AS orders
INNER JOIN zi_carrier AS carriers
ON orders~carriercode = carriers~carriercode
Aliases make multi-source statements easier to read. The ~ separator qualifies fields by their source alias and avoids ambiguity when both sources have similarly named fields.
Select explicitly from both sides
FIELDS orders~dispatchorder, carriers~carriername
INTO TABLE @DATA(order_carriers).
An inner join excludes orders without a matching carrier. That is correct only if unmatched orders should be excluded. If they must remain, consider an outer join and handle the missing side.
Join or CDS association?
Use a join in a query when you need the combination for this read. A CDS association models a reusable relationship in a view definition and can be navigated by consumers. Choose based on whether the relationship itself should be part of a reusable model.
Practice
Add the matching inner join, qualified fields, and table target. Set result to the row count. This checker does not execute the query.
Sources
- SAP Samples, ABAP SQL
- SAP Samples, CDS View Entities
- SAP Help Portal, ABAP SQL
Version note: Join forms and syntax support depend on source type and ABAP release.
Developer practice · ABAP
Practice: select columns from both sides
Join the project-owned order and carrier entities on CarrierCode, and select DispatchOrder plus CarrierName.
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 AS orders
INNER JOIN zi_carrier AS carriers
ON orders~carriercode = carriers~carriercode
FIELDS orders~dispatchorder, carriers~carriername
INTO TABLE @DATA(order_carriers).
DATA(result) = lines( order_carriers ).
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.