Leaving Event Blocks Using CHECK Locate the document in its SAP Library structure

If you use the CHECK <expr> statement within an event block but not within a loop, and the condition <expr> is 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 are do not fulfill the condition in the selection table, it is the same as a false logical expression.

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

This graphic is explained in the accompanying text

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.

Example

The following program is connected to the logical database F1S.

REPORT EVENT_DEMO.

NODES: SPFLI, SFLIGHT, SBOOK.

START-OF-SELECTION.
  CHECK CITY_FR NE ' '.
  WRITE: / 'Selected City-From:', CITY_FR.
  ULINE.
  CHECK CITY_TO NE ' '.
  WRITE: / ' Selected City-To:', CITY_TO.
  ULINE.

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:

This graphic is explained in the accompanying text

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

Example

The following program is connected to the logical database F1S.

REPORT EVENT_DEMO.

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:

This graphic is explained in the accompanying text

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.

 

 

 

 

Leaving content frame