Using Variants As Default Values Using ABAP

If you need to use variant values as the default values in your selection screen, then you can achieve this by using the “RS_SUPPORT_SELECTIONS” function module.

All you need to do is supply the variant name and it will display the value automatically during the INITIALIZATION event.

Here’s the ABAP SAMPLE CODE.

INITIALIZATION.

data: tp_subrc like sy-subrc.
data: tp_repid like rsvar-report.
data: tp_variant like rsvar-variant.



tp_repid = sy-repid.
clear tp_variant.
tp_variant = 'Your Variant Name'.

"Check if the variant is exist.

call function 'RS_VARIANT_EXISTS'
exporting
report = tp_repid
variant = tp_variant
importing
r_c = tp_subrc
exceptions
others = 9.

if sy-subrc = 0.

call function 'RS_SUPPORT_SELECTIONS'
exporting
report = tp_repid
variant = tp_variant
exceptions
variant_not_existent = 01
variant_obsolete = 02.

endif.

Once you run the report program (F8) you will see the selection screen are populated by the variant values.

Subscribe in a reader

Comments

0 Responses to "Using Variants As Default Values Using ABAP"

Post a Comment

Stay Updated