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

Regarding ALV grid

Former Member
0 Likes
755

Hi experts

I need the push button column to be displayed as the first column to select the rows. I have set the SEL_MODE field of lvc_s_layo structure as 'A'. But its not helping. Could u please suggest.

Best Regards

Anand.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
722

Hello Anand,

You can easily insert check box before each and every record in grid alv.

layout is having a field call box_fieldname where we have to give the fieldname which is of lengh one and shoud be internal table.

 g_r_layout-box_fieldname     = 'SEL'.

for reference... i'ms sending my code... go thru that....

report zssr_alv_list_display .

*----


  • TYPE-POOLS

*----


type-pools: slis. " Type pool for ALV

*----


  • Tables

*----


tables: vbak, vbap.

*----


  • INTERNAL TABLES

*----


data: begin of g_t_itab occurs 0,

<b>sel type c,</b>

vbeln like vbak-vbeln,

erdat like vbak-erdat,

vbtyp like vbak-vbtyp,

vkorg like vbak-vkorg,

vtweg like vbak-vtweg,

spart like vbak-spart,

netwr like vbak-netwr,

kunnr like vbak-kunnr,

end of g_t_itab.

data: begin of g_t_item occurs 0,

vbeln like vbap-vbeln,

posnr like vbap-posnr,

matnr like vbap-matnr,

arktx like vbap-arktx,

end of g_t_item.

  • Data fields used for ALV call - simple list

data : g_f_repid like sy-repid.

data : g_t_fieldcat type slis_t_fieldcat_alv.

data : g_r_fieldcat type slis_fieldcat_alv.

data : g_t_events type slis_t_event.

data : g_r_events type slis_alv_event.

data : g_r_layout type slis_layout_alv.

data : g_r_x_variant like disvariant.

data : g_r_variant like disvariant.

data : g_f_exit(1) type c.

data : g_f_save(1) type c.

*----


  • SELECTION SCREEN

*----


selection-screen begin of block b1 with frame title text-001.

select-options: s_vbeln for vbak-vbeln.

selection-screen end of block b1.

*----


  • START OF SELECTION

*----


start-of-selection.

perform get_data.

*----


  • END OF SELECTION

*----


end-of-selection.

perform set_alv_parameters.

perform display_list.

&----


*& Form get_data

&----


  • Get data from DB tables

----


form get_data.

clear: g_t_itab.

refresh: g_t_itab.

select vbeln erdat vbtyp vkorg vtweg spart netwr kunnr

from vbak

into corresponding fields of table g_t_itab

where

vbeln in s_vbeln.

endform. " get_data

&----


*& Form set_alv_parameters

&----


  • Set alv parameters , layout, events, fieldcatlog

----


form set_alv_parameters.

perform set_filedcatlog.

  • Events

refresh : g_t_events.

clear : g_r_events.

  • Top of Page event for standard header

g_r_events-name = 'TOP_OF_PAGE'.

g_r_events-form = 'TOP_OF_PAGE'.

append g_r_events to g_t_events.

  • Attributes for layout

g_r_layout-zebra = 'X'.

g_r_layout-min_linesize = 119.

g_r_layout-colwidth_optimize = 'X'.

  • g_r_layout-detail_initial_lines = 'X'.

  • g_r_layout-get_selinfos = 'X'.

  • g_r_layout-group_change_edit = 'X'.

<b>* Field having the check box

g_r_layout-box_fieldname = 'SEL'.</b>

  • Field having the checkbox internal table name

g_r_layout-box_tabname = 'G_T_ITAB'.

endform. " set_alv_parameters

&----


*& Form display_list

&----


  • text

----


form display_list.

g_f_repid = sy-repid.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

i_callback_program = g_f_repid

  • i_callback_pf_status_set = 'PF_STATUS_SET'

  • i_callback_user_command = 'USER_COMMAND'

  • I_STRUCTURE_NAME =

is_layout = g_r_layout

it_fieldcat = g_t_fieldcat[]

  • IS_LAYOUT =

  • IT_FIELDCAT =

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • i_save = g_f_save

  • is_variant = g_r_variant

it_events = g_t_events[]

  • 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

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

tables

t_outtab = g_t_itab

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. " display_list

&----


*& Form set_filedcatlog

&----


  • text

----


form set_filedcatlog.

data: l_r_fieldcat type slis_fieldcat_alv. " For column heading

clear : g_t_fieldcat,

g_t_fieldcat[].

  • check - box

  • l_r_fieldcat-tabname = 'G_T_ITAB'.

  • l_r_fieldcat-fieldname = 'SEL'.

  • l_r_fieldcat-col_pos = 1.

  • append l_r_fieldcat to g_t_fieldcat.

  • clear l_r_fieldcat.

  • Sales Order

l_r_fieldcat-tabname = 'G_T_ITAB'.

l_r_fieldcat-fieldname = 'VBELN'.

l_r_fieldcat-ref_tabname = 'VBAK'.

l_r_fieldcat-ref_fieldname = 'VBELN'.

l_r_fieldcat-no_out = ' '.

l_r_fieldcat-input = ' '.

l_r_fieldcat-key = 'X'.

l_r_fieldcat-col_pos = 2.

  • l_r_fieldcat-seltext_m = 'Sales Order'.

append l_r_fieldcat to g_t_fieldcat.

clear l_r_fieldcat.

  • Creation date

l_r_fieldcat-tabname = 'G_T_ITAB'.

l_r_fieldcat-fieldname = 'ERDAT'.

l_r_fieldcat-ref_tabname = 'VBAK'.

l_r_fieldcat-ref_fieldname = 'ERDAT'.

l_r_fieldcat-col_pos = 3.

append l_r_fieldcat to g_t_fieldcat.

clear l_r_fieldcat.

  • document category

l_r_fieldcat-tabname = 'G_T_ITAB'.

l_r_fieldcat-fieldname = 'VBTYP'.

l_r_fieldcat-ref_tabname = 'VBAK'.

l_r_fieldcat-ref_fieldname = 'VBTYP'.

l_r_fieldcat-col_pos = 4.

append l_r_fieldcat to g_t_fieldcat.

clear l_r_fieldcat.

  • Sales organization

l_r_fieldcat-tabname = 'G_T_ITAB'.

l_r_fieldcat-fieldname = 'VKORG'.

l_r_fieldcat-ref_tabname = 'VBAK'.

l_r_fieldcat-ref_fieldname = 'VKORG'.

l_r_fieldcat-col_pos = 5.

append l_r_fieldcat to g_t_fieldcat.

clear l_r_fieldcat.

  • Distribution channel

l_r_fieldcat-tabname = 'G_T_ITAB'.

l_r_fieldcat-fieldname = 'VTWEG'.

l_r_fieldcat-ref_tabname = 'VBAK'.

l_r_fieldcat-ref_fieldname = 'VTWEG'.

l_r_fieldcat-col_pos = 6.

append l_r_fieldcat to g_t_fieldcat.

clear l_r_fieldcat.

  • Division

l_r_fieldcat-tabname = 'G_T_ITAB'.

l_r_fieldcat-fieldname = 'SPART'.

l_r_fieldcat-ref_tabname = 'VBAK'.

l_r_fieldcat-ref_fieldname = 'SPART'.

l_r_fieldcat-col_pos = 7.

append l_r_fieldcat to g_t_fieldcat.

clear l_r_fieldcat.

  • Net Value

l_r_fieldcat-tabname = 'G_T_ITAB'.

l_r_fieldcat-fieldname = 'NETWR'.

l_r_fieldcat-ref_tabname = 'VBAK'.

l_r_fieldcat-ref_fieldname = 'NETWR'.

l_r_fieldcat-do_sum = 'X'.

l_r_fieldcat-col_pos = 8.

l_r_fieldcat-emphasize = 'C500'.

append l_r_fieldcat to g_t_fieldcat.

clear l_r_fieldcat.

  • Distribution channel

l_r_fieldcat-tabname = 'G_T_ITAB'.

l_r_fieldcat-fieldname = 'KUNNR'.

l_r_fieldcat-ref_tabname = 'VBAK'.

l_r_fieldcat-ref_fieldname = 'KUNNR'.

l_r_fieldcat-col_pos = 9.

append l_r_fieldcat to g_t_fieldcat.

clear l_r_fieldcat.

endform. " set_filedcatlog

----


  • FORM top_of_page *

----


form top_of_page.

data : l_r_listheader type slis_t_listheader,

l_r_line type slis_listheader.

clear l_r_line.

l_r_line-typ = 'H'.

l_r_line-info = 'Sales details'.

append l_r_line to l_r_listheader.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = l_r_listheader

  • I_LOGO =

  • I_END_OF_LIST_GRID =.

.

endform.

5 REPLIES 5
Read only

Former Member
0 Likes
722

Hi,

Instead of 'A', assign value 'X'.

Thanks and Best Regards,

Vikas Bittera.

Read only

0 Likes
722

Hi Vikas

The allowable values for SEL_MODE field are SPACE, 'A','B','C' and 'D'.

Regards

Anand

Read only

Former Member
0 Likes
722

Hi,

To my knowledge , I think it is not possible, to do in ALV Grid display.

Reward if useful.

Read only

Former Member
0 Likes
723

Hello Anand,

You can easily insert check box before each and every record in grid alv.

layout is having a field call box_fieldname where we have to give the fieldname which is of lengh one and shoud be internal table.

 g_r_layout-box_fieldname     = 'SEL'.

for reference... i'ms sending my code... go thru that....

report zssr_alv_list_display .

*----


  • TYPE-POOLS

*----


type-pools: slis. " Type pool for ALV

*----


  • Tables

*----


tables: vbak, vbap.

*----


  • INTERNAL TABLES

*----


data: begin of g_t_itab occurs 0,

<b>sel type c,</b>

vbeln like vbak-vbeln,

erdat like vbak-erdat,

vbtyp like vbak-vbtyp,

vkorg like vbak-vkorg,

vtweg like vbak-vtweg,

spart like vbak-spart,

netwr like vbak-netwr,

kunnr like vbak-kunnr,

end of g_t_itab.

data: begin of g_t_item occurs 0,

vbeln like vbap-vbeln,

posnr like vbap-posnr,

matnr like vbap-matnr,

arktx like vbap-arktx,

end of g_t_item.

  • Data fields used for ALV call - simple list

data : g_f_repid like sy-repid.

data : g_t_fieldcat type slis_t_fieldcat_alv.

data : g_r_fieldcat type slis_fieldcat_alv.

data : g_t_events type slis_t_event.

data : g_r_events type slis_alv_event.

data : g_r_layout type slis_layout_alv.

data : g_r_x_variant like disvariant.

data : g_r_variant like disvariant.

data : g_f_exit(1) type c.

data : g_f_save(1) type c.

*----


  • SELECTION SCREEN

*----


selection-screen begin of block b1 with frame title text-001.

select-options: s_vbeln for vbak-vbeln.

selection-screen end of block b1.

*----


  • START OF SELECTION

*----


start-of-selection.

perform get_data.

*----


  • END OF SELECTION

*----


end-of-selection.

perform set_alv_parameters.

perform display_list.

&----


*& Form get_data

&----


  • Get data from DB tables

----


form get_data.

clear: g_t_itab.

refresh: g_t_itab.

select vbeln erdat vbtyp vkorg vtweg spart netwr kunnr

from vbak

into corresponding fields of table g_t_itab

where

vbeln in s_vbeln.

endform. " get_data

&----


*& Form set_alv_parameters

&----


  • Set alv parameters , layout, events, fieldcatlog

----


form set_alv_parameters.

perform set_filedcatlog.

  • Events

refresh : g_t_events.

clear : g_r_events.

  • Top of Page event for standard header

g_r_events-name = 'TOP_OF_PAGE'.

g_r_events-form = 'TOP_OF_PAGE'.

append g_r_events to g_t_events.

  • Attributes for layout

g_r_layout-zebra = 'X'.

g_r_layout-min_linesize = 119.

g_r_layout-colwidth_optimize = 'X'.

  • g_r_layout-detail_initial_lines = 'X'.

  • g_r_layout-get_selinfos = 'X'.

  • g_r_layout-group_change_edit = 'X'.

<b>* Field having the check box

g_r_layout-box_fieldname = 'SEL'.</b>

  • Field having the checkbox internal table name

g_r_layout-box_tabname = 'G_T_ITAB'.

endform. " set_alv_parameters

&----


*& Form display_list

&----


  • text

----


form display_list.

g_f_repid = sy-repid.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

i_callback_program = g_f_repid

  • i_callback_pf_status_set = 'PF_STATUS_SET'

  • i_callback_user_command = 'USER_COMMAND'

  • I_STRUCTURE_NAME =

is_layout = g_r_layout

it_fieldcat = g_t_fieldcat[]

  • IS_LAYOUT =

  • IT_FIELDCAT =

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • i_save = g_f_save

  • is_variant = g_r_variant

it_events = g_t_events[]

  • 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

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

tables

t_outtab = g_t_itab

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. " display_list

&----


*& Form set_filedcatlog

&----


  • text

----


form set_filedcatlog.

data: l_r_fieldcat type slis_fieldcat_alv. " For column heading

clear : g_t_fieldcat,

g_t_fieldcat[].

  • check - box

  • l_r_fieldcat-tabname = 'G_T_ITAB'.

  • l_r_fieldcat-fieldname = 'SEL'.

  • l_r_fieldcat-col_pos = 1.

  • append l_r_fieldcat to g_t_fieldcat.

  • clear l_r_fieldcat.

  • Sales Order

l_r_fieldcat-tabname = 'G_T_ITAB'.

l_r_fieldcat-fieldname = 'VBELN'.

l_r_fieldcat-ref_tabname = 'VBAK'.

l_r_fieldcat-ref_fieldname = 'VBELN'.

l_r_fieldcat-no_out = ' '.

l_r_fieldcat-input = ' '.

l_r_fieldcat-key = 'X'.

l_r_fieldcat-col_pos = 2.

  • l_r_fieldcat-seltext_m = 'Sales Order'.

append l_r_fieldcat to g_t_fieldcat.

clear l_r_fieldcat.

  • Creation date

l_r_fieldcat-tabname = 'G_T_ITAB'.

l_r_fieldcat-fieldname = 'ERDAT'.

l_r_fieldcat-ref_tabname = 'VBAK'.

l_r_fieldcat-ref_fieldname = 'ERDAT'.

l_r_fieldcat-col_pos = 3.

append l_r_fieldcat to g_t_fieldcat.

clear l_r_fieldcat.

  • document category

l_r_fieldcat-tabname = 'G_T_ITAB'.

l_r_fieldcat-fieldname = 'VBTYP'.

l_r_fieldcat-ref_tabname = 'VBAK'.

l_r_fieldcat-ref_fieldname = 'VBTYP'.

l_r_fieldcat-col_pos = 4.

append l_r_fieldcat to g_t_fieldcat.

clear l_r_fieldcat.

  • Sales organization

l_r_fieldcat-tabname = 'G_T_ITAB'.

l_r_fieldcat-fieldname = 'VKORG'.

l_r_fieldcat-ref_tabname = 'VBAK'.

l_r_fieldcat-ref_fieldname = 'VKORG'.

l_r_fieldcat-col_pos = 5.

append l_r_fieldcat to g_t_fieldcat.

clear l_r_fieldcat.

  • Distribution channel

l_r_fieldcat-tabname = 'G_T_ITAB'.

l_r_fieldcat-fieldname = 'VTWEG'.

l_r_fieldcat-ref_tabname = 'VBAK'.

l_r_fieldcat-ref_fieldname = 'VTWEG'.

l_r_fieldcat-col_pos = 6.

append l_r_fieldcat to g_t_fieldcat.

clear l_r_fieldcat.

  • Division

l_r_fieldcat-tabname = 'G_T_ITAB'.

l_r_fieldcat-fieldname = 'SPART'.

l_r_fieldcat-ref_tabname = 'VBAK'.

l_r_fieldcat-ref_fieldname = 'SPART'.

l_r_fieldcat-col_pos = 7.

append l_r_fieldcat to g_t_fieldcat.

clear l_r_fieldcat.

  • Net Value

l_r_fieldcat-tabname = 'G_T_ITAB'.

l_r_fieldcat-fieldname = 'NETWR'.

l_r_fieldcat-ref_tabname = 'VBAK'.

l_r_fieldcat-ref_fieldname = 'NETWR'.

l_r_fieldcat-do_sum = 'X'.

l_r_fieldcat-col_pos = 8.

l_r_fieldcat-emphasize = 'C500'.

append l_r_fieldcat to g_t_fieldcat.

clear l_r_fieldcat.

  • Distribution channel

l_r_fieldcat-tabname = 'G_T_ITAB'.

l_r_fieldcat-fieldname = 'KUNNR'.

l_r_fieldcat-ref_tabname = 'VBAK'.

l_r_fieldcat-ref_fieldname = 'KUNNR'.

l_r_fieldcat-col_pos = 9.

append l_r_fieldcat to g_t_fieldcat.

clear l_r_fieldcat.

endform. " set_filedcatlog

----


  • FORM top_of_page *

----


form top_of_page.

data : l_r_listheader type slis_t_listheader,

l_r_line type slis_listheader.

clear l_r_line.

l_r_line-typ = 'H'.

l_r_line-info = 'Sales details'.

append l_r_line to l_r_listheader.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = l_r_listheader

  • I_LOGO =

  • I_END_OF_LIST_GRID =.

.

endform.

Read only

Former Member
0 Likes
722

HI,

just make first field of the internal table (u r using for alv display) as box.

and in layout pass it like that

wa_layout-box_fname = 'BOX'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'

EXPORTING

i_callback_program = g_repid

is_layout_lvc = wa_layout

it_fieldcat_lvc = i_fcat[]

it_events = i_events

TABLES

t_outtab = li_temp

EXCEPTIONS

program_error = 1

OTHERS = 2.

Reward points if found useful,

Thanks,

Gaurav Mittal