Application Development and Automation 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: 
Read only

ALV Layout

Former Member
0 Likes
538

Hi gurus,

In the program I've some fields like : f1, f2, f3,f4,f5 and I create fieldcat for these fields. When calling ALV_GRID_DISPLAY all the fields will be displayed, but our client wants that , by default just f1,f2,f3 displayed, howerver they can select the others fields such as : f3, f4 to be displayed and saved as variant, could you please show me how to do this

Thanks in advance

1 ACCEPTED SOLUTION
Read only

venkat_o
Active Contributor
0 Likes
494

Hi, <li>Just execute the below program without giving anything on the selection screen.

 REPORT  ztest_notepad.
 DATA: BEGIN OF it_t100 OCCURS 0,
         sprsl TYPE t100-sprsl,
         arbgb TYPE t100-arbgb,
         msgnr TYPE t100-msgnr,
         text TYPE t100-text,
       END OF it_t100.
 TYPE-POOLS :slis.
 DATA:wa_variant TYPE disvariant.
 PARAMETERS : p_var TYPE disvariant-variant.
"F4 help for Variant
 AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_var.
   DATA:g_exit.
   wa_variant-report = sy-repid.
   CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
     EXPORTING
       is_variant = wa_variant
       i_save     = 'X'
     IMPORTING
       e_exit     = g_exit
       es_variant = wa_variant.
   IF sy-subrc EQ 0.
     IF g_exit = space.
       p_var = wa_variant-variant.
     ENDIF.
   ENDIF.
 "START-OF-SELECTION
 START-OF-SELECTION.
   SELECT * FROM t100 INTO TABLE it_t100 UP TO 100 ROWS.
   CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
     EXPORTING
       i_callback_program = sy-repid
       i_structure_name   = 'T100'
       i_default          = 'X'        "Initial variant active
       i_save             = 'X'        "Display variants can be saved as standard display variants.
       is_variant         = wa_variant
     TABLES
       t_outtab           = it_t100.
<li>To save layouts follow the screen shots below [ screen 1|http://2.bp.blogspot.com/_O5f8iAlgdNQ/SmbgDhz7vdI/AAAAAAAAFDI/xp7xxBdxWDo/s1600-h/1-714796.JPG] [screen 2|http://3.bp.blogspot.com/_O5f8iAlgdNQ/SmbgENdq9BI/AAAAAAAAFDY/Z8SnywJz9Rc/s1600-h/3-716761.JPG] [ screen 3|http://3.bp.blogspot.com/_O5f8iAlgdNQ/SmbgEXxtY-I/AAAAAAAAFDg/APxJMLrB_CM/s1600-h/4-717734.JPG] [screen 4|http://3.bp.blogspot.com/_O5f8iAlgdNQ/SmbgEyxfXfI/AAAAAAAAFDw/3IHLF0hymlo/s1600-h/6-719115.JPG] I hope that you will get it. Thanks Venkat.O

Hi gurus,

In the program I've some fields like : f1, f2, f3,f4,f5 and I create fieldcat for these fields. When calling ALV_GRID_DISPLAY all the fields will be displayed, but our client wants that , by default just f1,f2,f3 displayed, howerver they can select the others fields such as : f3, f4 to be displayed and saved as variant, could you please show me how to do this

Thanks in advance

3 REPLIES 3
Read only

venkat_o
Active Contributor
0 Likes
495

Hi, <li>Just execute the below program without giving anything on the selection screen.

 REPORT  ztest_notepad.
 DATA: BEGIN OF it_t100 OCCURS 0,
         sprsl TYPE t100-sprsl,
         arbgb TYPE t100-arbgb,
         msgnr TYPE t100-msgnr,
         text TYPE t100-text,
       END OF it_t100.
 TYPE-POOLS :slis.
 DATA:wa_variant TYPE disvariant.
 PARAMETERS : p_var TYPE disvariant-variant.
"F4 help for Variant
 AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_var.
   DATA:g_exit.
   wa_variant-report = sy-repid.
   CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
     EXPORTING
       is_variant = wa_variant
       i_save     = 'X'
     IMPORTING
       e_exit     = g_exit
       es_variant = wa_variant.
   IF sy-subrc EQ 0.
     IF g_exit = space.
       p_var = wa_variant-variant.
     ENDIF.
   ENDIF.
 "START-OF-SELECTION
 START-OF-SELECTION.
   SELECT * FROM t100 INTO TABLE it_t100 UP TO 100 ROWS.
   CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
     EXPORTING
       i_callback_program = sy-repid
       i_structure_name   = 'T100'
       i_default          = 'X'        "Initial variant active
       i_save             = 'X'        "Display variants can be saved as standard display variants.
       is_variant         = wa_variant
     TABLES
       t_outtab           = it_t100.
<li>To save layouts follow the screen shots below [ screen 1|http://2.bp.blogspot.com/_O5f8iAlgdNQ/SmbgDhz7vdI/AAAAAAAAFDI/xp7xxBdxWDo/s1600-h/1-714796.JPG] [screen 2|http://3.bp.blogspot.com/_O5f8iAlgdNQ/SmbgENdq9BI/AAAAAAAAFDY/Z8SnywJz9Rc/s1600-h/3-716761.JPG] [ screen 3|http://3.bp.blogspot.com/_O5f8iAlgdNQ/SmbgEXxtY-I/AAAAAAAAFDg/APxJMLrB_CM/s1600-h/4-717734.JPG] [screen 4|http://3.bp.blogspot.com/_O5f8iAlgdNQ/SmbgEyxfXfI/AAAAAAAAFDw/3IHLF0hymlo/s1600-h/6-719115.JPG] I hope that you will get it. Thanks Venkat.O

Read only

Former Member
0 Likes
494

hi,

use 'REUSE_ALV_VARIANT_F4'

Please refer this similar thread

thanks

Read only

Former Member
0 Likes
494

Hi ,

You can make fields f3 and f4 as invisible while creating field catalog, collect the data for the same.

When user selects the option to view them. Just make these visible.

Hope it Helps you.