Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ALV Layout variant as input in selection screen

Former Member
0 Kudos

I have a ALV grid report with ALV layout variant. i am selecting one ALV layout varient in the selection screen (parameter) and execute the program in background then in background mode the result list will come according to ALV layout variant or not? if yes then how ?

2 REPLIES 2

Former Member
0 Kudos

Hi,

It is possible to achieve this in ALV. You just need to pass the selected variant name to the FM REUSE_ALV_GRID_DISPLAY.

Pass this variant name to IS_VARIANT parameter.

Before using this, the variant should be created and saved in the ALV grid.

Thanks and Regards,

Lakshmi.

Former Member
0 Kudos

Hi

If u transfer the ALV variant (chosen in selection-screen) to the fm ALV, the layout will be in according to the variant: this doesn't depend on how the report runs: online or background.

If u don't transfer any variant, the fm will use the default one.

DATA: GT_VARIANT TYPE DISVARIANT.

PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT.

AT SELECTION-SCREEN.
  DATA: GX_VARIANT TYPE DISVARIANT.

  IF NOT P_VARI IS INITIAL.
    MOVE GT_VARIANT TO GX_VARIANT.
    MOVE: P_VARI         TO GX_VARIANT-VARIANT,
          SY-REPID       TO GX_VARIANT-REPORT.
    CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
         EXPORTING
              I_SAVE     = 'A'
         CHANGING
              CS_VARIANT = GX_VARIANT.
    GT_VARIANT = GX_VARIANT.
  ELSE.
     CLEAR GT_VARIANT.
    GT_VARIANT-REPORT = SY-REPID.
    GT_VARIANT-USERNAME = SY-UNAME. 
  ENDIF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.

  GT_VARIANT-REPORT   = SY-REPID.
  GT_VARIANT-USERNAME = SY-UNAME.
  CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
       EXPORTING
            IS_VARIANT = GT_VARIANT
            I_SAVE     = 'A'
       IMPORTING
            E_EXIT     = GT_EXIT
            ES_VARIANT = GX_VARIANT
       EXCEPTIONS
            NOT_FOUND  = 2.
  IF SY-SUBRC = 2.
    MESSAGE ID SY-MSGID TYPE 'S'      NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    CLEAR: GT_VARIANT, GX_VARIANT.
  ELSE.
    IF GT_EXIT = SPACE.
      P_VARI = GX_VARIANT-VARIANT.
    ENDIF.
  ENDIF.

START-OF-SELECTION.

  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
          ....................
          I_SAVE                   = 'A'
         IS_VARIANT               = GT_VARIANT
         ...................

The code above it's good for all ALV type: so for grid and oop ALV

Max