Professional Documents
Culture Documents
Variant f4 Default Get For SAP ABAP
Variant f4 Default Get For SAP ABAP
Some requirements need to allow user to choose a specific layout in the report selection screen. This means that
we need to add some additional codes to achieve that. There several FM for this purpose.
REUSE_ALV_VARIANT_DEFAULT_GET get the default layout of this report
REUSE_ALV_VARIANT_EXISTENCE check whether the input layout name exists
REUSE_ALV_VARIANT_F4 pop up a screen to allow user to choose existing layout
Below are several steps to use these FM.
Step 1. Define layout data.
DATA: GS_VARIANT LIKE DISVARIANT. define the data representation of a layout
V_EXIT.
Step 2. Define selection screen.
IF SY-SUBRC = 2.
MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
IF V_EXIT = SPACE.
P_VARI = GS_VARIANT-VARIANT.
ENDIF.
ENDIF.
Step 4. Define event Initialization to get the default layout.
GS_VARIANT-REPORT = SY-REPID.
IF SY-SUBRC EQ 0.
P_VARI = GS_VARIANT-VARIANT.
ENDIF.
Step 5. Pass the selected layout to the REUSE_ALV_GRID_DISPLAY.
We need to pass the selected layout to parameter named IS_VARIANT. At the same time we need to pass a
value to paramenter named I_SAVE. I_SAVE has a type of c and several value can be passed into it.