Show TOC

Background documentationUsing a Query Locate this document in the navigation structure

 

Syntax Syntax

  1. report  DEMO_QUERY_PERSISTENT.
  2. parameters AIRPFROM type S_FROMAIRP default 'FRA'.
  3. parameters AIRPTO   type S_TOAIRP   default 'SIN'.
  4. data: QUERY_MANAGER type ref to IF_OS_QUERY_MANAGER,
  5.       QUERY         type ref to IF_OS_QUERY.
  6. data: CONNECTIONS type OSREFTAB,
  7.       CONNECTION  type ref to CL_SPFLI_PERSISTENT,
  8.       AGENT       type ref to CA_SPFLI_PERSISTENT.
  9. data: CARRID type S_CARR_ID,
  10.       CONNID type S_CONN_ID.
  11. data: TMP type ref to OBJECT.
  12. data: EXC type ref to CX_ROOT,
  13.       TEXT type STRING.
  14. AGENT = CA_SPFLI_PERSISTENT=>AGENT.
  15. try.
  16.     QUERY_MANAGER = CL_OS_SYSTEM=>GET_QUERY_MANAGER( ).
  17.     QUERY = QUERY_MANAGER->CREATE_QUERY(
  18.               I_FILTER  = `AIRPFROM = PAR1 AND AIRPTO = PAR2` ).
  19.     CONNECTIONS =
  20.       AGENT->IF_OS_CA_PERSISTENCY~GET_PERSISTENT_BY_QUERY(
  21.                I_QUERY   = QUERY
  22.                I_PAR1    = AIRPFROM
  23.                I_PAR2    = AIRPTO ).
  24.     if ( lines( CONNECTIONS ) > 0 ).
  25.       read table CONNECTIONS into TMP index 1.
  26.       CONNECTION ?= TMP.
  27.       CARRID = CONNECTION->GET_CARRID( ).
  28.       CONNID = CONNECTION->GET_CONNID( ).
  29.       concatenate TEXT-001 CARRID CONNID into TEXT separated by SPACE.
  30.     else.
  31.       TEXT = TEXT-002.
  32.     endif.
  33.     message TEXT type 'I'.
  34.   catch CX_ROOT into EXC.
  35.     TEXT = EXC->GET_TEXT( ).
  36.     message TEXT type 'I'.
  37. endtry.
End of the code.

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 obtained 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.