08-20-2007 7:22 AM
Hi all,
I am displaying data in ALV grid format by using the FM REUSE_ALV_GRID_DISPLAY.
I have added a custom button to the standard ALV display screen.
when I execute the report I get the button which I have created but the standard ALV tool bar is not getting displayed.
Can any one please suggest me how i can get the ALV tool bar and custom button together.
thanks
vijay
08-20-2007 7:25 AM
Go to se38, give
bcalv in the program name. and press f4.
YOu can find lots of them.
08-20-2007 7:26 AM
HI,
Use the command
form status.
set pf-status 'STATUS'.
endform status.
and status for this prog we have to copy from
se41 -- give prog name as
saplkkbl
and standard_fullscreen ( status )
and copy this to your program
where you hve to give
your prog name and status name..
and activate your programme
then it will come
thanks & regards,
Venkatesh
08-20-2007 7:26 AM
Hi
Adding Your Own Functions
ALV Grid control has an open door letting you to add your own functions triggered by a button press on the ALV toolbar. For this, we mainly utilize two of ALV Grid events. We use the event toolbar to add the button and the event user_command to implement the new function.
In the method handling the toolbar event, we define a new button by filling a structure and appending it to the table attribute mt_toolbar of the object to whose reference we can reach via the parameter e_object of the event.
FORM handle_toolbar USING i_object TYPE REF TO cl_alv_event_toolbar_set .
DATA: ls_toolbar TYPE stb_button.
CLEAR ls_toolbar.
MOVE 3 TO ls_toolbar-butn_type.
APPEND ls_toolbar TO i_object->mt_toolbar.
CLEAR ls_toolbar.
MOVE 'PER' TO ls_toolbar-function. "#EC NOTEXT
MOVE icon_display_text TO ls_toolbar-icon.
MOVE 'Passenger Info'(201) TO ls_toolbar-quickinfo.
MOVE 'Passenger Info'(201) TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled. "#EC NOTEXT
APPEND ls_toolbar TO i_object->mt_toolbar.
CLEAR ls_toolbar.
MOVE 'EXCH' TO ls_toolbar-function. "#EC NOTEXT
MOVE 2 TO ls_toolbar-butn_type.
MOVE icon_calculation TO ls_toolbar-icon.
MOVE 'Payment in Other Currencies'(202) TO ls_toolbar-quickinfo.
MOVE ' ' TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled. "#EC NOTEXT
APPEND ls_toolbar TO i_object->mt_toolbar.
ENDFORM .
The fields of the structure we fill are as follows:
Field
Description
FUNCTION
The function code for the function
BUTN_TYPE
Button type that will be added to the toolbar. Available button types are:
0
Button (normal)
1
Menu and default button
2
Menu
3
Separator
4
Radio button
5
Checkbox
6
Menu entry
ICON
Icon for the button (optional)
TEXT
Text for the button (optional)
QUICKINFO
Quick info for the button (optional)
DISABLED
Adds the button as disabled
Fields of structure to be filled to add a new function
we are adding a separator line and two buttons one of which is a normal button whereas the other is a menu button. To handle a menu button which as added by choosing 1 or 2 as the button type, we must also implement some coding at the method handling the event menu_button to define functions as to be subentries. The functions of these subentries are also handled under the event user_command.
FORM handle_menu_button USING i_object TYPE REF TO cl_ctmenu
i_ucomm TYPE syucomm .
CASE i_ucomm .
WHEN 'EXCH' .
CALL METHOD i_object->add_function
EXPORTING
fcode = 'EU'
text = 'Euro' .
CALL METHOD i_object->add_function
EXPORTING
fcode = 'TRL'
text = 'Turkish Lira' .
.. ..
ENDCASE .
ENDFORM. " handle_menu_button
Adding two functions to be subentries for the menu button with function code EXCH
Now, to implement what to be executed when our button is pressed or our subentry is selected we need to program our functions in the method handling the event user_command.
Implementing functioning codes for new functions
FORM handle_user_command USING i_ucomm TYPE syucomm .
DATA lt_selected_rows TYPE lvc_t_roid .
DATA ls_selected_row TYPE lvc_s_roid .
CALL METHOD gr_alvgrid->get_selected_rows
IMPORTING
et_row_no = lt_selected_rows .
READ TABLE lt_selected_rows INTO ls_selected_row INDEX 1 .
IF sy-subrc ne 0 .
MESSAGE s000(su) WITH 'Select a row!'(203) .
ENDIF .
CASE i_ucomm .
WHEN 'CAR' .
READ TABLE gt_list INDEX ls_selected_row-row_id .
IF sy-subrc = 0 .
CALL FUNCTION 'ZDISPLAY_CARRIER_INFO'
EXPORTING carrid = gt_list-carrid
EXCEPTIONS carrier_not_found = 1
OTHERS = 2.
IF sy-subrc NE 0 .
*--Exception handling
ENDIF .
ENDIF .
WHEN 'EU' .
READ TABLE gt_list INDEX ls_selected_row-row_id .
IF sy-subrc = 0 .
CALL FUNCTION 'ZPOPUP_CONV_CURR_AND_DISPLAY'
EXPORTING monun = 'EU'
quant = gt_list-paymentsum.
ENDIF .
.. ..
ENDCASE .
ENDFORM .
As you can see, we are using the method get_selected_rows to get which row is selected. Since the button with function EXCH branches into subfunctions, we do not implement anything for it. Instead, we implement functional codes for subfunctions.
After all, to make ALV show our additional buttons, we must call the method set_toolbar_interactive for the ALV Grid instance after the instance is created.
e.g. CALL METHOD gr_alvgrid->set_toolbar_interactive .
Regards
Preeti
<b>
Reward if useful</b>
08-21-2007 11:02 AM
Go to the PF status which u have given in SE41 transaction,
Goto Extras --> Adjust Template
choose the radio button List Viewer.
activate the screen.