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: 

Choose Layout option in the selection screen

Former Member
0 Kudos

Hai Friends,

I am displaying my report in ALV. I want to give a Layout option in the selection screen as in FAGLL03. How can i do this?.

3 REPLIES 3

Former Member
0 Kudos

Add the display variant as a parameter on the selection screen.and then call FM REUSE_ALV_VARIANT_F4 when the user presses F4 for the variant.

Rob

Former Member
0 Kudos

HI,

Firt create a parameter as shown below and then use a FM to get the values of the variants


DATA  G_VARIANT      LIKE DISVARIANT.
PARAMETERS P_VAR LIKE DISVARIANT-VARIANT.

INITIALIZATION.
G_VARIANT-REPORT = SY-REPID.

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.
In your FM REUSE_ALV_GRID_DISPLAY, pass G_VARIANT to the parameter IS_VARIANT of the FM.

Hope this helps.

Regards,

Sachin

Former Member
0 Kudos

Steps are as follows :

1. On selection screen create the parameter :

SELECTION-SCREEN BEGIN OF BLOCK blk3 WITH FRAME TITLE text-021.

*-- Parameters for ALV display

PARAMETERS: p_layout TYPE variant.

SELECTION-SCREEN END OF BLOCK blk3.

2. Attach F4 help to this parameter using FM

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

is_variant = gw_alv_variant

i_save = 'A'

IMPORTING

es_variant = gw_alv_variant

EXCEPTIONS

not_found = 1

program_error = 2

OTHERS = 3.

3. Set this layout for initial display of ALV . Otherwise there is no meaning to use the layout option.

*-- Set Layout

CALL METHOD go_layout->set_initial_layout

EXPORTING

value = p_layout .

Hope it helps you.