‎2007 Aug 05 11:50 AM
HI ALL,
hope all are doing fine...let me tell u abt my requirement..
1. Im working on <b>interactive alv report</b> using <b>function modules(reuse_alv_list_display)</b>...and i have displayed checkboxes in the basic list and in the secondary list i have to display header and item details.
2. As and when i click on check boxes in the basic list,,,i have to get the secondary list ..NOW how to handle checkbox in alv? (i have already displayed checkboxes in the basic list)...the user may click/check 1 or 2 or 3 or all check boxes in the basic list...depending on the number of checkboxes user has selected in the basic list ,,,he has get that number of header and item details.
<b>for example</b>..if i have selected 3 check boxes i have to get 3 header and 3 item details in the secondary list accordingly.
<b>Cud anyone pls provide sample code for the above requirement</b>
3.For displaying header and item details in secondary list im using <b>reuse_alv_hierseq_list_display</b>??</b> Will this function module serve my purpose? or i have to use any other function module?
Pls provide sample codings for my req..!!!
points wil be given for sure..
Thanxalot in Advance....
regards,
jack
‎2007 Aug 05 12:01 PM
Hi,
Follow this example for check box and other more features.
REPORT ZALVSELECT.
TYPE-POOLS : SLIS.
DATA : AFLD TYPE SLIS_T_FIELDCAT_ALV,
LYT TYPE SLIS_LAYOUT_ALV,
REPID LIKE SY-REPID.
DATA : TFLD LIKE LINE OF AFLD.
DATA : BEGIN OF ITAB OCCURS 0,
MATNR LIKE MAKT-MATNR,
MAKTX LIKE MAKT-MAKTX,
MCHK(1) TYPE C VALUE '1' , "checkbox,
COLOR TYPE SLIS_T_SPECIALCOL_ALV, "For Color
END OF ITAB.
DATA : IT_COL TYPE SLIS_T_SPECIALCOL_ALV,
WA_COL LIKE LINE OF IT_COL.
DATA : TXT(50) TYPE C, RN TYPE N.
SELECT MATNR MAKTX FROM MAKT INTO CORRESPONDING FIELDS OF TABLE ITAB UP TO 200 ROWS.
LYT-COLTAB_FIELDNAME = 'COLOR'.
DATA: MCTR TYPE I VALUE 1. " color counter
LOOP AT ITAB.
WA_COL-COLOR-COL = MCTR.
APPEND WA_COL TO IT_COL.
ITAB-COLOR = IT_COL.
CLEAR WA_COL. CLEAR IT_COL[].
MODIFY ITAB INDEX MCTR.
ADD 1 TO MCTR.
ENDLOOP.
PERFORM BUILDFLD.
PERFORM BUILDLYT.
PERFORM CALLALV.
*It will display checked row value from alv when get saved .
LOOP AT ITAB WHERE MCHK = 'X'.
WRITE:/01 ITAB-MATNR.
ENDLOOP.
&----
*& Form buildfld
&----
text
----
FORM BUILDFLD.
TFLD-FIELDNAME = 'MCHK'. TFLD-SELTEXT_M = 'X'. TFLD-CHECKBOX = 'X'.
TFLD-EDIT = 'X'. APPEND TFLD TO AFLD.CLEAR TFLD.
TFLD-FIELDNAME = 'MATNR'. TFLD-SELTEXT_M = 'Material No.'.
tfld-key = 'X'.* tfld-hotspot = 'X'.
APPEND TFLD TO AFLD. CLEAR TFLD.
TFLD-FIELDNAME = 'MAKTX'. TFLD-SELTEXT_M = 'Material Desc..'.
TFLD-EDIT = 'X'. Using this we can edit alv field in output.
APPEND TFLD TO AFLD.CLEAR TFLD.
ENDFORM. "buildfld
&----
*& Form buildlyt
&----
FORM BUILDLYT.
LYT-KEY_HOTSPOT = 'X'.
LYT-ZEBRA = 'X'.
LYT-COLWIDTH_OPTIMIZE = 'X'.
ENDFORM. "buildlyt
&----
*& Form usercommand
&----
FORM USERCOMMAND USING R_COMMAND TYPE SY-UCOMM SELFLD TYPE SLIS_SELFIELD.
*here you will get field checked in internal table so you can do what you want with *data.
CASE R_COMMAND.
WHEN '&IC1'.
IF SELFLD-FIELDNAME = 'MATNR'.
RN = SELFLD-TABINDEX.
READ TABLE ITAB INDEX RN.
SET PARAMETER ID 'MAT' FIELD ITAB-MATNR.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
concatenate 'Clicked' itab-matnr into txt.
message txt type 'S'.
ENDIF.
ENDCASE.
ENDFORM. "usercommand
&----
*& Form callalv
&----
FORM CALLALV.
REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = 'ZALVSELECT'
I_CALLBACK_USER_COMMAND = 'USERCOMMAND'
IS_LAYOUT = LYT
IT_FIELDCAT = AFLD
TABLES
T_OUTTAB = ITAB.
ENDFORM. "callalv
*----
Note: check the check boxes and click on SAVE Button so it will execute and give a list of selected data.
‎2007 Aug 05 12:01 PM
Hi,
Follow this example for check box and other more features.
REPORT ZALVSELECT.
TYPE-POOLS : SLIS.
DATA : AFLD TYPE SLIS_T_FIELDCAT_ALV,
LYT TYPE SLIS_LAYOUT_ALV,
REPID LIKE SY-REPID.
DATA : TFLD LIKE LINE OF AFLD.
DATA : BEGIN OF ITAB OCCURS 0,
MATNR LIKE MAKT-MATNR,
MAKTX LIKE MAKT-MAKTX,
MCHK(1) TYPE C VALUE '1' , "checkbox,
COLOR TYPE SLIS_T_SPECIALCOL_ALV, "For Color
END OF ITAB.
DATA : IT_COL TYPE SLIS_T_SPECIALCOL_ALV,
WA_COL LIKE LINE OF IT_COL.
DATA : TXT(50) TYPE C, RN TYPE N.
SELECT MATNR MAKTX FROM MAKT INTO CORRESPONDING FIELDS OF TABLE ITAB UP TO 200 ROWS.
LYT-COLTAB_FIELDNAME = 'COLOR'.
DATA: MCTR TYPE I VALUE 1. " color counter
LOOP AT ITAB.
WA_COL-COLOR-COL = MCTR.
APPEND WA_COL TO IT_COL.
ITAB-COLOR = IT_COL.
CLEAR WA_COL. CLEAR IT_COL[].
MODIFY ITAB INDEX MCTR.
ADD 1 TO MCTR.
ENDLOOP.
PERFORM BUILDFLD.
PERFORM BUILDLYT.
PERFORM CALLALV.
*It will display checked row value from alv when get saved .
LOOP AT ITAB WHERE MCHK = 'X'.
WRITE:/01 ITAB-MATNR.
ENDLOOP.
&----
*& Form buildfld
&----
text
----
FORM BUILDFLD.
TFLD-FIELDNAME = 'MCHK'. TFLD-SELTEXT_M = 'X'. TFLD-CHECKBOX = 'X'.
TFLD-EDIT = 'X'. APPEND TFLD TO AFLD.CLEAR TFLD.
TFLD-FIELDNAME = 'MATNR'. TFLD-SELTEXT_M = 'Material No.'.
tfld-key = 'X'.* tfld-hotspot = 'X'.
APPEND TFLD TO AFLD. CLEAR TFLD.
TFLD-FIELDNAME = 'MAKTX'. TFLD-SELTEXT_M = 'Material Desc..'.
TFLD-EDIT = 'X'. Using this we can edit alv field in output.
APPEND TFLD TO AFLD.CLEAR TFLD.
ENDFORM. "buildfld
&----
*& Form buildlyt
&----
FORM BUILDLYT.
LYT-KEY_HOTSPOT = 'X'.
LYT-ZEBRA = 'X'.
LYT-COLWIDTH_OPTIMIZE = 'X'.
ENDFORM. "buildlyt
&----
*& Form usercommand
&----
FORM USERCOMMAND USING R_COMMAND TYPE SY-UCOMM SELFLD TYPE SLIS_SELFIELD.
*here you will get field checked in internal table so you can do what you want with *data.
CASE R_COMMAND.
WHEN '&IC1'.
IF SELFLD-FIELDNAME = 'MATNR'.
RN = SELFLD-TABINDEX.
READ TABLE ITAB INDEX RN.
SET PARAMETER ID 'MAT' FIELD ITAB-MATNR.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
concatenate 'Clicked' itab-matnr into txt.
message txt type 'S'.
ENDIF.
ENDCASE.
ENDFORM. "usercommand
&----
*& Form callalv
&----
FORM CALLALV.
REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = 'ZALVSELECT'
I_CALLBACK_USER_COMMAND = 'USERCOMMAND'
IS_LAYOUT = LYT
IT_FIELDCAT = AFLD
TABLES
T_OUTTAB = ITAB.
ENDFORM. "callalv
*----
Note: check the check boxes and click on SAVE Button so it will execute and give a list of selected data.
‎2007 Aug 05 12:32 PM
HI RAJIV,
BUT SAVE BUTTON IS DISABLED IN ALV OUTPUT..
ANOTHER WAY TO TRACK THIS?
THANKS
REGARDS,
JACK
‎2007 Aug 05 12:31 PM
Hi,
REPORT YMS_CHECKBOXALV.
TYPE-POOLS: slis.
DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
DATA: s_layout TYPE slis_layout_alv.
DATA: BEGIN OF itab OCCURS 0,
icon TYPE icon-id,
vbeln TYPE vbeln,
kunnr TYPE kunnr,
erdat TYPE erdat,
box TYPE c,
END OF itab.
DATA: v_repid TYPE syrepid.
START-OF-SELECTION.
Get the data.
SELECT vbeln kunnr erdat UP TO 100 ROWS
FROM vbak
INTO CORRESPONDING FIELDS OF TABLE itab.
IF sy-subrc <> 0.
MESSAGE s208(00) WITH 'No data found'.
LEAVE LIST-PROCESSING.
ENDIF.
Modify the record with red light.
itab-icon = '@0A@'.
MODIFY itab TRANSPORTING icon WHERE NOT vbeln IS initial.
v_repid = sy-repid.
Get the field catalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'ICON'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-seltext_l = 'Status'.
s_fieldcatalog-icon = 'X'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '2'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-rollname = 'VBELN'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '3'.
s_fieldcatalog-fieldname = 'KUNNR'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-rollname = 'KUNNR'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '4'.
s_fieldcatalog-fieldname = 'ERDAT'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-rollname = 'ERDAT'.
APPEND s_fieldcatalog TO t_fieldcatalog.
Set the layout.
s_layout-box_fieldname = 'BOX'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = v_repid
is_layout = s_layout
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = t_fieldcatalog[]
TABLES
t_outtab = itab.
----
FORM SET_PF_STATUS *
----
........ *
----
--> EXTAB *
----
FORM set_pf_status USING extab TYPE slis_t_extab.
SET PF-STATUS 'TEST2'.
ENDFORM.
----
FORM user_command *
----
........ *
----
--> UCOMM *
--> SELFIELD *
----
FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
Check the ucomm.
IF ucomm = 'DETAIL'.
LOOP AT itab WHERE box = 'X'.
itab-icon = '@08@'.
MODIFY itab TRANSPORTING icon.
ENDLOOP.
ENDIF.
selfield-refresh = 'X'.
ENDFORM.
Thanks,
Sankar M