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.

01.INITIALIZATION.
02.
03. data: tp_subrc like sy-subrc.
04. data: tp_repid like rsvar-report.
05. data: tp_variant like rsvar-variant.
06.
07. tp_repid = sy-repid.
08. clear tp_variant.
09. tp_variant = 'Your Variant Name'.
10.
11. "Check if the variant is exist.
12.
13. call function 'RS_VARIANT_EXISTS'
14. exporting
15. report = tp_repid
16. variant = tp_variant
17. importing
18. r_c = tp_subrc
19. exceptions
20. others = 9.
21.
22. if sy-subrc = 0.
23.
24. call function 'RS_SUPPORT_SELECTIONS'
25. exporting
26. report = tp_repid
27. variant = tp_variant
28. exceptions
29. variant_not_existent = 01
30. variant_obsolete = 02.
31.
32. endif.

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

No comments:

Post a Comment