‎2006 Nov 20 9:44 AM
hi,
i have created ALV using OOPs cponcept.
now i wanted to add new button on the toolbar of ALV and want hyperlink on one column..
how can i add button on toolbar of ALV and make hyperling using OOPs concept.
Thankx in advance.
Chintan Soni
‎2006 Nov 20 9:49 AM
This piece of code will create a new button with ok_code 'BOOKINGS'.
DATA:LS_TOOLBAR TYPE STB_BUTTON.
METHOD: ADDBUTTON.
CLEAR LS_TOOLBAR.
MOVE 0 TO LS_TOOLBAR-BUTN_TYPE.
MOVE ICON_EMPLOYEE TO LS_TOOLBAR-ICON.
MOVE 'Move to 2nd ALV' TO LS_TOOLBAR-TEXT.
MOVE 'BOOKINGS' TO LS_TOOLBAR-FUNCTION.
MOVE SPACE TO LS_TOOLBAR-DISABLED.
APPEND LS_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
ENDMETHOD. "addbutton
‎2006 Nov 20 9:50 AM
U can have button on application toolbar.
You just have to use the new pf status in your report program.
You should copy the 'STANDARD' GUI status from program SAPLKKBL using transaction SE90 >Programming SubObjects> Gui Status.
Execute this transaction to get to next screen. select status using checkbox. click on GUI Status --> Copy.
Enter your Z program name and the name you what for this status - you can keep it as 'STANDARD' to be simple.
Then you can edit the new status to add or delete buttons. This will also bring in the standard SAP ALV functionality.
I hope it helps.
Best Regards,
Vibha
*Please mark all the helpful answers
‎2006 Nov 20 9:53 AM
Hi Chintan,
Take a look at the following demo programs:
BCALV_GRID_05 - Shows how to add a custom toolbar button
BCALV_FIELDCAT_TEST - Editing the field catalog online (see the HOTSPOT field).
MJ
‎2006 Nov 20 9:54 AM
Hi Chitan
Refer this program,
SALV_DEMO_TABLE_EVENTS
Use this for the Hyperlink
try.
lr_column ?= lr_columns->get_column( 'CARRID' ).
lr_column->set_cell_type( if_salv_c_cell_type=>link ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
Regards
Kathirvel
‎2006 Nov 20 11:21 AM
Hi Chintan,
You can go through this nice document. I think it will satisfy both of your requirements.
http://esnips.com/doc/2d953590-e8c5-490c-a607-d1ab7cf517d7/ALV.pdf
<b>Award points if found useful.</b>
Regards,
SP.
‎2006 Nov 20 8:00 PM
Hello Chintan
You have to call method <b>grid->set_toolbar_interactive</b> and create an event handler method for event TOOLBAR.
The following sample (modified version of BCALV_GRID_DEMO) shows how to do (my coding is in bold):
[code]PROGRAM test.
DATA: ok_code LIKE sy-ucomm,
gt_sflight TYPE TABLE OF sflight,
g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
grid1 TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container.
----
CLASS lcl_eventhandler DEFINITION
----
*
----
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-DATA:
md_cnt TYPE i.
CLASS-METHODS:
handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING
e_object
e_interactive
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
----
CLASS lcl_eventhandler IMPLEMENTATION
----
*
----
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_toolbar.
DATA:
ls_button TYPE stb_button.
*$Comment: Coding for inactivating standard toolbar buttons
ADD 1 TO md_cnt. " a simple counter
LOOP AT e_object->mt_toolbar INTO ls_button FROM 1 TO md_cnt.
ls_button-disabled = 'X'.
MODIFY e_object->mt_toolbar FROM ls_button.
ENDLOOP.
ENDMETHOD. "handle_toolbar
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
----
MAIN *
----
SELECT * FROM sflight INTO TABLE gt_sflight.
CALL SCREEN 100.
----
MODULE PBO OUTPUT *
----
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
CREATE OBJECT grid1
EXPORTING i_parent = g_custom_container.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'SFLIGHT'
CHANGING
it_outtab = gt_sflight.
*$Comment: Set event handler for event TOOLBAR
SET HANDLER:
lcl_eventhandler=>handle_toolbar FOR grid1.
ENDIF.
*$Comment: Toolbar can be modified on-the-fly
grid1->set_toolbar_interactive( ). " raises event TOOLBAR
ENDMODULE. "PBO OUTPUT
----
MODULE PAI INPUT *
----
MODULE pai INPUT.
to react on oi_custom_events:
CALL METHOD cl_gui_cfw=>dispatch.
CASE ok_code.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN OTHERS.
do nothing
ENDCASE.
CLEAR ok_code.
ENDMODULE. "PAI INPUT
----
FORM EXIT_PROGRAM *
----
FORM exit_program.
CALL METHOD G_CUSTOM_CONTAINER->FREE.
CALL METHOD CL_GUI_CFW=>FLUSH.
LEAVE PROGRAM.
ENDFORM. "EXIT_PROGRAM[/code]
Within the handle_toolbar method you can place coding like described by David to add you specific toolbar buttons.
The use of hyperlinks is well described in
<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907">Easy Reference to ALV Grid Control</a>
Regards
Uwe