Skip to Content

How to retrieve query variables

This blog provides a step by step procedure to create a small ALV report that gathers information coming from tables rszcompdir and rsrrepdir.

Two parameters are created. They are related to the query technical name and the infoprovider technical name.

With just two elements and one standard function module provide by SAP you can retrieve all meta informatin related to the variable of a query.


1- Go to transaction se38 and create a new report

2- Copy and paste the below coding (adapt the parts you need)

3- Execute the report filling the import parameters


4- Export or copy and paste in an excel sheet to format your file.

The important and relevant information regarding the variables are :

The Type of Variable

1 Characteristic value
2 Hierarchy nodes
3 Text
4 Formula
5 Hierarchy

The processing type

5 User entry / default value
1 Replacement path
3 Customer exit
4 SAP exit
6 Authorization

The select parameters

P Single value (parameters)
S Selection option
I Interval
M Multiple Single Values

The flag for ready for input

And the guid for the unique identifier that is available in the query itself.

The coding

REPORT  zquery_variables_get.

PARAMETERS :  p_query   TYPE  char30,
                      p_prov    TYPE  rsinfoprov.
DATA :            lt_var     TYPE TABLE OF  rssem_s_query_variables,
                      l_title    TYPE lvc_title.

    i_query             = p_query
    i_objvers           = ‘A’
    i_infoprov          = p_prov
    i_vartext_requested = ‘X’
    et_var              = lt_var.

SORT lt_var BY vnam.
CONCATENATE ‘Variables for Query’ p_query  INTO l_title SEPARATED BY space.

    i_buffer_active  = ‘X’
    i_structure_name = ‘rssem_s_query_variables’
    i_grid_title     = l_title
    t_outtab         = lt_var
    program_error    = 1
    OTHERS           = 2.

You must be Logged on to comment or reply to a post.