‎2006 Jun 15 10:14 AM
Hi,
I have created a ALV grid using CL_GUI_ALV_GRID....i neeed to add a button on each...row..of the grid....i.e. a field in the table has to be displayed as a button..
How can this be done and a event also...has to be associated along with this.
‎2006 Jun 15 10:27 AM
Hi Vinotha,
You can do that.
Do the style setting as to make it pushbutton.
<b>In the class CL_GUI_ALV_GRID, there are constants starting by the name MC_STYLE..... Just assign the STYLE attribute of Fieldcatalog to the style corresponding to the push button</b> .
That is it...problem solved.
Here is an example....
form PREPARE_CATALOG changing p_field_catalog type lvc_t_fcat.
DATA ls_fcat type lvc_s_fcat .
CLEAR LS_FCAT.
ls_fcat-fieldname = 'CARRID'.
ls_fcat-ref_table = 'SFLIGHT' .
<b>ls_fcat-style = cl_gui_alv_grid=>mc_style_button.</b>
ls_fcat-outputlen = '20' .
ls_fcat-coltext = 'Carrid' .
APPEND ls_fcat to p_field_catalog .
endform.
Regards,
SP.
Message was edited by: Sylendra Prasad
‎2006 Jun 15 10:21 AM
Hi,
take a look at this prog.
BCALV_GRID_05
rgds,
latheesh
Message was edited by: Latheesh Kaduthara
‎2006 Jun 15 10:24 AM
Hi,
You can achieve this functionality through LAYOUT by passing 'X' to the layout-sel_mode.Then the Grid looks like a table control.
Cheers,
Bujji
‎2006 Jun 15 10:31 AM
I want to add a button along with other fields in a row...<b>not a way to select the row</b>..<b>and not on the toolbar</b> but many buttons on a single row..with added functionality
‎2006 Jun 15 10:57 AM
Hi,
Check this image. the sample output.
http://img91.imageshack.us/img91/2963/button9fv.jpg
Regards
vijay
‎2006 Jun 15 11:18 AM
Hi Vinotha,
If the requirement is similar to the picture uploaded by Vijay, you can go through my previous post or Vijay's post. It is very simple.
Regards,
SP.
‎2006 Jun 20 1:50 PM
Thanks a lot...it worked...can u also..tell me how to disable the button...based on user entry.
‎2006 Jun 20 2:04 PM
Hi Vinotha,
You can disable the buttons in the standard toolbar in ALV using the method <b>hide_functions.</b>In that method, there is a parameter which should contain all the codes of the buttons you want to disable.
For more details, refer this document.
http://esnips.com/doc/2d953590-e8c5-490c-a607-d1ab7cf517d7/ALV.pdf
Regards,
SP.
‎2006 Jun 20 2:36 PM
No, I dont want to disable the standard buttons....i want to disable the buttons that i created on each row..using the style field of the fieldcatalg..
i.e a column entirely displayed as buttons.
‎2006 Jun 20 3:05 PM
Hi Vinotha,
You can disable the button style by setting the style as MC_STYLE_DISABLED.
for eg:
my_cat-style = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
Regards,
SP.
‎2006 Jun 15 10:27 AM
Hi Vinotha,
You can do that.
Do the style setting as to make it pushbutton.
<b>In the class CL_GUI_ALV_GRID, there are constants starting by the name MC_STYLE..... Just assign the STYLE attribute of Fieldcatalog to the style corresponding to the push button</b> .
That is it...problem solved.
Here is an example....
form PREPARE_CATALOG changing p_field_catalog type lvc_t_fcat.
DATA ls_fcat type lvc_s_fcat .
CLEAR LS_FCAT.
ls_fcat-fieldname = 'CARRID'.
ls_fcat-ref_table = 'SFLIGHT' .
<b>ls_fcat-style = cl_gui_alv_grid=>mc_style_button.</b>
ls_fcat-outputlen = '20' .
ls_fcat-coltext = 'Carrid' .
APPEND ls_fcat to p_field_catalog .
endform.
Regards,
SP.
Message was edited by: Sylendra Prasad
‎2006 Jun 15 10:27 AM
hi,
<b>Pushbuttons on the List To make a cell to be displayed as a pushbutton</b>
we have two steps.
Firstly, insert a new inner table of type LVC_T_STYL into your list data table.
Fill this inner table for each field to be displayed as pushbutton.
Button click event is handled like hotspot click via the event button_click through its parameters es_col_id and es_row_no which contain the address of the clicked pushbutton cell.
This detail Is provided in
An Easy Reference for ALV Grid Control PDF page 32.
if u dont have the PDF .
Please give me ur Email address i will send u.
<b>
Please Mark Helpful Answers</b>
‎2006 Jun 15 10:30 AM
You cannot declare it as a button, but as an ICON or CheckBox only.
Add a single character field in your table. And when you are inserting the field in your field cat, check the field
ICON or
SYMBOL or
CHECKBOX or
Or you can declare the lay out as lvc_s_layo-sel_mode = 'A'
The event you could use to capture the actions is lcl_event_receiver
See sample from SAP, search BCALV* in SE38
‎2006 Jun 15 10:42 AM
Hi,
it is very well possible.Just check this Program.
and for responding you need the event BUTTON_CLICK
have a local class method, and implement that, and then set the handler for it to respond.
<b> button_click for event button_click
of cl_gui_alv_grid
importing es_col_id
es_row_no</b>i just used LVC fm, it is almost like using <b>CL_GUI_ALV_GRID</b> from this report take the bold alone, thats all.
REPORT ZTESTALV.
TYPE-POOLS: SLIS.
*- Fieldcatalog
DATA: IT_FIELDCAT TYPE LVC_T_FCAT,
IT_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV..
*- For Events
DATA:IT_EVENTS TYPE SLIS_T_EVENT.
DATA: X_FIELDCAT TYPE LVC_S_FCAT,
X_FIELDCAT1 TYPE SLIS_FIELDCAT_ALV.
DATA:X_LAYOUT TYPE LVC_S_LAYO.
"{ FOR DISABLE
DATA: LS_EDIT TYPE LVC_S_STYL,
LT_EDIT TYPE LVC_T_STYL.
"} FOR DISABLE
DATA: BEGIN OF IT_VBAP OCCURS 0,
VBELN LIKE VBAP-VBELN,
POSNR LIKE VBAP-POSNR,
HANDLE_STYLE TYPE LVC_T_STYL, "FOR DISABLE
<b> BUTTON(10),</b>
END OF IT_VBAP.
DATA: LS_OUTTAB LIKE LINE OF IT_VBAP.
SELECT VBELN
POSNR
UP TO 10 ROWS
INTO CORRESPONDING FIELDS OF TABLE IT_VBAP
FROM VBAP.
DATA:L_POS TYPE I VALUE 1.
CLEAR: L_POS.
L_POS = L_POS + 1.
<b>X_FIELDCAT-SELTEXT = 'Button'.
x_fieldcat-fieldname = 'BUTTON'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '10'.
X_FIELDCAT-style = X_FIELDCAT-style bit-xor
cl_gui_alv_grid=>MC_STYLE_BUTTON bit-xor
cl_gui_alv_grid=>MC_STYLE_ENABLEd.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.</b>
L_POS = L_POS + 1.
X_FIELDCAT-SELTEXT = 'VBELN'.
X_FIELDCAT-FIELDNAME = 'VBELN'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-EDIT = 'X'.
X_FIELDCAT-OUTPUTLEN = '10'.
x_fieldcat-ref_field = 'VBELN'.
x_fieldcat-ref_table = 'VBAK'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SELTEXT = 'POSNR'.
X_FIELDCAT-FIELDNAME = 'POSNR'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-EDIT = 'X'.
X_FIELDCAT-OUTPUTLEN = '5'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
"{FOR DISABLE HERE 6ROW IS DISABLED
SY-TABIX = 6.
LS_EDIT-FIELDNAME = 'VBELN'.
LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
LS_EDIT-STYLE2 = SPACE.
LS_EDIT-STYLE3 = SPACE.
LS_EDIT-STYLE4 = SPACE.
LS_EDIT-MAXLEN = 10.
INSERT LS_EDIT INTO TABLE LT_EDIT.
*LS_EDIT-FIELDNAME = 'POSNR'.
*LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
*LS_EDIT-STYLE2 = SPACE.
*LS_EDIT-STYLE3 = SPACE.
*LS_EDIT-STYLE4 = SPACE.
*LS_EDIT-MAXLEN = 6.
*INSERT LS_EDIT INTO TABLE LT_EDIT.
INSERT LINES OF LT_EDIT INTO TABLE LS_OUTTAB-HANDLE_STYLE.
MODIFY IT_VBAP INDEX SY-TABIX FROM LS_OUTTAB TRANSPORTING
HANDLE_STYLE .
X_LAYOUT-STYLEFNAME = 'HANDLE_STYLE'.
"} UP TO HERE
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT_LVC = X_LAYOUT
IT_FIELDCAT_LVC = IT_FIELDCAT
TABLES
T_OUTTAB = IT_VBAP[]
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.to check the Button you copy paste and see the above code.
for button using cl_gui_alv_grid try the fieldcat which i marked as bold.
Regards
vijay
‎2007 Feb 20 11:19 AM
@Vijay Babu Dudla
Hi Vijay or anybody else that wants to answer me
I tried the program ZTESTALV. What I don't get is how to set the handler for the event BUTTON_CLICK. Do you have a code example how to create the handler when using the FM REUSE_ALV_GRID_DISPLAY_LVC?
Thanks and regards,
Stefan
‎2007 Mar 23 5:34 PM
I've the same problem. The field is shown as button but no event is triggerd.