2007 Aug 17 7:35 AM
how can i add a new pushbutton in the application toolbar if all the function keys already have values?
2007 Aug 17 7:39 AM
Hi
you can goto SE41 transaction and there you can creat what ever pushbuttons you and
and for that pushbuton you can assign different function keys also
reward if usefull
2007 Aug 17 7:39 AM
Hi..
You didn't mention where do u want to add it.
But if it is in Selection Screen This is the code:
REPORT zselfile1 .
TABLES:sscrfields.
**Create the Additional Selection screen to input filename
SELECTION-SCREEN: BEGIN OF SCREEN 10.
PARAMETERS: p_file TYPE rlgrap-filename.
SELECTION-SCREEN: END OF SCREEN 10.
**Create Application Toolbar Button on the Standard selection Screen
SELECTION-SCREEN FUNCTION KEY 1. "Its fcode will be FC01
PARAMETERS : p_werks TYPE marc-werks.
INITIALIZATION.
sscrfields-functxt_01 = 'Enter File'. "Assign the Text to the Button
AT SELECTION-SCREEN.
CASE sscrfields-ucomm. "Check the Fcode
WHEN 'FC01'.
CALL SELECTION-SCREEN 10 STARTING AT 5 8 ENDING AT 85 20.
ENDCASE.
<b>Reward if Helpful</b>
2007 Aug 17 8:08 AM
2007 Aug 17 7:40 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
Code Part 28 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.
<b>Implementing functioning codes for new functions</b>
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>
2007 Aug 17 8:26 AM
Hello Steph,
Its just simple.
Just type SET PF-STATUS 'TEST'. in ur program and double click in on that.
Then It will ask for creation of GUI STATUS. press enter.
Give short description for that GUI STATUS.
Then one screen will appear where you can find
Menu bar
Application toolbar
Function keys
-
You can create buttons in Application toolbar...
Click on arrow which will appear next to Application toolbar. There is a provision to create ur own buttons. Type ur button name ( This is function code ) in the field and click just bellow, where u can find the HOT SPOT ( Hand Symbol ).
Choose text type as Static and press enter...
Then u need to fill
Function text
Icon name ( optional )
Info. text
after filling the above things... press enter... then it will ask for shortcut key... choose the key and fill
Function text
Icon name
Icon text
Info. text
Fastpath
and press enter..... Then ACTIVATE(Ctrl+F3) the GUI STATUS. then go to your program on pressing Esc.
Then in user-command function in program give the function code also in the case statement...
ex...
case sy-ucomm.
....
when '<ur Function code>',
.....
......
.....
endcase.
reward If Helpful
Regards
--
Sasidhar Reddy.