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: 

how to set check box in alv

Former Member
0 Kudos
76

Hello Sir,

I am Developing One Report In ALV, But I want One Column Of ALV Should Be In Checkboxes .How Can I set Check Box In Field Catalog.

Plz Help Me.

4 REPLIES 4

Former Member
0 Kudos
40

u follow this logic ...

W_FCAT-checkbox = 'x' is correct, it is used for displaying field as check box.

W_FCAT-COL_POS = 1.

W_FCAT-FIELDNAME = 'KUNNR'.

W_FCAT-SELTEXT_M = 'CUST. NO'.

W_FCAT-HOTSPOT = 'X'. "HOT SPOT HAND SYMBOL

W_FCAT-EMPHASIZE = 'C119'. "FOR COLORING THE COLUMN 1

W_FCAT-checkbox = 'x'.

APPEND W_FCAT TO T_FCAT.

for sample programs follow thsese links

http://www.sapfans.com/forums/viewtopic.php?t=88376

http://www.sapfans.com/forums/viewtopic.php?t=40968

http://www.sapfans.com/forums/viewtopic.php?t=6919

Former Member
0 Kudos
40

Hi anil,

chk my blog if it can help u

/people/community.user/blog/2007/01/10/displaychange-mode-of-editable-fields-in-alv-using-function-modules-but-not-custom-containers

Former Member
0 Kudos
40

hi,

Try like this.

&----


*& Report ZTEST_ALV

*&

&----


*&

*&

&----


REPORT ztest_alv.

*----


  • TYPE-POOLS

*----


TYPE-POOLS: slis. " Type pool for ALV

*----


  • Tables

*----


TABLES: vbak, vbap.

*----


  • INTERNAL TABLES

*----


DATA: BEGIN OF g_t_itab OCCURS 0,

sel TYPE c,

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.

ENDFORM. " set_alv_parameters

&----


*& Form display_list

&----


  • text

----


FORM display_list.

g_f_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = g_f_repid

  • is_layout = g_r_layout

it_fieldcat = g_t_fieldcat[]

it_events = g_t_events[]

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[].

<b> l_r_fieldcat-tabname = 'G_T_ITAB'.

l_r_fieldcat-fieldname = 'SEL'.

l_r_fieldcat-checkbox = 'X'.

l_r_fieldcat-outputlen = 2.

l_r_fieldcat-col_pos = 1.

l_r_fieldcat-edit = 'X'.

l_r_fieldcat-input = 'X'.

APPEND l_r_fieldcat TO g_t_fieldcat.

CLEAR l_r_fieldcat.</b>

  • 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-col_pos = 2.

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-col_pos = 8.

l_r_fieldcat-do_sum = 'X'.

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