Dictionary Views and Search Helps
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. |
A table holds the data, but a program or a screen often needs the data in another shape: the claims together with the name of the employee who filed them, or only two columns of a wide table, or a list of the values a user may type into a field. The ABAP Dictionary, the system’s central catalogue of type definitions, offers two kinds of objects for this. A view is a saved question over one or more tables that you can read like a table. A search help is the description of the pop-up list that appears when a user presses F4 in an input field. A newcomer meets both in older systems all the time, so this page explains what each kind is, how the four classic view types differ, how the input help of a field is chosen, and why new development uses CDS view entities and CDS value helps instead. It is written against Standard ABAP release 8.16 and ABAP for Cloud Development release 9.20 (2608). Classic views and search helps apply to classic Standard ABAP, on premise and the private edition of SAP S/4HANA. SAP states that classic Dictionary views are not available in ABAP Cloud, which is the case for the Public Edition and the SAP BTP ABAP environment, and recommends their CDS successors for new developments.
Before you read
-
Database Tables and Structures: a view reads tables, and this page uses the claim table defined there.
-
Domains and Data Elements: the fixed values of a domain are one of the sources of an input help.
-
ABAP SQL Basics: a view is read with the same
SELECTstatement as a table. -
Classic Tools: SE80 and SE11: the screens on which classic views and search helps are maintained.
-
Foreign keys and indexes, which decide how tables can be joined in some views, have a page of their own that comes just before this one in the section; locks and CDS view entities have pages after it.
Key terms
-
ABAP Dictionary: the central place where tables, views, search helps and other type definitions are kept.
-
DDIC database view: a classic view that combines several tables with a join and is created as a view on the database.
-
Projection view: a classic view that shows only some of the columns of exactly one table.
-
Help view: a classic view that is used as the data source of a search help.
-
Maintenance view: a classic view that lets a user maintain the data of several tables as one object.
-
Search help: a Dictionary object that builds the list of values offered when a user presses F4 in an input field.
-
Value help: the general name for such a list of values, also used for CDS-based lists and Fiori applications.
-
Matchcode object: the predecessor of the search help.
-
CDS view entity: the current kind of CDS view, defined with
DEFINE VIEW ENTITY, which replaces classic views and DDIC-based CDS views.
Views in plain words
Think of a window cut into a wall of filing cabinets. You do not move any folders: you decide which cabinets the window shows and which columns of the folders are visible, and whoever looks through it sees one tidy list. A view works the same way. It stores no data of its own. It is a definition that says which tables are combined, which of their fields are shown, and which rows are kept. The Dictionary documentation describes the three steps: select the tables and link them with join conditions, select the fields of the base tables, and formulate the conditions that restrict the rows. In an ABAP program a view is used like a table: it can be read with ABAP SQL and it types a work area.
The Dictionary knows four view types, and the documentation names the job of each.
| View type | What it is for | Rule worth remembering |
|---|---|---|
Database view |
Combines several tables with a join and is created as an equivalent view on the database. |
Implements an inner join. Only transparent tables can be included. The join may use equality between any fields of the base tables. |
Projection view |
Hides fields of a table: only a projection. |
Contains exactly one table, so it never joins. |
Help view |
Serves as the selection method of a search help. |
Tables can be combined only when they are linked by foreign keys. |
Maintenance view |
Lets a user maintain the data spread over several tables as one application object. |
Tables can be combined only when they are linked by foreign keys, and all key fields of the primary table must be in the view. |
The Dictionary page on views adds that database views implement an inner join and the other view types an outer join, and that the join conditions of the other three types must come from existing foreign keys. The maintenance status of a view says whether you can only read data with it or also insert and change data.
Source: ABAP Platform: Views, ABAP Platform: Creating a Database View and ABAP Keyword Documentation: DDIC database view
The next sections go through the four types. None of them is created in the source editor of ADT: the ADT user guide lists views among the classic objects that open in the integrated SAP GUI, so the screens are those of SE11.
Database views
A database view answers a question such as "show every claim together with the name of its employee". On the tab Tables/Join conditions you list the tables and link them with join conditions. If suitable foreign keys exist you copy the join condition from the foreign key instead of typing it. On View fields you choose the columns, optionally on Selection conditions you restrict the rows, and on Maintenance status you choose read-only or not. The only technical setting a database view has is buffering. When you activate the view, the system creates the matching view in the database if the base tables already exist there.
What the view computes is an inner join: a row appears only when both sides have a partner. The playground of this site has no Dictionary views, so it cannot create one, but it can run the query that the view would stand for. The report below fills two small tables, joins them, and then shows the same join as an outer join and a one-table projection, which the view types above are built from. It runs in the local playground and prints the lines shown below. It does not create or read a Dictionary view.
REPORT zp_view.
INSERT zexp_employee FROM @( VALUE zexp_employee( employee_id = 'E1' name = 'Ana' ) ).
INSERT zexp_employee FROM @( VALUE zexp_employee( employee_id = 'E2' name = 'Ben' ) ).
INSERT zexp_claim FROM @( VALUE zexp_claim( claim_id = 'C-1' employee_id = 'E1' status = 'N' amount = 100 ) ).
INSERT zexp_claim FROM @( VALUE zexp_claim( claim_id = 'C-2' employee_id = 'E2' status = 'A' amount = 250 ) ).
INSERT zexp_claim FROM @( VALUE zexp_claim( claim_id = 'C-3' employee_id = 'E9' status = 'N' amount = 40 ) ).
WRITE / 'inner join (what a database view computes)'.
SELECT c~claim_id, e~name, c~amount
FROM zexp_claim AS c
INNER JOIN zexp_employee AS e ON e~employee_id = c~employee_id
ORDER BY c~claim_id
INTO TABLE @DATA(inner_rows).
LOOP AT inner_rows INTO DATA(i).
WRITE / |{ i-claim_id } { i-name } { i-amount }|.
ENDLOOP.
WRITE / 'left outer join (rows without a partner are kept)'.
SELECT c~claim_id, e~name, c~amount
FROM zexp_claim AS c
LEFT OUTER JOIN zexp_employee AS e ON e~employee_id = c~employee_id
ORDER BY c~claim_id
INTO TABLE @DATA(outer_rows).
LOOP AT outer_rows INTO DATA(o).
WRITE / |{ o-claim_id } [{ o-name }] { o-amount }|.
ENDLOOP.
WRITE / 'projection (a subset of the columns of one table)'.
SELECT claim_id, status FROM zexp_claim ORDER BY claim_id INTO TABLE @DATA(proj_rows).
LOOP AT proj_rows INTO DATA(p).
WRITE / |{ p-claim_id } { p-status }|.
ENDLOOP.
WRITE / 'value list (distinct values a help would offer)'.
SELECT DISTINCT status FROM zexp_claim ORDER BY status INTO TABLE @DATA(vals).
LOOP AT vals INTO DATA(v).
WRITE / |{ v-status }|.
ENDLOOP.
inner join (what a database view computes)
C-1 Ana 100
C-2 Ben 250
left outer join (rows without a partner are kept)
C-1 [Ana] 100
C-2 [Ben] 250
C-3 [] 40
projection (a subset of the columns of one table)
C-1 N
C-2 A
C-3 N
value list (distinct values a help would offer)
A
N
Claim C-3 names an employee E9 that does not exist. The inner join drops it, the outer join keeps it with an empty name. That difference is the reason to know which join a view type uses: a database view silently hides rows that have no partner. The playground tables here have no client field and no foreign key, which a real system adds, as described on the page about database tables.
Projection views
A projection view is the simplest type. You enter one basis table and select the fields you want to keep, and the rest of the
table is hidden. The documentation stresses that a projection view always contains exactly one table. You can give a view
field another data element, as long as it refers to the same domain as the data element of the table field, and you choose
the maintenance status. A projection view is typically used when a screen or a search help needs only a few columns of a wide
table. The SELECT claim_id, status of the report above is the same idea written as a query.
Help views
A help view looks like a database view, but its tables must be linked by foreign keys, starting from a primary table: you select the primary table, choose Relationships, and copy the foreign keys whose join conditions you want. Foreign keys with unsuitable cardinality are listed separately, at the end of the list. The key fields of the primary table are copied to the view as a proposal. A help view exists to be the selection method of an elementary search help, which is the next topic: it is what that help reads its list of values from when the values come from more than one table.
Maintenance views
A maintenance view lets users maintain data that belongs together but is stored in several tables, for example a header and its texts, as if it were one table. Like a help view it is built from a primary table and foreign keys. The rules protect the data: all key fields of the primary table must be in the view, and so must every key field of a secondary table that is not tied to a field already in the view, so that a record entered through the view can be written correctly to every table. The maintenance status of the view defines how its data may be changed with the standard maintenance transaction SM30, and transaction SE54 generates the maintenance modules and screens that distribute the entered data to the base tables. Combine this with the data maintenance setting of a table, described on Database Tables and Structures, and you see why a business table such as the claim table is not maintained through SM30 at all: claims are written by the application.
Search helps and the F4 key
When a user presses F4 in an input field, the system shows a list of possible values, often with extra columns such as a name next to a number, and copies the chosen value back into the field. A search help is the Dictionary object that defines this list. The documentation describes the standard process: the system offers one or more search paths, shows a dialog for restricting the values, determines the hits and shows them as a list, and returns the chosen value, possibly together with other values, to the screen. A search help is a standalone object: it is attached to table fields, structure components or data elements, and every screen field based on them offers it.
Two kinds exist.
-
An elementary search help describes one search path. It names the selection method that supplies the hit list, which is a table, or a projection view of one table, or a database view or help view when the data comes from several tables. It has an interface of search help parameters, which are copied from the selection method and are marked as import parameters (the value the field already holds is used to restrict the search) and export parameters (the values returned to the screen). It also fixes the dialog behaviour: show the values immediately, ask for a restriction first, or decide by the size of the hit list, where the documentation gives 100 entries as the limit.
-
A collective search help combines several elementary search helps, so that the user can choose between alternative search paths, for example search an employee by name or by cost centre. Its own interface of parameters is mapped to the parameters of the helps it combines, and other collective helps inside it are expanded down to the elementary ones.
If the underlying tables are client-specific, the selection method must contain the client field, otherwise the selection would run over all clients, and the search help itself has no client parameter. A search help exit, a function module with a fixed interface, can change the behaviour at defined moments, for example hide entries according to the authorizations of the user. Append search helps let a customer add search paths to an SAP-delivered help without modifying it.
Source: ABAP Platform: Search Helps, ABAP Platform: Elementary Search Help, ABAP Platform: Collective Search Help and ABAP Platform: Dialog Types
A search help is attached to a table field in the table maintenance, or in source form with the addition WITH VALUE HELP
of DEFINE STRUCTURE and DEFINE TABLE: the addition names an existing search help and links every one of its parameters
to a component with WHERE. The example attaches a help for employees to the employee field of an input structure. The
names zexp_employee_id and zexp_sh_employee stand for a data element and a search help that you would have created
first. It requires an SAP system; not run here.
@EndUserText.label : 'Input fields of the claim screen'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
define structure zexp_s_claim_input {
employee_id : zexp_employee_id
with value help zexp_sh_employee
where employee_id = zexp_s_claim_input.employee_id;
}
Which input help wins
A field can have several sources of help at once, and a beginner is often puzzled which list appears. The Keyword
Documentation lists them in ascending order of priority: a calendar or clock help for fields of type DATS and TIMS, the
fixed values of the domain, the search help of the data element, the key fields of the check table, the check table with a
text table (the texts appear in the logon language), a search help bound to the check table, and finally a search help bound
directly to the field, which always wins. Value transport works in both directions: when the help opens, matching fields
supply the import parameters, and when the user picks a line, the export parameters fill the input-enabled screen fields.
Source: ABAP Keyword Documentation: dynpro - Input Helps in the ABAP Dictionary and ABAP Keyword Documentation: dynpro - Input Help
The same page says that a search help bound directly to a field should only propose values that also exist in the check table, otherwise the automatic input check rejects the value the user has just chosen.
From matchcodes to CDS value helps
The F4 list has changed its technology in steps, and older material mixes the names. Matchcode objects were the first technique; the Keyword Documentation defines a matchcode object as the predecessor of the search help, and the word still appears in older selection-screen statements for logical databases. Search helps, elementary and collective, replaced them in the ABAP Dictionary and are still the way classic SAP GUI screens (dynpros and selection screens) get their F4 list. For ABAP Cloud, which has no dynpros, the replacement is the value help of the CDS model: a CDS view entity that provides the values, referenced from the field that needs them.
The SAP cheat sheet on the ABAP Dictionary puts it in one sentence: search helps, which create value lists for input fields on dynpros, can be replaced by CDS-based search helps, and these classic Dictionary objects are not covered because they are not relevant in ABAP Cloud.
A CDS value help has two parts. The first is a view that provides the values: it contains the field with the possible values
and the fields that help the user recognise one, such as a name, so the user can filter by any of them. The second is an
annotation on the element that needs help, @Consumption.valueHelpDefinition, which names the value help view and the element
of it that supplies the value. SAP’s documentation of the simple value help describes the result on a Fiori user interface:
F4 in the field opens a search mask, the user can filter by any field of the provider view, and the chosen value is
transferred to the annotated element. When the source view is exposed in an OData service, the value help view is exposed with
it automatically. The annotation @Consumption.valueHelpDefault.fetchValues with the value #AUTOMATICALLY_WHEN_DISPLAYED
loads the whole list when the help opens, and #ON_EXPLICIT_REQUEST turns that off for large lists. The example gives the claim
view an employee help. It requires an SAP system; not run here.
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Employee value help'
@Consumption.valueHelpDefault.fetchValues: #AUTOMATICALLY_WHEN_DISPLAYED
define view entity ZI_ExpEmployeeVH
as select from zexp_employee
{
key employee_id as EmployeeId,
name as EmployeeName
}
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Expense claim'
define view entity ZI_ExpClaim
as select from zexp_claim
{
key claim_id as ClaimId,
@Consumption.valueHelpDefinition: [{ entity: { name: 'ZI_ExpEmployeeVH', element: 'EmployeeId' } }]
employee_id as EmployeeId,
status as Status,
amount as Amount
}
Source: ABAP Platform: Simple Value Help and ABAP Keyword Documentation: Consumption.valueHelpDefinition.entity.name
The annotation takes a list in square brackets, so one element can have several value helps. For the case of a classic
collective search help, the annotation @ObjectModel.collectiveValueHelp.for.element marks a collective value help for a
field: the Keyword Documentation says that in Fiori this is done through an abstract entity that lists the assigned
elementary helps and any mapping of field names. With useForValidation set to true, a value help can also serve as an input
validator. A full model, with the draft, behavior definition and UI annotations around it, belongs to the RAP pages of this
section, and the CDS syntax itself to the page on CDS view entities.
DDIC-based CDS views and CDS view entities
CDS gave ABAP a second kind of view. The first kind, the DDIC-based CDS view, is defined with DEFINE VIEW and was released with
release 7.40 SP05. When it is activated the system creates two things: the CDS entity, which is what programs should read, and
a CDS-managed DDIC view in the Dictionary, named by the annotation @AbapCatalog.sqlViewName, which is a read-only database
view that exists only as technical foundation. The Keyword Documentation marks this kind as obsolete and says that the
CDS-managed DDIC view should not be used directly in ABAP or in CDS.
The second kind, the CDS view entity, is defined with DEFINE VIEW ENTITY and has been available since release 7.80. SAP recommends
it for every new CDS view and lists the gains: no additional Dictionary view is created on activation, activation is faster,
the syntax is simpler, and the syntax checks are stricter. Two differences show in the source. The view entity has no
@AbapCatalog.sqlViewName, and it has no name list in brackets: the element names are given with AS. Client handling is
automatic too: for a view entity the client dependency follows from the data sources, and the filter on the client is added
implicitly, where a DDIC-based view declares it by annotation.
The two definitions below are written for the claim table. The first is the obsolete form, shown only so that you can recognise it in older code. Both require an SAP system; not run here.
@AbapCatalog.sqlViewName: 'ZEXPCLAIMV'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view zexp_claim_old(
claim,
employee
)
as select from zexp_claim
{
key claim_id,
employee_id
}
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view entity zexp_claim_new
as select from zexp_claim
{
key claim_id as claim,
employee_id as employee
}
Source: ABAP Keyword Documentation: ABAP CDS - DDIC-Based Entities (Obsolete), ABAP Keyword Documentation: ABAP CDS - CDS-managed DDIC Views and ABAP Keyword Documentation: Definition of Client Handling for CDS View Entities
A CDS entity, whichever kind it is, is a global type that ABAP programs can use as a data type and read with ABAP SQL, and
that CDS can use as a data source. What it cannot do is serve as a type for the definition of Dictionary objects: a view
entity cannot be the type of a table field, for example. Dictionary objects can be used inside CDS, but not the other way
round. SAP also notes that writing CDS view entities is a data modelling task and usually not the job of an ordinary
application programmer; once a view exists, programs only read it with SELECT.
Which to choose
-
In ABAP Cloud, which is the Public Edition and the BTP ABAP environment, create a CDS view entity for every new view and a CDS value help for every input help. Classic Dictionary views are not available there, and search helps are not relevant without dynpros.
-
On a classic system, create a CDS view entity for new views as well, and keep a Dictionary view only when an older object needs one: a help view for an existing search help, or a maintenance view generated for SM30.
-
Create a new classic search help only when a classic SAP GUI screen needs an F4 list; otherwise use a CDS value help.
-
When you read older code, translate the names: a DDIC-based CDS view with
@AbapCatalog.sqlViewNameis the obsolete form of a view entity, and a matchcode is the old name of a search help.
Older material you may meet
-
Books and older programs create views and search helps on the SE11 screens, tab by tab. The result is the same Dictionary object that this page describes; only the editor differs.
-
Older material says "database view" for every CDS view. Today a DDIC database view is the classic Dictionary object, and a CDS view is a CDS entity.
-
Older code sets the F4 list in the dynpro flow logic with a dialog module at the event POV. The Keyword Documentation lists that as the third and lowest-ranked technique: a search help from the Dictionary should be used whenever possible, and a search help exit should be tried before a self-programmed help.
Summary
-
A Dictionary view stores no data. It is a definition over tables that you read like a table, and the four classic types are the database view (inner join of transparent tables), the projection view (one table, fewer columns), the help view (the data source of a search help) and the maintenance view (maintaining several tables as one object, through SM30).
-
A search help builds the F4 list of an input field. An elementary search help describes one search path with a selection method and parameters, and a collective search help combines several of them.
-
When a field has several helps, the one bound directly to the field wins over the check table, the data element, the fixed values of the domain and the calendar or clock help.
-
A matchcode is the old name of a search help; in ABAP Cloud the replacement is a CDS view entity that provides the values, referenced by
@Consumption.valueHelpDefinitionon the field. -
A DDIC-based CDS view creates an extra Dictionary view and is obsolete. Write new views as CDS view entities with
DEFINE VIEW ENTITY.