Generating events such as "push buttons" in ABAP
Hi,
Is it possible to make code in ABAP that given a screen number can generate events for that screen.
For example create a Z program that given the input parameters screen name and transaction, do something like:
screen 101.pushChangeButton.?
regards
Baran
yes see this code.
REPORT YH648_DIALOG_PROGRAM.
*call screen 1649.
call screen 1642.
***&SPWIZARD: DATA DECLARATION FOR TABLECONTROL 'T_CONTROL'
*&SPWIZARD: DEFINITION OF DDIC-TABLE
TABLES: SPFLI.
*&SPWIZARD: TYPE FOR THE DATA OF TABLECONTROL 'T_CONTROL'
TYPES: BEGIN OF T_T_CONTROL,
MANDT LIKE SPFLI-MANDT,
CARRID LIKE SPFLI-CARRID,
CONNID LIKE SPFLI-CONNID,
COUNTRYFR LIKE SPFLI-COUNTRYFR,
CITYFROM LIKE SPFLI-CITYFROM,
AIRPFROM LIKE SPFLI-AIRPFROM,
COUNTRYTO LIKE SPFLI-COUNTRYTO,
CITYTO LIKE SPFLI-CITYTO,
AIRPTO LIKE SPFLI-AIRPTO,
FLTIME LIKE SPFLI-FLTIME,
DEPTIME LIKE SPFLI-DEPTIME,
ARRTIME LIKE SPFLI-ARRTIME,
DISTANCE LIKE SPFLI-DISTANCE,
DISTID LIKE SPFLI-DISTID,
FLTYPE LIKE SPFLI-FLTYPE,
PERIOD LIKE SPFLI-PERIOD,
END OF T_T_CONTROL.
*&SPWIZARD: INTERNAL TABLE FOR TABLECONTROL 'T_CONTROL'
DATA: G_T_CONTROL_ITAB TYPE T_T_CONTROL OCCURS 0,
G_T_CONTROL_WA TYPE T_T_CONTROL. "work area
DATA: G_T_CONTROL_COPIED. "copy flag
*&SPWIZARD: DECLARATION OF TABLECONTROL 'T_CONTROL' ITSELF
CONTROLS: T_CONTROL TYPE TABLEVIEW USING SCREEN 1642.
*&SPWIZARD: LINES OF TABLECONTROL 'T_CONTROL'
DATA: G_T_CONTROL_LINES LIKE SY-LOOPC.
DATA: OK_CODE LIKE SY-UCOMM.
module pf_status output.
set pf-status 'STATUS_1642'.
endmodule.
*&SPWIZARD: OUTPUT MODULE FOR TC 'T_CONTROL'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: COPY DDIC-TABLE TO ITAB
MODULE T_CONTROL_INIT OUTPUT.
IF G_T_CONTROL_COPIED IS INITIAL.
*&SPWIZARD: COPY DDIC-TABLE 'SPFLI'
*&SPWIZARD: INTO INTERNAL TABLE 'g_T_CONTROL_itab'
SELECT * FROM SPFLI
INTO CORRESPONDING FIELDS
OF TABLE G_T_CONTROL_ITAB.
G_T_CONTROL_COPIED = 'X'.
REFRESH CONTROL 'T_CONTROL' FROM SCREEN '1642'.
ENDIF.
ENDMODULE.
*&SPWIZARD: OUTPUT MODULE FOR TC 'T_CONTROL'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: MOVE ITAB TO DYNPRO
MODULE T_CONTROL_MOVE OUTPUT.
MOVE-CORRESPONDING G_T_CONTROL_WA TO SPFLI.
ENDMODULE.
*&SPWIZARD: OUTPUT MODULE FOR TC 'T_CONTROL'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: GET LINES OF TABLECONTROL
MODULE T_CONTROL_GET_LINES OUTPUT.
G_T_CONTROL_LINES = SY-LOOPC.
ENDMODULE.
*&SPWIZARD: INPUT MODULE FOR TC 'T_CONTROL'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: PROCESS USER COMMAND
MODULE T_CONTROL_USER_COMMAND INPUT.
OK_CODE = SY-UCOMM.
PERFORM USER_OK_TC USING 'T_CONTROL'
'G_T_CONTROL_ITAB'
'FLAG'
CHANGING OK_CODE.
SY-UCOMM = OK_CODE.
ENDMODULE.
module back_exit.
leave program.
endmodule.
INCLUDE TABLECONTROL_FORMS *
*& Form USER_OK_TC *
FORM USER_OK_TC USING P_TC_NAME TYPE DYNFNAM
P_TABLE_NAME
P_MARK_NAME
CHANGING P_OK LIKE SY-UCOMM.
&SPWIZARD: BEGIN OF LOCAL DATA----
DATA: L_OK TYPE SY-UCOMM,
L_OFFSET TYPE I.
&SPWIZARD: END OF LOCAL DATA----
*&SPWIZARD: Table control specific operations *
*&SPWIZARD: evaluate TC name and operations *
SEARCH P_OK FOR P_TC_NAME.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
L_OFFSET = STRLEN( P_TC_NAME ) + 1.
L_OK = P_OK+L_OFFSET.
*&SPWIZARD: execute general and TC specific operations *
CASE L_OK.
WHEN 'INSR'. "insert row
PERFORM FCODE_INSERT_ROW USING P_TC_NAME
P_TABLE_NAME.
CLEAR P_OK.
WHEN 'DELE'. "delete row
PERFORM FCODE_DELETE_ROW USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME.
CLEAR P_OK.
WHEN 'P--' OR "top of list
'P-' OR "previous page
'P+' OR "next page
'P++'. "bottom of list
PERFORM COMPUTE_SCROLLING_IN_TC USING P_TC_NAME
L_OK.
CLEAR P_OK.
WHEN 'L--'. "total left
PERFORM FCODE_TOTAL_LEFT USING P_TC_NAME.
WHEN 'L-'. "column left
PERFORM FCODE_COLUMN_LEFT USING P_TC_NAME.
WHEN 'R+'. "column right
PERFORM FCODE_COLUMN_RIGHT USING P_TC_NAME.
WHEN 'R++'. "total right
PERFORM FCODE_TOTAL_RIGHT USING P_TC_NAME.
WHEN 'MARK'. "mark all filled lines
PERFORM FCODE_TC_MARK_LINES USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME .
CLEAR P_OK.
WHEN 'DMRK'. "demark all filled lines
PERFORM FCODE_TC_DEMARK_LINES USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME .
CLEAR P_OK.
WHEN 'SASCEND' OR
'SDESCEND'. "sort column
PERFORM FCODE_SORT_TC USING P_TC_NAME
l_ok.
ENDCASE.
ENDFORM. " USER_OK_TC
*& Form FCODE_INSERT_ROW *
FORM fcode_insert_row
USING P_TC_NAME TYPE DYNFNAM
P_TABLE_NAME .
&SPWIZARD: BEGIN OF LOCAL DATA----
DATA L_LINES_NAME LIKE FELD-NAME.
DATA L_SELLINE LIKE SY-STEPL.
DATA L_LASTLINE TYPE I.
DATA L_LINE TYPE I.
DATA L_TABLE_NAME LIKE FELD-NAME.
FIELD-SYMBOLS <TC> TYPE CXTAB_CONTROL.
FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.
FIELD-SYMBOLS <LINES> TYPE I.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (P_TC_NAME) TO <TC>.
*&SPWIZARD: get the table, which belongs to the tc *
CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline
*&SPWIZARD: get looplines of TableControl *
CONCATENATE 'G_' P_TC_NAME '_LINES' INTO L_LINES_NAME.
ASSIGN (L_LINES_NAME) TO <LINES>.
*&SPWIZARD: get current line *
GET CURSOR LINE L_SELLINE.
IF SY-SUBRC <> 0. " append line to table
L_SELLINE = <TC>-LINES + 1.
*&SPWIZARD: set top line *
IF L_SELLINE > <LINES>.
<TC>-TOP_LINE = L_SELLINE - <LINES> + 1 .
ELSE.
<TC>-TOP_LINE = 1.
ENDIF.
ELSE. " insert line into table
L_SELLINE = <TC>-TOP_LINE + L_SELLINE - 1.
L_LASTLINE = <TC>-TOP_LINE + <LINES> - 1.
ENDIF.
*&SPWIZARD: set new cursor line *
L_LINE = L_SELLINE - <TC>-TOP_LINE + 1.
*&SPWIZARD: insert initial line *
INSERT INITIAL LINE INTO <TABLE> INDEX L_SELLINE.
<TC>-LINES = <TC>-LINES + 1.
*&SPWIZARD: set cursor *
SET CURSOR LINE L_LINE.
ENDFORM. " FCODE_INSERT_ROW
*& Form FCODE_DELETE_ROW *
FORM fcode_delete_row
USING P_TC_NAME TYPE DYNFNAM
P_TABLE_NAME
P_MARK_NAME .
&SPWIZARD: BEGIN OF LOCAL DATA----
DATA L_TABLE_NAME LIKE FELD-NAME.
FIELD-SYMBOLS <TC> TYPE cxtab_control.
FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.
FIELD-SYMBOLS <WA>.
FIELD-SYMBOLS <MARK_FIELD>.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (P_TC_NAME) TO <TC>.
*&SPWIZARD: get the table, which belongs to the tc *
CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline
*&SPWIZARD: delete marked lines *
DESCRIBE TABLE <TABLE> LINES <TC>-LINES.
LOOP AT <TABLE> ASSIGNING <WA>.
*&SPWIZARD: access to the component 'FLAG' of the table header *
ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.
IF <MARK_FIELD> = 'X'.
DELETE <TABLE> INDEX SYST-TABIX.
IF SY-SUBRC = 0.
<TC>-LINES = <TC>-LINES - 1.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " FCODE_DELETE_ROW
*& Form COMPUTE_SCROLLING_IN_TC
text
-->P_TC_NAME name of tablecontrol
-->P_OK ok code
FORM COMPUTE_SCROLLING_IN_TC USING P_TC_NAME
P_OK.
&SPWIZARD: BEGIN OF LOCAL DATA----
DATA L_TC_NEW_TOP_LINE TYPE I.
DATA L_TC_NAME LIKE FELD-NAME.
DATA L_TC_LINES_NAME LIKE FELD-NAME.
DATA L_TC_FIELD_NAME LIKE FELD-NAME.
FIELD-SYMBOLS <TC> TYPE cxtab_control.
FIELD-SYMBOLS <LINES> TYPE I.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (P_TC_NAME) TO <TC>.
*&SPWIZARD: get looplines of TableControl *
CONCATENATE 'G_' P_TC_NAME '_LINES' INTO L_TC_LINES_NAME.
ASSIGN (L_TC_LINES_NAME) TO <LINES>.
*&SPWIZARD: is no line filled? *
IF <TC>-LINES = 0.
*&SPWIZARD: yes, ... *
L_TC_NEW_TOP_LINE = 1.
ELSE.
*&SPWIZARD: no, ... *
CALL FUNCTION 'SCROLLING_IN_TABLE'
EXPORTING
ENTRY_ACT = <TC>-TOP_LINE
ENTRY_FROM = 1
ENTRY_TO = <TC>-LINES
LAST_PAGE_FULL = 'X'
LOOPS = <LINES>
OK_CODE = P_OK
OVERLAPPING = 'X'
IMPORTING
ENTRY_NEW = L_TC_NEW_TOP_LINE
EXCEPTIONS
NO_ENTRY_OR_PAGE_ACT = 01
NO_ENTRY_TO = 02
NO_OK_CODE_OR_PAGE_GO = 03
OTHERS = 0.
ENDIF.
*&SPWIZARD: get actual tc and column *
GET CURSOR FIELD L_TC_FIELD_NAME
AREA L_TC_NAME.
IF SYST-SUBRC = 0.
IF L_TC_NAME = P_TC_NAME.
*&SPWIZARD: et actual column *
SET CURSOR FIELD L_TC_FIELD_NAME LINE 1.
ENDIF.
ENDIF.
*&SPWIZARD: set the new top line *
<TC>-TOP_LINE = L_TC_NEW_TOP_LINE.
ENDFORM. " COMPUTE_SCROLLING_IN_TC
*& Form FCODE_TC_MARK_LINES
marks all TableControl lines
-->P_TC_NAME name of tablecontrol
FORM FCODE_TC_MARK_LINES USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME.
&SPWIZARD: EGIN OF LOCAL DATA----
DATA L_TABLE_NAME LIKE FELD-NAME.
FIELD-SYMBOLS <TC> TYPE cxtab_control.
FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.
FIELD-SYMBOLS <WA>.
FIELD-SYMBOLS <MARK_FIELD>.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (P_TC_NAME) TO <TC>.
*&SPWIZARD: get the table, which belongs to the tc *
CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline
*&SPWIZARD: mark all filled lines *
LOOP AT <TABLE> ASSIGNING <WA>.
*&SPWIZARD: access to the component 'FLAG' of the table header *
ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.
<MARK_FIELD> = 'X'.
ENDLOOP.
ENDFORM. "fcode_tc_mark_lines
*& Form FCODE_TC_DEMARK_LINES
demarks all TableControl lines
-->P_TC_NAME name of tablecontrol
FORM FCODE_TC_DEMARK_LINES USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME .
&SPWIZARD: BEGIN OF LOCAL DATA----
DATA L_TABLE_NAME LIKE FELD-NAME.
FIELD-SYMBOLS <TC> TYPE cxtab_control.
FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.
FIELD-SYMBOLS <WA>.
FIELD-SYMBOLS <MARK_FIELD>.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (P_TC_NAME) TO <TC>.
*&SPWIZARD: get the table, which belongs to the tc *
CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline
*&SPWIZARD: demark all filled lines *
LOOP AT <TABLE> ASSIGNING <WA>.
*&SPWIZARD: access to the component 'FLAG' of the table header *
ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.
<MARK_FIELD> = SPACE.
ENDLOOP.
ENDFORM. "fcode_tc_mark_lines
see at pf-status.
Message was edited by:
sunil kumar
Similar Messages
-
My ipod nano 4th generation only works when it is plugged into the computer; otherwise, the screen turns black and it is completely unresponsive to any efforts such as pushing buttons, reseting, etc. What should I do?
Sounds like the battery is shot and in need of a replacement. You can have Apple replace the battery for a flat fee or you can send it into a third party repair center for a bit less.
Not much else you can do for troubleshooting this one.
B-rock -
Push button using abap objects
Hi experts,
can u paste any sample code for creating and handling push button on a screen using ABAP objects.
thanks in advance.
santhoshHi Santhosh,
Check the following code.
* create a custom area on the screen
DATA : gref_ver_toolbar TYPE REF TO cl_gui_toolbar,
gref_custom_container TYPE REF TO cl_gui_custom_container.
* initializing toolbar
* Creating toolbar container............................................
create object gref_custom_container
exporting
container_name = iv_ccarea " control area on screen
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6
* creating reference to toolbar........................................
create object gref_ver_toolbar
exporting
parent = gref_custom_container
display_mode = 1
exceptions
cntl_install_error = 1
cntl_error = 2
cntb_wrong_version = 3
others = 4
* subroutine to create buttons
* Local data............................................................
data: lv_fcode type ui_func,
lv_icon type iconname,
lv_is_disabled type c,
lv_quickinfo type iconquick.
* delete node button...................................................
lv_fcode = 'DELETE'.
lv_icon = '@11@'.
lv_is_disabled = space.
lv_quickinfo = test(001).
* adding button to toolbar
call method gref_toolbar->add_button
exporting
fcode = lv_fcode
icon = lv_icon
is_disabled = lv_is_disabled
butn_type = cntb_btype_button
quickinfo = lv_quickinfo
exceptions
cntl_error = 1
cntb_btype_error = 2
cntb_error_fcode = 3
others = 4
* registering toolbar
* Local data............................................................
data: ls_event type cntl_simple_event,
lt_event type cntl_simple_events.
ls_event-eventid = cl_gui_toolbar=>m_id_function_selected.
ls_event-appl_event = space.
append ls_event to lt_event.
* Method for Registering Events for Toolbar.............................
call method gref_toolbar->set_registered_events
exporting
events = lt_event[]
exceptions
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3
others = 4.
* Setting handler for the Toolbar Buttons..............................
set handler gref_application->handle_function_selected
for gref_toolbar.
just copy paste the above code in the PBO of the screen also you need to create a method handle_function_selected which will take care of the function on the button
* Method to handle button on toolbar....................................
handle_function_selected
FOR EVENT function_selected
OF cl_gui_toolbar
IMPORTING fcode.
method handle_function_selected.
case fcode.
when 'DELETE'.
* code...
endcase.
endmethod.
Hope the above code snippet help you.
Regards,
Kinshuk -
Problem in push button of abap object code
Hi,
I am working on a example ABAP Object taken from www.erpgenie.com . There is a problem code that during exceution the push button when i select the exapnd sroage locations it does not get expanded. plzz provide me guidelines by watching the code of it and tell me what will be the amendments requiered in it to display the all the storage locations when click on the push buttons.
http://docs.google.com/Doc?id=dngp529_1rqvhzxgv&hl=en
plzz go through the above link as it conatins the code in it and provide me guidelines to solve this problem.
Edited by: ricx .s on Apr 13, 2009 11:07 AMhi,
please refer this link
Re: Setting the PF Status for ALV
https://wiki.sdn.sap.com/wiki/pages/pointstab/viewpageversion.action?pageId=37715&version=2
thanks -
Event in ALV For Extra Push Button Added
Hello Guys,
I have created an ALV and with the help of u people I have successfull to add new button (push button) in it with following procdure.
a) New PF-STATUS is required , say 'ABCD'.
b) Handle user_commmand
2. First of all, from Function group SALV,
copy the STANDARD gui status to your program,
from SE80, by right clicking.
3. come to your program.
start-of-selection.
SET PF-STATUS 'ABCD'.
4. Double click ABCD and activate the gui status.
4. In gui status,
add/change your own buttons
Save and activate.
after that, you should be passing the name of the pf-status in the alv grid fm..
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SAT_REPID
I_CALLBACK_PF_STATUS_SET = 'abcd'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = SAT_LAYOUT
IT_FIELDCAT = SAT_FIELDCATALOG[]
IT_EVENTS = SAT_EVENTS[]
TABLES
T_OUTTAB = ITAB_FINAL
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.
make sure there is a form ABCD in your program...
FORM abcd USING P_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'abcd' EXCLUDING P_EXTAB.
ENDFORM.
Now I have given name of push button as show . My requirement is when users select one row (First I have to identify any row selected or not , if not Error message should be display) and with respect to the selected row I have to show one more ALV contain the billing details of the sales order Row Selected.
My question is ..
1. Is is possible to add a option button with respect to each sales order to identify the which row is selected.
2. How I code to get the event of show push button.
3. At the event I required the Selected Row data, not first column only.
Please do the needful.
Thanks
Swati....Hello Shiba ,
Really Thanks for Code, Porgram is actviated but after pressing the show button it giving dump.
the message in the dump is <b>Type conflict when calling a FORM.</b>
I have define field catalog like this.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = w_repid
I_CALLBACK_PF_STATUS_SET = 'STANDARD'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'p_header1'(001)
I_CALLBACK_HTML_TOP_OF_PAGE = 'p_header1'(001)
I_GRID_TITLE = 'Outstanding Agewise Customer Report'
IT_FIELDCAT = IT_FIELDCAT
it_events = it_events
TABLES
T_OUTTAB = t_fit
and form i have define like this
FORM USER_COMMAND using pucom like sy-ucomm extab type slis_extab.
data : selfield type slis_selfield .
CASE pucom.
WHEN 'SHOW'. "(this is the function code of ur button)
if selfield-fieldname = 'VBELN'.
Perform Show_data using selfield-value.
elseif selfield-fieldname = ' '.
MESSAGE E015(ZMO) WITH 'Please select One Row'.
endif.
ENDCASE.
ENDFORM.
When i have debug the program, I found it will not executing my code , the progrm goes to execute one Stranded code with following name..
form user_command using r_ucomm type sy-ucomm
r_refresh
r_exit
rs_stable type lvc_s_stbl.
data: ls_selfield type slis_selfield.
On this form my program is giving me dump on following line.
>>>>> rs_stable-row = ls_selfield-row_stable.
1103 rs_stable-col = ls_selfield-col_stable.
Please tell me what the problem and how to resolve the same.
Regards
Swati... -
I am working on ALV PUSH BUTTONS. When I am clicking the button some records in an internal table is displayed in ALV. Each column is repeated twice for the first time and on the second time it is working fine.What is the reason and what I have to do.I am using 3 push buttons. And with the same itab.But according to the buttons clicked column display will vary.
Hi,
Handle the EVENT of each push button & modify the FIELDCATALOG accorindlgy with the names of columns which you want to be displayed against each button.
Best regards,
Prashant -
i want a push button in containar. is this possible?
first i have placed the container and named it . then i clicked on push button and trying to place it on container , but it is not allowing to place on it.
i have written a toolbar event , once the push button is clicked , then i want to handle it. But i am unable to put the pushbutton on the screen while doing ooalv .
please tell me how to place the push button .SORRY I AM TRYING TO ARRANGE MY CODE BUT I AM NOT ABLE TO ARRANGE IT PROPERLY
i have placed a push both ITEM and if i click it will fetch the item details of purchase order.
when i click the ITEM ,the details are displayed on the grid. Here the ITEM button is still comming,
I dont want this button to appear also i dont want to dislay the toolbar when i click the ITEM button .Please tell me where i need to change the code.
REPORT zdemo_ooalv_user_command .
DATA : o_container TYPE REF TO cl_gui_custom_container,
o_grid TYPE REF TO cl_gui_alv_grid.
DATA : it_ekko LIKE TABLE OF ekko,
wa_ekko LIKE ekko,
it_ekpo LIKE TABLE OF ekpo.
DATA : wa_layout TYPE lvc_s_layo.
CLASS lcl_event_handler DEFINITION.
PUBLIC SECTION.
METHODS : handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
handle_user_command FOR EVENT user_command OF
cl_gui_alv_grid IMPORTING e_ucomm.
ENDCLASS. "lcl_event_handler DEFINITION
CLASS lcl_event_handler IMPLEMENTATION.
METHOD : handle_toolbar.
DATA : wa_toolbar TYPE stb_button.
CLEAR wa_toolbar.
wa_toolbar-function = 'ITEM'.
wa_toolbar-icon = 'ICON_DETAIL'.
wa_toolbar-text = 'PREVIOUS'.
APPEND wa_toolbar TO e_object->mt_toolbar.
ENDMETHOD. ":
METHOD handle_user_command.
CASE e_ucomm.
WHEN 'ITEM'.
SELECT * INTO TABLE
it_ekpo FROM ekpo FOR ALL ENTRIES IN it_ekko
WHERE ebeln = it_ekko-ebeln.
CALL METHOD o_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'EKPO'
CHANGING
it_outtab = it_ekpo.
ENDCASE.
ENDMETHOD. "handle_user_command
ENDCLASS. "lcl_event_handler IMPLEMENTATION
START-OF-SELECTION.
CALL SCREEN 100.
MODULE read_data OUTPUT.
SELECT * INTO TABLE it_ekko FROM ekko
UP TO 10 ROWS.
ENDMODULE. " read_data OUTPUT
MODULE status_0100 OUTPUT.
SET PF-STATUS 'ZSTATUS'.
SET TITLEBAR 'Handle the toolbar events'.
CREATE OBJECT o_container
EXPORTING
PARENT =
container_name = 'CONTAINER'.
IF sy-subrc = 0.
CREATE OBJECT o_grid
EXPORTING
* I_SHELLSTYLE = 0
* I_LIFETIME =
i_parent = o_container.
IF sy-subrc = 0.
wa_layout-sel_mode = 'D'.
CALL METHOD o_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'EKKO'
is_layout = wa_layout
CHANGING
it_outtab = it_ekko
*CREATE an object for the event handler class
DATA : o_handler TYPE REF TO lcl_event_handler.
CREATE OBJECT: o_handler.
*Regestring the events
SET HANDLER : o_handler->handle_toolbar FOR o_grid,
o_handler->handle_user_command FOR o_grid.
*To trigger the toolbar event
CALL METHOD o_grid->set_toolbar_interactive.
ENDIF.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT> -
Disabled button generates events
Hello,
I have a radio button that I want to disable while a background process is running.
After the process finishes, I enable the button again.
However, if the user clicks on the disabled button during the background process, an ActionEvent still gets generated.
Then when the button is re-enabled, it responds to the event that was generated while it was disabled. I want to prevent my button from responding to events generated while it was disabled.
I do not want to use the getGlassPane.setVisible(true) technique because I still want my cancel button to be able to generate events during the background process.
I am using JDK 1.3.1 and my button is in a panel contained in a JFrame application.
Suggestions?
Thank you,
Ted HillHello,
I have a radio button that I want to disable while a background process is running.
After the process finishes, I enable the button again.
However, if the user clicks on the disabled button during the background process, an ActionEvent still gets generated.
Then when the button is re-enabled, it responds to the event that was generated while it was disabled. I want to prevent my button from responding to events generated while it was disabled.
I do not want to use the getGlassPane.setVisible(true) technique because I still want my cancel button to be able to generate events during the background process.
I am using JDK 1.3.1 and my button is in a panel contained in a JFrame application.
Suggestions?
Thank you,
Ted Hill -
ABAP SAP script unable to see push buttons
Dear friends,
I am new to ABAP and I am trying to create SAP script layout, but I created new form, I did not see Pages, Windows and Page Windows push buttons.
I could not figure out why I am unable see those windows? Please, can somebody help? I don't see even on first page where I can create new Form name.
I really appreciated your help.
ShaileshHi,
In script go to SETTING---> there select PC EDITOR check box , uncheck graphic editor.
U will get it. -
Disabled buttons still generate events
It seems that disabled buttons still generate events in business one. If a button is disabled (even a standard one) click events can still be seen in the SBO event logger. I would have expected a disabled button to be completely disabled and no events to be generated whereas as it is I have to check in the event handler to see if the button is enabled or not.
Is my understanding of this correct?
Has anyone else had issues like this?
Gordon WoodHi Gordon,
That sounds like an issue with the SBO Event Logger because no event is actually triggered in the addon when the button is disabled.
Kind Regards,
Owen -
How to add a push button in ALV Grid Top-of-page
Is it possible to add a push button to the top-of-page in Alv grid display?if yes, then how? I am not using OO ABAP and am using reuse_alv_grid_display with top-of-page event.
Hi,
I am not sure whether we can add push button in top-of -page or not. But instead of that if you want to add button on toolbar as per your requirement then follow below link. it will useful.
http://www.sap-img.com/abap/example-of-a-simple-alv-grid-report.htm
Ram. -
Creating push button on Selection screen application toolbar
Hi Friends,
this is a HR-ABAP report. I have to create a push button on Selection screen. when user clicks on that push button 'MODAL DIALOG BOX' has to be displayed containing some data.
plz kindly give some sample code to do this.
Regards,
Radhika Dasharatha.Hi,
1)Use SELECTION-SCREEN PUSHBUTTON /10(20) PUSH USER-
COMMAND 'ABC'. in selection screen.
2) Give the static name to button in INITIALIZATION event like PUSH = 'PRESS'.
3) At selection screen.
if sy-ucomm eq 'ABC'.
call FM HR_BE_GE_MODAL_DIALOG
endif.
Thanks
Sandeep
Reward if useful -
Plz tell me the syntax
Go through this
SELECTION-SCREEN - PUSHBUTTON
Syntax
SELECTION-SCREEN PUSHBUTTON [/][pos](len) button_text
USER-COMMAND fcode
[VISIBLE LENGTH vlen]
[MODIF ID modid]
[ldb_additions].
Extras:
1. ... [/][pos](len)
2. ... USER-COMMAND fcode
3. ... VISIBLE LENGTH vlen
4. ... MODIF ID modid
Effect
This statement creates a pushbutton on the current selection screen. The text on the pushbutton is determined by the content of button_text. The rules that apply to text also apply to button_text when creating an output field.
The additions ldb_additions can only be used in the selection include for a logical database.
Notes
You can use the function module ICON_CREATE to assign an icon, a quick info text and a corresponding text to a pushbutton. When you do this, you must specify an adequate length len for the pushbutton so that the icon can be displayed internally and adjust the visible length with VISIBLE LENGTH.
Once the event block in AT SELECTION-SCREEN has been processed, the system usually returns to displaying the selection screen. To exit selection screen processing and continue executing the program, you can only choose Execute or Cancel. This means pushbuttons on selection screens are intended primarily for use for dynamic modifications to the selection screen rather than to control the program.
Addition 1
... [/][pos](len)
Effect
You must specify the position of the output field using [/][pos](len). The syntax and meaning of [/][pos](len) are the same as when creating horizontal lines, although in this case, len defines the length of the pushbutton on the selection screen. If a pushbutton extends beyond position 83 or beyond the edge of a block with a frame, it is cut off at the right hand side.
Addition 2
... USER-COMMAND fcode
Effect
If you specify the USER-COMMAND addition, the pushbutton must be assigned a function code fcode. The function code fcode must be specified directly and can only contain a maximum of 20 characters.
Before you can work with the pushbutton, you must specify a TABLES statement to declare an interface work area for the structure SSCRFIELDS from the ABAP Dictionary.
If the user selects the pushbutton on the selection screen, the runtime environment triggers the event AT SELECTION-SCREEN and the function code fcode is transferred to the ucomm component in the interface work area sscrfields.
Note
If the function code of a pushbutton corresponds to a function code used in the GUI status of the selection screen, the selection screen processing is influenced accordingly.
Addition 3
... VISIBLE LENGTH vlen
Effect
The VISIBLE LENGTH addition defines the visible length vlen of the pushbutton and your text. The syntax and meaning of this addition are the same as when creating output fields, although a pushbutton is never displayed as shorter than the text defined for it.
Addition 4
... MODIF ID modid
Effect
The MODIF ID addition assigns the pushbutton to the modification group modid that is assigned to the column group1 on the system table screen. This means it can be modified using a MODIFY SCREEN statement before the selection screen is displayed.
Example
Define and access a stand-alone selection screen 500 with two pushbuttons in an executable program. An icon and a quick info text are created for the second pushbutton.
TABLES sscrfields.
TYPE-POOLS icon.
SELECTION-SCREEN:
BEGIN OF SCREEN 500 AS WINDOW TITLE title,
PUSHBUTTON 2(10) but1 USER-COMMAND cli1,
PUSHBUTTON 12(30) but2 USER-COMMAND cli2
VISIBLE LENGTH 10,
END OF SCREEN 500.
AT SELECTION-SCREEN.
CASE sscrfields.
WHEN 'CLI1'.
WHEN 'CLI2'.
ENDCASE.
START-OF-SELECTION.
title = 'Push button'.
but1 = 'Button 1'.
CALL FUNCTION 'ICON_CREATE'
EXPORTING
name = icon_information
text = 'Button 2'
info = 'My Quickinfo'
IMPORTING
RESULT = but2
EXCEPTIONS
OTHERS = 0.
CALL SELECTION-SCREEN '0500' STARTING AT 10 10.
THnaks
Ankur Sharma -
Using application toolbar push buttons in report
Hello folks,
I'm new to ABAP and so i'm facing some problems with my code.
I have copied a standard program to my Z program (ZXXXXX). I have added few push buttons to the application toolbar of the Z program (ZXXXXX) and now on click of the 1st button i need to call another standard program.
Where should I write the code for the action to be performed on click of the buttons? I am aware that it is generally written in the PAI module but I did not have this module, its a normal report program and not a module pool.
Need your help.
Thanks in advance.Welcome on SCN!
Please do not forget to read Welcome and Rules of Engagement
As for the question, you would need to clarify where this application toolbar option is placed:
- in selection screen?
- in list (output of program)?
If first applies, do as above suggested (using AT SELECTION-SCREEN event).
If second is what you need, use event AT USER-COMMAND .
In both cases variable sy-ucomm will hold function code of triggered function (i.e sy-ucomm = 'MY_BUTTON' ). If that condition is fulfilled simply use SUBMIT 'MY_PROGRAM' AND RETURN , or just SUBMIT 'MY_PROGRAM' if you don't want to get back to calling program.
Regards
Marcin -
Push Buttons in the custom Container
Hi
I have created one container using cl_gui_custom_container.
Now I have splitted the container into two parts as left and right using cl_gui_splitter_container.
Is there any way to create push buttons in the left container.
Regards
VijayPushbutton is an example of classic control while custom container is an example of GUI control . You can't mix controls of first type with the latter meaning you can embed classic control in GUI container. You can have such control only outside any container (on screen canvas). This is very common that you have docking container on the left and classic controls on the right side of the screen (not container)
To be able to have a button inside container, you will have to use cl_gui_toolbar class adding your options there and handling them as normal OO event. This way you only combine GUI controls (toolbar + container). Otherwise it is not possible.
Regards
Marcin
Maybe you are looking for
-
Error Message when trying to burn CD from Playlist
Never had this problem before, but when I try to burn a playlist, I get the error message "there is a file whose file is bigger than that of a blank CD. You need to insert a blank DVD." Can anyone tell me what I am doing wrong. Thanks in advance for
-
Connecting old Ipod nano to new imac
We have a new imac and want to play our previously loaded nano on it. The nano was loaded from an itunes account on another PC in our house. When you plug the nano into the imac, the songs on the nano appear on the imac display, but they are grayed-o
-
Why nothing has changed let me buy this tune with the same ID and password that I have used to purchase other tracks with no problems,
-
Hi, I posted this last night, many of you may not have seen it! Please assist. Hello experts, how are you? I have a program that is not working as a result of a missing table <b>K9RDEV3000001</b>, could anyone help with the possible location or defin
-
Upgrading from 3.0 beta 5
Every time I click on the "Check for Update" button, it says, "This current version of the iPhone (3.0) is the current version." I'm currently running on beta 5 and I just updated my iTunes to version 8.2 so I have no idea how to upgrade the firmware