Introduction: ABAP Program to derive dynamic report name based on input variable values of a Query
Requirement: Need Dynamic Query Description based on the input variable values
Example:
When ZP_VAR1 = Australia, ZP_VAR2 = Sydney & Fiscal year = 2012
Then Report name should display as Australia Sydney 2012
Program code:
WHEN "Mention the text variable give in the Query description"
** Defining Variables
data : Var1(n), *corresponding input variable in query = ZP_VAR1*
Var2(n), *corresponding input variable in query = ZP_VAR2*
Var3(n), *corresponding input variable in query = ZP_VAR3*
Var4(n), *corresponding input variable in query = ZP_VAR4*
fyear(n), *corresponding input variable in query = 0P_FPER1*
title(n).
**Code to read the value stored in the variable to the Query Description
read table i_t_var_range INTO s_t_var_range with key vnam = 'ZP_VAR1' .
if s_t_var_range-LOW is not initial .
Var1 = s_t_var_range-LOW.
endif.
clear s_t_var_range-LOW.
read table i_t_var_range INTO s_t_var_range with key vnam = 'ZP_VAR2' .
if s_t_var_range-LOW is not initial .
Var2 = s_t_var_range-LOW.
endif.
clear s_t_var_range-LOW.
read table i_t_var_range INTO s_t_var_range with key vnam = 'ZP_VAR3'.
if s_t_var_range-LOW is not initial .
Var2 = s_t_var_range-LOW.
endif.
clear s_t_var_range-LOW.
read table i_t_var_range INTO s_t_var_range with key vnam = 'ZP_VAR4' .
if s_t_var_range-LOW is not initial .
Var4 = s_t_var_range-LOW.
endif.
clear s_t_var_range-LOW.
read table i_t_var_range INTO s_t_var_range with key vnam = '0P_FPER1' .
if s_t_var_range-LOW is not initial .
fyear = s_t_var_range-LOW.
endif.
clear s_t_var_range-LOW.
concatenate Var1 Var2 Var3 Var4 '' fyear into title separated by space.
CLEAR: L_S_RANGE.
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'EQ'.
L_S_RANGE-LOW = title.
APPEND L_S_RANGE TO E_T_RANGE.
CLEAR L_S_RANGE.
ENDCASE.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 |