Creating variants for default values
You can automatically use an existing variant to fill your report parameters and selections during the event initialization.
Continue Reading This Article
Enjoy this article as well as all of our content, including E-Guides, news, tips and more.
function /ctac/variant_start. *"---------------------------------------------------------------------- *"*"Local interface: *" IMPORTING *" REFERENCE(RE_SYST) TYPE SYST *"---------------------------------------------------------------------- * * This function checks if there are variants with a specific name and * propose these values on selection screen * Use this function in the INITIALIZATION event of your report data: tp_subrc like sy-subrc. data: tp_repid like rsvar-report. data: tp_variant like rsvar-variant. tp_repid = re_syst-repid. clear tp_variant. tp_variant = 'U_'. write re_syst-uname to tp_variant+2. call function 'RS_VARIANT_EXISTS' exporting report = tp_repid variant = tp_variant importing r_c = tp_subrc exceptions others = 9. if sy-subrc = 0. if not tp_subrc is initial. clear tp_variant. tp_variant = 'U_'. write re_syst-sysid to tp_variant+2. call function 'RS_VARIANT_EXISTS' exporting report = tp_repid variant = tp_variant importing r_c = tp_subrc exceptions others = 9. check sy-subrc = 0. endif. if tp_subrc = 0. call function 'RS_SUPPORT_SELECTIONS' exporting report = tp_repid variant = tp_variant exceptions variant_not_existent = 01 variant_obsolete = 02. endif. endif. * endfunction.