2 Replies Latest reply: Feb 29, 2012 11:48 AM by venkat lakshmikanth tumu RSS

ALV + layout varient on selection screen

newbie82 c
Currently Being Moderated

hiii

 

with ALV list i want to know with how to allow to put the layout on the selection screen and when user press F4 he will be able to use the list of layout he has save on the ALV output

 

Note for the layout button to appear i had to activate shown below:

i_save                   = c_x

 

please give me sample code where user can choose layout on selection screen and this layout will be used to display on ALV

  • Re: ALV + layout varient on selection screen
    Sriram Ponna
    Currently Being Moderated

    Hi,

     

    Please refer the code below for layout variants :

    DATA:   gt_rsparams  TYPE TABLE OF rsparams.
    
    * Data for ALV variant
    DATA  gv_repname          LIKE sy-repid.
    DATA  gv_x_variant        LIKE disvariant.
    DATA  gv_exit(1)          TYPE c.
    DATA  gv_save(1)          TYPE c.
    DATA  gv_variant          LIKE disvariant.
    
    PARAMETERS: sp_vari LIKE disvariant-variant.        "Dispaly Variant
    
    
    INITIALIZATION.
    
      gv_repname = sy-repid.
      REFRESH : gt_glacct,
                gr_rcomp,
                gt_output,
                gt_fieldcat,
                gt_sort.
    
    * Initialize ALV Layout variant
      PERFORM f_initialize_variant.
    
    
    FORM f_initialize_variant .
    
      CLEAR gv_variant.
      gv_save           = 'X'.
      gv_variant-report = gv_repname.
      gv_x_variant      = gv_variant.
    
      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
        EXPORTING
          i_save     = gv_save
        CHANGING
          cs_variant = gv_x_variant
        EXCEPTIONS
          not_found  = 2.
    
      IF sy-subrc = 0.
    
        sp_vari = gv_x_variant-variant.
    
      ENDIF.
    
    ENDFORM.                    " f_initialize_variant
    
    
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR sp_vari.
      PERFORM f_f4_for_variant.
    
    FORM f_f4_for_variant .
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant = gv_variant
          i_save     = gv_save
        IMPORTING
          e_exit     = gv_exit
          es_variant = gv_x_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.
      ELSE.
        IF gv_exit = space.
          sp_vari = gv_x_variant-variant.
        ENDIF.
      ENDIF.
    
    ENDFORM.                    " f_f4_for_variant
    
    AT SELECTION-SCREEN.
    
    *  Validating selection screen fields
      PERFORM f_at_selection_screen.
    
    FORM f_at_selection_screen .
    
    * ALV Layout variant
      IF NOT sp_vari IS INITIAL.
    
        MOVE gv_variant TO gv_x_variant.
        MOVE sp_vari    TO gv_x_variant-variant.
    
        CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
          EXPORTING
            i_save     = gv_save
          CHANGING
            cs_variant = gv_x_variant.
        gv_variant = gv_x_variant.
    
      ELSE.
    
        PERFORM f_initialize_variant.
    
      ENDIF.
    
    FORM f_initialize_variant .
    
      CLEAR gv_variant.
      gv_save           = 'X'.
      gv_variant-report = gv_repname.
      gv_x_variant      = gv_variant.
    
      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
        EXPORTING
          i_save     = gv_save
        CHANGING
          cs_variant = gv_x_variant
        EXCEPTIONS
          not_found  = 2.
    
      IF sy-subrc = 0.
    
        sp_vari = gv_x_variant-variant.
    
      ENDIF.
    
    ENDFORM.                    " f_initialize_variant

     

    Thanks,

    Sriram POnna.

  • Re: ALV + layout varient on selection screen
    venkat lakshmikanth tumu
    Currently Being Moderated

    hi

    Please look at the code below.

     

     

    SELECTION-SCREEN BEGIN OF BLOCK LISTE WITH FRAME TITLE TEXT-052.

      PARAMETERS: alv_def LIKE DISVARIANT-VARIANT.

    SELECTION-SCREEN END OF BLOCK LISTE.

     

    *----


    F4-Hilfe für Reportvariante -


    *

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR alv_def.

      PERFORM alv_f4.

     

     

    form alv_f4.

      alv_variant-report = alv_repid.

      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

        EXPORTING

          is_variant = alv_variant

          i_save     = 'A'

        IMPORTING

          es_variant = alv_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.

      ELSE.

        alv_def = alv_variant-variant.

      ENDIF.

    ENDFORM.

     

    Regards,

    Lakshmikanth

     

    Edited by: venkat lakshmikanth tumu on Feb 28, 2008 8:23 PM

     

Actions