Skip to Content
author's profile photo Former Member
Former Member

ALV Layout variant as input in selection screen

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 ?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jun 06, 2008 at 09:25 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 06, 2008 at 09:26 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.