Show TOC

Leaving Event Blocks Using CHECKLocate this document in the navigation structure

Leaving Event Blocks Using CHECK

If you use the CHECK expr statement within an event block but not within a loop, and the condition expris not fulfilled, the system exits the processing block immediately.

expr can be any logical expression or the name of a selection table. If you specify a selection table and the contents of the corresponding table work area do not fulfill the condition in the selection table, it has the same effect as a false logical expression.

The ABAP runtime environment triggers the next event according to the following diagram:

The next event in the prescribed sequence is always called.

If the CHECK statement occurs in a loop using DO, WHILE, or LOOP, it is the loop that terminates, not the processing block.

Within a GET event block, this means the next GET event at the same hierarchical level.When it leaves the event block, the logical database reads the next line of the current node, or the next-highest node if it has already reached the end of the hierarchy level. Nodes that are lower down in the hierarchical structure of the logical database are not processed.

Inside GET events, you can use an extra variant of the CHECK statement:

CHECK SELECT-OPTIONS.

This statement checks the contents of the table work area of the current node against all selection tables linked to that node.

Note that CHECK statements for checking database contents in GET events are only processed after the data has been read from the logical database. For performance reasons, you should therefore avoid using checks of this kind. Instead, try to check before the data is read, for example, by using dynamic selections.

Tip

The following executable program is connected to the logical database F1S.

REPORT demo_program_check_1.

NODES: spfli, sflight, sbook.

START-OF-SELECTION.  LOOP AT airp_fr.    CHECK airp_fr-low NE ' '.    WRITE: / 'Selected Aiport-From:', airp_fr-low.    ULINE.  ENDLOOP.  LOOP AT airp_fr.    CHECK airp_to-low NE ' '.    WRITE: / 'Selected Airport-To:', airp_to-low.    ULINE.  ENDLOOP.

GET sflight.  WRITE: / 'Connid:', sflight-connid,           'Carrid:', sflight-carrid,           'Fldate:', sflight-fldate.

If the user enters "Frankfurt" for CITY_FR, but nothing for CITY_TO, the beginning of the list would look like this:

After the second CHECK statement, the system leaves the START-OF-SELECTION block and triggers the event GET sflight.

Tip

The following executable program is connected to the logical database F1S.

REPORT demo_program_check_2.

NODES: spfli, sflight, sbook.

GET sflight.  CHECK sflight-carrid EQ 'LH'.  WRITE: / 'Connid:', sflight-connid,           'Carrid:', sflight-carrid,           'Fldate:', sflight-fldate.

GET sbook.  CHECK sbook-bookid LT 00000320.  WRITE: / 'Bookid:', sbook-bookid.

GET sflight LATE.  ULINE.

This produces the following output list:

In the example above, all lines of the node SFLIGHT and, if SFLIGHT-CARRID is "LH", all lines of the node SBOOK, must be read. For performance reasons, you should avoid programming selections as above. Instead, use the selections of the logical database.