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

Change layout in ALV

Former Member
0 Likes
5,721

Hi all..

I got this table contain 5 field. All these fields are output in the ALV.

How can i hide default 2 field instead on screen load. Only display the neccessary 3 field out. But when the user click on the change layout button, he can choose whatever field to be display as he like.

How can i achieve it?

Thks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,907

Hi,

You can do as below :

While building your fieldcatalog for all the fields, for that fields that should be in change layout for that fields you can use the code as gs_fieldcat-no_out = 'X'.

Thanks,

Sriram Ponna.

7 REPLIES 7
Read only

Former Member
0 Likes
2,907

Hi,

use this logic.

data: variant type disvariant.

start-of-selection.

variant-report = sy-repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy_repid

it_fieldcat = ist_fcat[]

i_save = 'X'

is_variant = variant

TABLES

t_outtab = ist_main[]

EXCEPTIONS

program_error = 1

OTHERS = 2

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

regards,

Santosh Thorat

Read only

Former Member
0 Likes
2,907

.

Edited by: Dhwani shah on Jan 22, 2008 11:09 AM

Read only

Former Member
0 Likes
2,907

Hi,

USe the following code

fill the defaule variant tab as below with required fields as below.

FORM check_fieldcat_variant_l.

DATA h_fieldcat_wa TYPE slis_fieldcat_alv.

DATA h_index LIKE sy-tabix.

h_index = 1.

DESCRIBE TABLE g_selfields_tab LINES sy-tabix.

IF sy-tabix IS INITIAL.

LOOP AT g_fieldcat_tab INTO h_fieldcat_wa.

CASE h_fieldcat_wa-fieldname.

WHEN 'PM_SELECTED'.

h_fieldcat_wa-no_out = space.

h_fieldcat_wa-col_pos = 1.

WHEN 'Z_RSLID'.

h_fieldcat_wa-no_out = space.

h_fieldcat_wa-col_pos = 2.

WHEN 'Z_FUNLC'.

h_fieldcat_wa-no_out = space.

h_fieldcat_wa-col_pos = 3.

WHEN 'Z_SMPDS'.

h_fieldcat_wa-no_out = space.

h_fieldcat_wa-col_pos = 4.

WHEN 'Z_SCHDT'.

h_fieldcat_wa-no_out = space.

h_fieldcat_wa-col_pos = 5.

WHEN 'Z_SCHTM'.

h_fieldcat_wa-no_out = space.

h_fieldcat_wa-col_pos = 6.

WHEN 'Z_ANLYT'.

h_fieldcat_wa-no_out = space.

h_fieldcat_wa-col_pos = 7.

WHEN OTHERS.

h_fieldcat_wa-no_out = g_x.

ENDCASE.

MODIFY g_fieldcat_tab FROM h_fieldcat_wa.

ENDLOOP.

ENDIF.

ENDFORM. " CHECK_FIELDCAT_VARIANT_L

and pass the that intrnal table in the following FM

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_buffer_active = g_alv_buffer

i_callback_program = g_repid

i_callback_pf_status_set = g_form_set_pf_stat

  • I_CALLBACK_USER_COMMAND = ' '

  • I_STRUCTURE_NAME =

is_layout = g_layout

it_fieldcat = g_fieldcat_tab[]

  • it_excluding =

it_special_groups = g_fieldgroups_tab[]

it_sort = g_sortfields_tab[]

  • it_filter =

  • is_sel_hide =

i_default = g_n

  • i_save = g_variant_save

i_save = g_a

is_variant = g_variant

it_events = g_events_tab[]

it_event_exit = g_event_exit_tab[]

is_print = g_print

i_screen_start_column = g_screen_start_column

i_screen_start_line = g_screen_start_line

i_screen_end_column = g_screen_end_column

i_screen_end_line = g_screen_end_line

it_except_qinfo = gt_qinf

  • importing

  • e_exit_caused_by_caller =

TABLES

t_outtab = object_tab

  • t_outtab = it_display

EXCEPTIONS

program_error = 1

OTHERS = 2.

Reward points if useful

Thanks,

Nageswar

Read only

Former Member
0 Likes
2,908

Hi,

You can do as below :

While building your fieldcatalog for all the fields, for that fields that should be in change layout for that fields you can use the code as gs_fieldcat-no_out = 'X'.

Thanks,

Sriram Ponna.

Read only

0 Likes
2,907

if i code gs_fieldcat-no_out = 'X', will it affect the user when he want to display that field when he click on the change layout button and choose that field to be shown. Will the field still be shown or not shown?

Read only

0 Likes
2,907

Thx i tested it worked.

Read only

0 Likes
2,907

Hi,

Due to this code, I field will be in the change layout, once the report is displayed you can choose the other fields by selecting change layout, if yuo select those fields in the change layout, that fields will be displayed in the repoer.

Thanks,

Sriram Ponna.