2007 Apr 17 1:14 PM
Hi All ,
I have doubt in ALV, How do i create a check box in Alv,
I have a cenario like i have list of purchase order nos in ALV report , but i have materials which are delivered in pallets for few PO, so i need choose a group of PO using check box option and then click on push button then all the selected PO with materials have to converted to boxes and stored in database. how to i do this , pls give detail code for this . thanks in advance
regards,
kumaran.c
2007 Apr 17 3:37 PM
Hi,
see this answered thread:
and this PDF tutorial about ALV Grid:
Message was edited by:
Rodrigo Paisante
2007 Apr 17 1:18 PM
<b>Using ALV LIST</b>
REPORT ABC.
TYPE-POOLS : SLIS.
*-------------- Data
DATA : BEGIN OF ITAB OCCURS 0.
INCLUDE STRUCTURE T001.
DATA : FLAG TYPE C,
END OF ITAB.
DATA : ALVFC TYPE SLIS_T_FIELDCAT_ALV.
DATA : ALVLY TYPE SLIS_LAYOUT_ALV.
*--------- Select Data
SELECT * FROM T001 INTO TABLE ITAB.
LOOP AT ITAB.
IF SY-TABIX = 1.
ITAB-FLAG = '1'.
MODIFY ITAB.
ENDIF.
IF SY-TABIX = 2.
ITAB-FLAG = 'X'.
MODIFY ITAB.
ENDIF.
IF SY-TABIX = 3.
ITAB-FLAG = '0'.
MODIFY ITAB.
ENDIF.
ENDLOOP.
*------- Field Catalogue
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-CPROG
I_INTERNAL_TABNAME = 'ITAB'
I_INCLNAME = SY-CPROG
CHANGING
CT_FIELDCAT = ALVFC
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
*---------------Display
ALVLY-BOX_FIELDNAME = 'FLAG'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
IT_FIELDCAT = ALVFC
I_CALLBACK_PROGRAM = SY-CPROG I_CALLBACK_USER_COMMAND =
'ITAB_USER_COMMAND'
IS_LAYOUT = ALVLY
TABLES
T_OUTTAB = ITAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
*-------------------------------------------------
* CALL BACK FORM
*-------------------------------------------------
FORM ITAB_USER_COMMAND USING WHATCOMM TYPE SY-UCOMM WHATROW TYPE
SLIS_SELFIELD.
DATA : MSG(100) TYPE C.
LOOP AT ITAB.
IF ITAB-FLAG = 'X'.
MSG = SY-TABIX.
CONDENSE MSG.
CONCATENATE 'Row Number ' MSG ' ' INTO MSG
SEPARATED BY SPACE.
*message msg type 'I'.
ENDIF.
ENDLOOP.
ENDFORM. "ITAB_user_command
<b>Using ALV GRID</b>
chk the blog
/people/community.user/blog/2007/01/10/displaychange-mode-of-editable-fields-in-alv-using-function-modules-but-not-custom-containers
<b>Using OO ALV</b>
chk program <b>BCALV_EDIT_05</b>
2007 Apr 17 1:35 PM
Hi kumaran,
1. To get a taste of it,
just copy paste this program.
2. It will display alv (t001)
It will show CHECKBOXES (besides every row)
TICK some rows,
and DOUBLE-CLICK ON any row.
3. It will display all the row numbers which have been checked/ticked.
4.
report abc.
TYPE-POOLS : slis.
*----
Data
DATA : BEGIN OF itab OCCURS 0.
INCLUDE STRUCTURE t001.
DATA : flag tyPE c,
END OF itab.
DATA : alvfc TYPE slis_t_fieldcat_alv.
DATA : alvly TYPE slis_layout_alv.
*----
Select Data
SELECT * FROM t001 INTO TABLE itab.
*------- Field Catalogue
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ITAB'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
*----
Display
alvly-box_fieldname = 'FLAG'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_fieldcat = alvfc
i_callback_program = sy-repid "<-------Important
i_callback_user_command = 'ITAB_USER_COMMAND' "<------ Important
is_layout = alvly
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
*----
CALL BACK FORM
*----
FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE
slis_selfield.
data : msg(100) type c.
LOOP AT itab.
if itab-flag = 'X'.
msg = sy-tabix.
condense msg.
concatenate 'Row Number ' msg ' ' into msg
separated by space.
message msg type 'I'.
endif.
ENDLOOP.
ENDFORM. "ITAB_user_command
regards,
amit m.
2007 Apr 17 3:37 PM
Hi,
see this answered thread:
and this PDF tutorial about ALV Grid:
Message was edited by:
Rodrigo Paisante