Add a parcel and read it back
The packing queue already contains PK-204. A new parcel arrives, and the exercise adds it to the table before reading the second row.
APPEND adds a row
APPEND 'PK-205' TO parcels.
For a standard table, APPEND adds a row at the end. Use it when arrival order is meaningful or when adding one row at a time is the clearest expression.
READ TABLE can retrieve a row
READ TABLE parcels INDEX 2 INTO DATA(result).
This reads the second row by position. In production code, a position may not identify the business object you actually need; if you need to find a parcel by tracking code, use a suitable key or table design and check whether a row was found.
The READ TABLE statement sets sy-subrc; classic ABAP code often checks it to determine success. Follow the language-version and API rules for your environment.
Other choices
For a small ordered list, index-based access is easy to teach. For repeated lookups by a unique identifier, a sorted or hashed table with a meaningful key may be a better fit. Choose the table category based on the operations you need rather than habit.
Practice
Append PK-205, read row 2 into result, and output it using the selected environment’s mechanism. The browser checker checks syntax patterns only.
Sources
- SAP Samples, Internal Tables
- SAP Help Portal, ABAP Keyword Documentation
Version note: Table syntax, keys, and available constructs depend on the target ABAP release/language version.
Developer practice · ABAP
Practice: look up a parcel by tracking code
Append a second parcel, then read the second row into result using READ TABLE and an index.
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
TYPES ty_parcels TYPE STANDARD TABLE OF string WITH EMPTY KEY.
DATA(parcels) = VALUE ty_parcels( ( 'PK-204' ) ).
APPEND 'PK-205' TO parcels.
READ TABLE parcels INDEX 2 INTO DATA(result).
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.