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 report

Former Member
0 Likes
921

Hi Experts,

Is it possible to keep a check box in grid display.If possible can u tell how to do..Any simple sample program.

1 ACCEPTED SOLUTION
Read only

Former Member

Hi Experts,

Is it possible to keep a check box in grid display.If possible can u tell how to do..Any simple sample program.

6 REPLIES 6
Read only

Former Member
Read only

former_member386202
Active Contributor
0 Likes
891

Hi,

In fieldcatalog there are one field named checkbox, just pass X to that field.

wa_fieldcat-checkbox = 'X'.

append wa_fieldcat to it_fieldcat.

Regards,

Prashant

Read only

Former Member
0 Likes
891

Hi,

Check the following code.

type-pools: slis.

types:

begin of ty_output,

chk type c,

number type i,

name(20) type c,

end of ty_output.

data: gt_output type standard table of ty_output,

gs_output type ty_output.

data: wa_layout type slis_layout_alv.

data: it_fieldcatalog type slis_t_fieldcat_alv,

wa_fieldcatalog type slis_fieldcat_alv.

*initialization.

data p_selfld type slis_selfield.

data ok_code type sy-ucomm.

controls: tc_display type tableview using screen '0100'.

selection-screen begin of block b2 with frame title text-b02.

parameters:

r_grid radiobutton group g1,

r_list radiobutton group g1 default 'X'.

selection-screen end of block b2.

start-of-selection.

perform get_data.

if r_grid is not initial.

perform alv_grid.

else.

perform alv_list.

endif.

&----


*& Form USER_COMMAND

&----


form user_command_grid using p_ucomm type sy-ucomm

p_selfld type slis_selfield.

data ref1 type ref to cl_gui_alv_grid.

call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'

importing

e_grid = ref1.

call method ref1->check_changed_data.

case p_ucomm.

when 'HELLO'.

delete gt_output where chk = space.

call screen 100.

  • WHEN OTHERS.

  • WRITE: 'hi'.

endcase.

endform. "user_command

&----


*& Form USER_COMMAND

&----


form user_command_list using p_ucomm type sy-ucomm

p_selfld type slis_selfield.

case p_ucomm.

when 'HELLO'.

delete gt_output where chk = space.

call screen 100.

when 'BACK' or 'EXIT'.

leave to screen 0.

endcase.

endform. "user_command

&----


*& Form set_pf_status

&----


  • text

----


form pf_status using pa_extab type slis_t_extab.

p_selfld-refresh = 'X'.

set pf-status 'STATUS'.

p_selfld-refresh = 'X'.

endform. "SET_PF_STATUS

&----


*& Form alv_grid

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form alv_grid .

perform grid_catlog.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = sy-repid

i_callback_pf_status_set = 'PF_STATUS'

i_callback_user_command = 'USER_COMMAND_GRID'

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

is_layout = wa_layout

it_fieldcat = it_fieldcatalog

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

tables

t_outtab = gt_output

  • 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.

endform. " alv_grid

&----


*& Form alv_list

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form alv_list .

perform list_catlog.

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

i_callback_program = sy-repid

i_callback_pf_status_set = 'PF_STATUS'

i_callback_user_command = 'USER_COMMAND_LIST'

  • I_STRUCTURE_NAME =

is_layout = wa_layout

it_fieldcat = it_fieldcatalog

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

tables

t_outtab = gt_output

  • 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.

endform. " alv_list

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


module status_0100 output.

set pf-status 'STATUS2'.

  • SET TITLEBAR 'xxx'.

endmodule. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


module user_command_0100 input.

case ok_code.

when 'BACK' or 'EXIT'.

perform get_data.

leave to screen 0.

endcase.

endmodule. " USER_COMMAND_0100 INPUT

&----


*& Form get_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_data .

clear gs_output.

refresh gt_output.

gs_output-number = 1000.

gs_output-name = 'TEST1'.

append gs_output to gt_output.

gs_output-number = 1001.

gs_output-name = 'TEST1'.

append gs_output to gt_output.

gs_output-number = 1002.

gs_output-name = 'TEST2.

append gs_output to gt_output.

gs_output-number = 1003.

gs_output-name = 'TEST3'.

append gs_output to gt_output.

gs_output-number = 1004.

gs_output-name = 'TEST4.

append gs_output to gt_output.

endform. " get_data

&----


*& Form grid_catlog

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form grid_catlog .

wa_fieldcatalog-fieldname = 'CHK'.

wa_fieldcatalog-outputlen = '3'.

wa_fieldcatalog-col_pos = '1'.

wa_fieldcatalog-seltext_m = 'CHK'.

wa_fieldcatalog-checkbox = 'X'.

wa_fieldcatalog-edit = 'X'.

append wa_fieldcatalog to it_fieldcatalog.

clear wa_fieldcatalog.

perform list_catlog.

endform. " grid_catlog

&----


*& Form list_catlog

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form list_catlog .

wa_fieldcatalog-fieldname = 'NUMBER'.

wa_fieldcatalog-outputlen = '10'.

wa_fieldcatalog-col_pos = '2'.

wa_fieldcatalog-seltext_m = 'NUMBER'.

append wa_fieldcatalog to it_fieldcatalog.

clear wa_fieldcatalog.

wa_fieldcatalog-fieldname = 'NAME'.

wa_fieldcatalog-outputlen = '10'.

wa_fieldcatalog-col_pos = '3'.

wa_fieldcatalog-seltext_m = 'NAME'.

append wa_fieldcatalog to it_fieldcatalog.

clear wa_fieldcatalog.

wa_layout-box_fieldname = 'CHK' .

wa_layout-box_tabname = 'GT_OUTPUT' .

endform. " list_catlog

Read only

Former Member
0 Likes
891

HI Mahesh

When you fill the work area for layout say, wa_layout, set this parameter.

wa_layout-sel_mode = 'A'.

This will automatically give check boxes for user selection. No need to make any field as a checkbox.

Regards

Sharath.

Read only

Former Member
0 Likes
891

Thanks

Read only

0 Likes
891

Hi

I coulod see your query is answered. Let us know what was the fix you have used.

Regards

Sharath.