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 - Predicative Method Call 

Predicative Method Calls

This example demonstrates predicative method calls.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    IF cl_abap_demo_services=>is_production_system( ).
      cl_demo_output=>display(
         'This demo cannot be executed in a production system' ).
      LEAVE PROGRAM.
    ENDIF.

    DATA carrier TYPE spfli-carrid VALUE 'LH'.
    cl_demo_input=>request( CHANGING field = carrier ).

    DATA(out) = cl_demo_output=>new(
      )->next_section( 'IF' ).
    IF cl_demo_spfli=>get_spfli( to_upper( carrier ) ).
      out->write( 'Filled' ).
    ELSE.
      out->write( 'Not filled' ).
    ENDIF.

    out->next_section( 'COND'
      )->write( COND string(
                  WHEN cl_demo_spfli=>get_spfli( to_upper( carrier ) )
                    THEN `Filled`
                  ELSE `Not filled` )
      )->display( ).

Description

The functional method IS_PRODUCTION_SYSTEM of the class CL_ABAP_DEMO_SERVICES is called predicatively in a control statement IF to verify that the current system is not a production system. The method called is a predicate method.

The functional method GET_SPFLI of the class CL_DEMO_SPFLI is then called predicatively once in a control statement IF and once in a conditional expression COND. In this case, it is not a predicate method. The relational expressions are true or false, depending on whether the internal table returned is empty or filled.