Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Program Flow Logic →  Expressions and Functions for Conditions →  log_exp - Logical Expressions →  rel_exp - Predicates →  rel_exp - Predicate Expressions →  rel_exp - IS BOUND 

Predicate Expression IS NOT BOUND

This example demonstrates the predicate expression IS NOT BOUND.

Other versions: 7.31 | 7.40 | 7.54

Source Code

REPORT demo_is_not_bound.

CLASS cls DEFINITION.
  PUBLIC SECTION.
    CLASS-DATA dref TYPE REF TO i.
    CLASS-METHODS main.
ENDCLASS.

CLASS cls IMPLEMENTATION.
  METHOD main.
    DATA number TYPE i.
    dref = REF #( number ).
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
  cls=>main( ).
  IF cls=>dref IS NOT INITIAL AND
     cls=>dref IS NOT BOUND.
    cl_demo_output=>display(
      'stack reference is not initial but not bound' ).
  ENDIF.

Description

The static attribute dref of a class is assigned a reference to a local data object in a method. This stack reference is invalid once the method is exited. Therefore, both predicate expressions IS NOT INITIAL and IS NOT BOUND are true for dref.