‎2011 Nov 17 7:38 PM
I Have 2 variants for a Z report. Having issue with variants values for one of the slection screen.
Selection Screen:
SELECTION-SCREEN : BEGIN OF BLOCK bj WITH FRAME TITLE text-m08.
PARAMETERS p_ba TYPE zfi_barea-zzarea MATCHCODE OBJECT zzbarea. "Business Area
PARAMETERS p_fn(40) TYPE c. "File Name
SELECTION-SCREEN : END OF BLOCK bj.
Variants for Z report
/VAR1 has Business Area FIN
File Name Test1
/VAR2 has blank vaues for Business Area and File Name
Issue:
When i switch between variants ..The /VAR2 is retaining values of /VAR1.
Apprecite feedback.
‎2011 Nov 17 7:49 PM
Yes, this is a common behavior.
If /VAR2 is not explicitly setting the value of a field, then the value set by the previous variant /VAR1 will be retained. Basically SAP is not forcing null/blanks on values that are already existing on a field.
This will only occur when you are switching variants. So it is always a good idea to check the values that a variant fetches and always do a /nsa38 or /nse38 before setting a variant online and not switch variants one after other.
This issue will NOT affect batch jobs run by variants as each batch job runs in its own session and there is no carry over.
‎2011 Nov 17 7:53 PM
Thanks for your inputs. But when you swtich between variants the values should not be retianed as the users may
accidentally trigger jobs and in my case [ The business Area & File Name information is used for background Job to write files to specific Unix folder..we have a unique folder for each business area ).
I am checking the option of clearing parameter id ..still looking for answers.
‎2011 Nov 18 12:55 AM
Resolved by using the FM 'RS_VARIANT_CONTENTS' below.
gx_program = sy-repid.
gx_variant = sy-slset.
DATA: lt_parm TYPE STANDARD TABLE OF vanz INITIAL SIZE 0,
lt_parm_nonv TYPE STANDARD TABLE OF vanz INITIAL SIZE 0,
lt_selop TYPE STANDARD TABLE OF vanz INITIAL SIZE 0,
lt_selop_nonv TYPE STANDARD TABLE OF vanz INITIAL SIZE 0,
lt_values TYPE STANDARD TABLE OF rsparams INITIAL SIZE 0,
lx_values TYPE rsparams.
CONSTANTS: lc_ba TYPE rsparams-selname VALUE 'P_BA',
lc_fn TYPE rsparams-selname VALUE 'P_FN'.
CALL FUNCTION 'RS_VARIANT_CONTENTS'
EXPORTING
report = gx_program
variant = gx_variant
TABLES
l_params = lt_parm
l_params_nonv = lt_parm_nonv
l_selop = lt_selop
l_selop_nonv = lt_selop_nonv
valutab = lt_values
EXCEPTIONS
variant_non_existent = 1
variant_obsolete = 2
OTHERS = 3.
IF sy-subrc EQ 0.
SORT lt_values BY selname.
READ TABLE lt_values INTO lx_values WITH KEY selname = lc_ba
BINARY SEARCH.
IF sy-subrc EQ 0.
IF lx_values-low IS INITIAL.
CLEAR p_ba.
ENDIF.
ENDIF.
READ TABLE lt_values INTO lx_values WITH KEY selname = lc_fn
BINARY SEARCH.
IF sy-subrc EQ 0.
IF lx_values-low IS INITIAL.
CLEAR p_fn.
ENDIF.
ENDIF.
ENDIF.
CLEAR lx_values.
FREE: lt_parm,
lt_parm_nonv,
lt_selop,
lt_selop_nonv,
lt_values.