2005 Nov 09 10:36 PM
Hi all,
The users have created a variant that they use when they run their report. When they select the variant it works fine, but they want the program to run the variant for them. Can anyone give me some ideas as to where I can go to see some sample code, so I can try to figure out how to do this, please?
Thanks
2005 Nov 09 10:41 PM
Hi,
You can select the Variant values in the INITIALIZATION event of the program, if you know the name of the variant. There are useful function modules in the function group SVAR. Or, search rs_variant_*
Cheers,
Bhanu
2005 Nov 09 10:45 PM
Olivia - we create a number of variants and then name them according to the USERIDs of the users that will be running the program. In the program, at the INITIALIZATION event, we call FM RS_SUPPORT_SELECTIONS using the report name and variant name. The program then starts with the individual user's defaults.
Rob
2005 Nov 09 10:59 PM
Hi,
you can use function module below to get the values for the variant user has created
AT SELECTION-SCREEN OUTPUT.
CALL FUNCTION 'RS_VARIANT_CONTENTS'
EXPORTING
report = Report Name
variant = Variant name
TABLES
valutab = it_valutab
EXCEPTIONS
variant_non_existent = 1
variant_obsolete = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Then LOOP AT IT_VALUTAB INTO WA_VALUTAB WHERE SELNAME = 'YOUR FIRST SELECT OPTION NAME such as S_VBELN'.
MOVE WA_VALUTAB-SIGN,WA_VALUTAB-OPTION, WA_VALUTAB-LOW, WA_VALUTAB-HIGH to the corresponding fields of your select option i.e. S_VBELN.
APPEND S_VBLEN.
ENDLOOP.
Similarly Loop at IT_VALUTAB for the remaining fields on the selection screen and append the values in the select options.
Please award points if it solves your problem.
Cheers
sharmistha
2005 Nov 09 11:23 PM
Hi
You can use SET/GET parameter: create a Z-PARAMETER where the variant name'll be stored, insert this PARAMETER in the own data of user.
Then create a new program that'll run the main program using user variant:
REPORT ZREPORT1.
GET PARAMETER ID 'ZVARIANT' FIELD VARIANT.
SUBMIT ZREPORT2
VIA SELECTION-SCREEN
USING SELECTION-SET VARIANT.
You should insert a piece of code to check if the variant exists (see the fm RS_VARIANT*)
Max
Message was edited by: max bianchi
2005 Nov 21 8:07 PM
Hi,
If the thread helped you, please award the points and close the thread.
Bhanu