Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Run query in programm with variable values

tino_schumacher
Explorer
0 Likes
497

Hi All,

I'd like to create a program, which runs queries without processing the variable screen.

The variables shall assigned dynamically.

How can I set the variable values programmatically?

thanks in advance

Tino



TYPE-POOLS: rsr, rzi0, rrx1, rrms, rsbbs, rrkh, rro01, rsdd,
            rrx2, rsdm4, vrm, col.

data:
  g_handle         LIKE rrx_misc-handle,
  g_cmdid          TYPE rrx_menu-cmdid,
  g_iobjnm         TYPE rs_char30,

  g_x              LIKE rrx_grid-x,
  g_y              LIKE rrx_grid-y,
  g_t_ranges       TYPE rrx1_t_ranges,
  g_t_dim          TYPE rrx1_t_dim,
  g_t_mem          TYPE rrx1_t_mem,
  g_t_cel          TYPE rrx1_t_cel,
  g_t_prptys       TYPE rrx1_t_prptys,
  g_t_atr          TYPE rrx1_t_atr,
  g_t_grid         TYPE rrx1_t_grid,
  g_t_con          TYPE rrx1_t_con,
  g_t_fac          TYPE rrx1_t_fac,
  g_t_var          LIKE rrx_var OCCURS 0,
  i_s_repkey       TYPE RSR_S_COMPKEY,
  i_s_repkey       TYPE RSR_S_COMPKEY.




" ...
  g_cmdid = 'STRT'.

  PERFORM init_prptys CHANGING g_t_prptys.

  CALL FUNCTION 'RRX_SESSION_INITIALIZE'
        TABLES
          c_t_prptys = g_t_prptys
        EXCEPTIONS
          OTHERS     = 1.

  IF sy-subrc <> 0.
    " do error message 
  ENDIF.

  CALL FUNCTION 'RRX_REPORT_OPEN'
     EXPORTING
       i_genuniid       = g_s_repkey-genuniid
     IMPORTING
       e_handle         = g_handle
     EXCEPTIONS
       open_failed      = 1
       invalid_genuniid = 2
       msg_init_failed  = 3
       inherited_error  = 4
       x_message        = 5
       OTHERS           = 6.






"fill the strukture 4 query init
 i_s_repkey-COMPUID = 'BJO5JX4GPOE6X6WO8GF0QMUYD'. " technical query id
 i_s_repkey-OBJVERS = 'A'.
 i_s_repkey-INFOCUBE = 'Z_INFP_01'. " technical name of the infoprovider
 i_s_repkey-GENUNIID	= 'C2UOVWRT24287QJQ5DSQBJNED'.
 i_s_repkey-COMPTYPE = 'REP'.
 i_s_repkey-COMPID   = 'Z_MyQuery_with_Var_01'.


"set the variables - this isn't working - start
  CREATE OBJECT lcl_olapVar
        EXPORTING
          i_s_repkey  = i_s_repkey
          " i_handle    = i_handle " with handle > the prog' dumps
          .

  c_varval->ADD_REF( EXPORTING I_R_RUNTIME = lcl_olapVar ).

" ....

" the the sample variable ..
  l_values-var_id-vnam  = <fs_var>-vnam.
  l_values-var_id-handle = g_handle.
  l_values-manual_input = ' '.
  l_range-sign          = 'I'.
  l_range-opt           = 'EQ'.
  l_range-low           = '26000'.
  l_range-high          = '26000'.

  APPEND l_range TO l_t_range.
  MOVE l_t_range TO l_values-values.
  APPEND l_values TO l_t_values.


 CALL METHOD c_varval->set_values
    EXPORTING
      i_t_values = l_t_values.

" this isn't working - end 

" run the query
  CALL FUNCTION 'RRX_GRID_CMD_PROCESS'
    EXPORTING
      i_handle           = g_handle
      i_cmdid            = g_cmdid
      i_iobjnm           = g_iobjnm
    IMPORTING
      e_max_x            = g_x
      e_max_y            = g_y
    TABLES
      i_t_ranges         = g_t_ranges
      e_t_dim            = g_t_dim
      e_t_mem            = g_t_mem
      e_t_cel            = g_t_cel
      c_t_prptys         = g_t_prptys
      e_t_atr            = g_t_atr
      e_t_grid           = g_t_grid
      e_t_ranges         = g_t_ranges
      e_t_con            = g_t_con
      e_t_fac            = g_t_fac
      e_t_var            = g_t_var
    EXCEPTIONS
      inherited_error    = 1
      no_record_found    = 2
      terminated_by_user = 3
      no_processing      = 4
      no_change          = 5
      dbcl_nosupport     = 6
      no_authorization   = 7
      x_message          = 8
      screen_canceled    = 9
      launch_url         = 10
      OTHERS             = 11.
  g_subrc = sy-subrc.


"...
" 
FORM init_prptys CHANGING c_t_prptys TYPE rrx1_t_prptys.

  DATA: l_s_global_settings TYPE rrxgblset,
        l_s_prptys          TYPE rrx1_s_prptys.

  CALL FUNCTION 'RRSV_GLOBAL_SETTINGS_GET'
    IMPORTING
      e_s_global_settings = l_s_global_settings.

  l_s_prptys-id    = rrx1_c_prptys_id-percentfrac.
  l_s_prptys-value = l_s_global_settings-percntfrac.
  APPEND l_s_prptys TO c_t_prptys.

  l_s_prptys-id    = rrx1_c_prptys_id-mask_date.
  l_s_prptys-value = l_s_global_settings-mask_date.
  APPEND l_s_prptys TO c_t_prptys.

  l_s_prptys-id    = rrx1_c_prptys_id-mask_time.
  l_s_prptys-value = l_s_global_settings-mask_time.
  APPEND l_s_prptys TO c_t_prptys.

  l_s_prptys-id    = rrx1_c_prptys_id-dcpchar.
  l_s_prptys-value = l_s_global_settings-dcpchar.
  APPEND l_s_prptys TO c_t_prptys.

  l_s_prptys-id    = rrx1_c_prptys_id-signprsnt.
  l_s_prptys-value = l_s_global_settings-signprsnt.
  IF l_s_prptys-value IS INITIAL.
    l_s_prptys-value = '1'.
  ENDIF.
  APPEND l_s_prptys TO c_t_prptys.

  l_s_prptys-id    = rrx1_c_prptys_id-formatted_values.
  l_s_prptys-value = 'X'.
  APPEND l_s_prptys TO c_t_prptys.

ENDFORM.  

1 REPLY 1
Read only

Sandra_Rossi
Active Contributor
0 Likes
384

Welcome to SDN.

I think you should better post it to the BI forum.

Did you try to use the user exit EXIT_SAPLRRS0_001 (extension RSR00001) to initialize the values? And for bypassing the selection screen, can't you define it in the query definition (if I remember well)?