Start of Content Area

Background documentation Using a Query  Locate the document in its SAP Library structure

report  DEMO_QUERY_PERSISTENT.

 

parameters AIRPFROM type S_FROMAIRP default 'FRA'.

parameters AIRPTO   type S_TOAIRP   default 'SIN'.

 

data: QUERY_MANAGER type ref to IF_OS_QUERY_MANAGER,

      QUERY         type ref to IF_OS_QUERY.

 

data: CONNECTIONS type OSREFTAB,

      CONNECTION  type ref to CL_SPFLI_PERSISTENT,

      AGENT       type ref to CA_SPFLI_PERSISTENT.

 

data: CARRID type S_CARR_ID,

      CONNID type S_CONN_ID.

 

data: TMP type ref to OBJECT.

 

data: EXC type ref to CX_ROOT,

      TEXT type STRING.

 

AGENT = CA_SPFLI_PERSISTENT=>AGENT.

 

try.

    QUERY_MANAGER = CL_OS_SYSTEM=>GET_QUERY_MANAGER( ).

    QUERY = QUERY_MANAGER->CREATE_QUERY(

              I_FILTER  = `AIRPFROM = PAR1 AND AIRPTO = PAR2` ).

    CONNECTIONS =

      AGENT->IF_OS_CA_PERSISTENCY~GET_PERSISTENT_BY_QUERY(

               I_QUERY   = QUERY

               I_PAR1    = AIRPFROM

               I_PAR2    = AIRPTO ).

    if ( lines( CONNECTIONS ) > 0 ).

      read table CONNECTIONS into TMP index 1.

      CONNECTION ?= TMP.

      CARRID = CONNECTION->GET_CARRID( ).

      CONNID = CONNECTION->GET_CONNID( ).

      concatenate TEXT-001 CARRID CONNID into TEXT separated by SPACE.

    else.

      TEXT = TEXT-002.

    endif.

    message TEXT type 'I'.

  catch CX_ROOT into EXC.

    TEXT = EXC->GET_TEXT( ).

    message TEXT type 'I'.

endtry.

 

A reference to the class actor of persistent class CL_SPFLI_PERSISTENT is assigned to the reference variable AGENT. The static constructor of the class CA_SPFLI_PERSISTENT generates this reference once only. A Query Manager is fetched using method GET_QUERY_MANAGER of system class CL_OS_SYSTEM, and a query is created using method CREATE_QUERY when you specify the filter. The query is executed with interface method GET_PERSISTENT_BY_QUERY of interface IF_OS_CA_PERSISTENCY, and the first flight that is found is displayed.

 

 

End of Content Area