Contexts are repository objects defined abstractly in Context Builder (transaction SE33) in ABAP Workbench that are used to derive the values of additional fields from key fields. ABAP programs work with instances of contexts.
A context comprises fields and modules. The fields of a context are subdivided into key fields and derived fields. The modules describe how the values of the derived fields are created from the key fields. Modules are based on foreign key dependencies between database tables and function modules defined in ABAP Dictionary, or on other contexts. Viewed from a technical perspective, contexts are special ABAP programs (context programs) generated by Context Builder.
An ABAP program can create one or more instances of a context. It can supply the key fields for each instance with values and query the fields derived. Each context has a cross-transaction buffer on the application server, whose attributes are defined in Context Builder. When an instance is queried for values, the system first searches the corresponding buffer for a record with the corresponding key fields. Only if there are not yet any values recorded for this key are they derived from the modules and written to the buffer.
Although contexts can be compared with highly specialized classes, they are not ABAP Objects. Contexts were introduced for high-performance access to frequently required derived data. Since the introduction of ABAP Objects, further development of contexts has been discontinued. Contexts can now be replaced by shared objects.