2022 Aug 18 7:46 AM
i am a beginner and just started practicing ALV report and i have been assigned the task to use is_variant in ALV but i am not able to understand how to make it work. A help will be highly appreciated.
2022 Aug 18 7:52 AM
2022 Aug 18 8:26 AM
***Step 1 Declaration
DATA G_VARIANT LIKE DISVARIANT.
PARAMETERS P_VAR LIKE DISVARIANT-VARIANT.
***Step 2 F4 Help to select Layout variant
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VAR.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
IS_VARIANT = G_VARIANT
I_SAVE = 'A'
IMPORTING
ES_VARIANT = G_VARIANT
EXCEPTIONS
NOT_FOUND = 1
PROGRAM_ERROR = 2
OTHERS = 3
.
IF SY-SUBRC = 0.
P_VAR = G_VARIANT-VARIANT.
ELSE.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
***Step 3 - Use the variant in Display ALV grid
gs_variant = g_variant. "<===========================
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
i_callback_pf_status_set = alv_status_set
i_callback_user_command = alv_user_comm
i_grid_title = grid_title
i_save = g_save
is_variant = gs_variant "<=============================
is_layout = alv_layout
it_fieldcat = alv_fieldcat[]
it_events = gt_events[]
it_sort = alv_sort[]
IMPORTING
e_exit_caused_by_caller = g_exit_caused_by_caller
es_exit_caused_by_user = gs_exit_caused_by_user
TABLES
t_outtab = it_output.
*** Step 4 In order to get the values upon pressing F4 you need to do as follows
After executing the report save the Layout using Save layout option.
Then it will appear in F4 help while executing next time
Hope this will help you.
Regards,
Venkat
2022 Aug 19 9:03 AM
Don't forget to also pass the report name (at least, use HANDLE if multiple ALVs in same report) in the disvariant structure
G_REPID = SY-REPID.
GS_variant-REPORT = G_REPID.
2022 Aug 18 12:42 PM
Nowhere you say what the requirement is. The requirement can't be "use is_variant" without anything else. So, I guess you want to display buttons above the ALV grid, so that the user can save and load layouts. What else? What is your current code?
2022 Aug 19 9:00 AM
Did you search and look at some SAP demo programs such as BCALV_GRID_09?