Make the lookup rule visible in the declaration

The dispatch identifier is unique in this example. Declaring it as the table’s key records that assumption in the type and makes key-based access clear to a reader.

Declare the table contract

TYPES ty_dispatches TYPE HASHED TABLE OF ty_dispatch
  WITH UNIQUE KEY dispatch_id.

An explicit key can catch duplicate identifiers when inserting and supports direct key lookup. If duplicates are valid, use a suitable non-unique key and a table category that preserves that requirement. Do not mark a field unique just because it is usually unique in a small test sample.

For a standard table used only as a sequence, WITH EMPTY KEY avoids an accidental standard key built from character-like fields. For sorted or hashed access, define the fields your business lookup actually uses. A table key is an in-memory access contract; it does not create a database constraint.

Sources

Developer practice · ABAP

Practice: declare a keyed dispatch table

Define a dispatch row and a hashed internal table whose unique primary key is dispatch_id.

Choose your ABAP environment

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