SAPContext
Analyze ABAP object dependencies by extracting compressed public API contracts to understand relationships efficiently before code modifications.
Instructions
Get compressed dependency context for an ABAP object or CDS entity. Returns only the public API contracts (method signatures, interface definitions, type declarations) of all objects that the target depends on — NOT the full source code. This is the most token-efficient way to understand dependencies. Instead of N separate SAPRead calls returning full source (~200 lines each), SAPContext returns ONE response with compressed contracts (~15-30 lines each). Typical compression: 7-30x fewer tokens.
What gets extracted per dependency:
Classes: CLASS DEFINITION with PUBLIC SECTION only (methods, types, constants). PROTECTED, PRIVATE and IMPLEMENTATION stripped.
Interfaces: Full interface definition (interfaces are already public contracts).
Function modules: FUNCTION signature block only (IMPORTING/EXPORTING parameters).
CDS views (DDLS): All data sources (tables, other CDS views), association targets, and compositions. Each dependency's full source is included (table definitions, CDS DDL). Essential for CDS unit test generation — provides the dependency graph and field catalogs needed for cl_cds_test_environment doubles.
Filtering: SAP standard objects (CL_ABAP_, IF_ABAP_, CX_SY_) are excluded — the LLM already knows standard SAP APIs. Custom objects (Z, Y*) are prioritized.
Use SAPContext BEFORE writing code that modifies or extends existing objects. Use SAPRead to get the full source of the target object, then SAPContext to understand its dependencies.
For CDS analysis: Use SAPContext instead of reading each view in the dependency chain individually. A single SAPContext call on a consumption view (e.g., ZC_*) returns all dependent interface views, tables, and associations — replacing 5-10 separate SAPRead calls. Only use targeted SAPRead for metadata extensions (DDLX) or service bindings (SRVB) that SAPContext does not cover.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | No | Action: "deps" (default, can be omitted) = get dependency context. "usages" = reverse dependency lookup — find all objects that depend on the given name. Requires cache warmup (--cache-warmup). Only "name" is needed for usages. | |
| type | No | Object type (required for deps action) | |
| name | Yes | Object name (e.g., ZCL_ORDER) | |
| source | No | Optional: provide source directly instead of fetching from SAP. Saves one round-trip if you already have the source from SAPRead. | |
| group | No | Required for FUNC type. The function group containing the function module. | |
| maxDeps | No | Maximum dependencies to resolve (default 20). Lower = faster + fewer tokens. | |
| depth | No | Dependency depth: 1 = direct deps only (default), 2 = deps of deps, 3 = maximum. Higher depth = more context but more SAP calls. |