Handle events in global class
Hi all,
I am working on handling events in global classes.
but my event is not triggererd,i m not able to find where it's going wrong.
Below is my code.
Global Class:ZCL_TEST_EVENT
events :EXCEEDEDRANGE
methods:CHECKRANGE,DISPLAYVENDOR.
Checkrange is event handler for exceededrange.
below is the code for methods.
method checkrange.
write:/ 'Vendor not within the range'(001).
exit.
endmethod.
method displayvendor.
DATA : exlfa1 TYPE lfa1.
IF imlifnr NOT BETWEEN 1000 AND 2000.
RAISE EVENT exceededrange.
ENDIF.
SELECT SINGLE * FROM lfa1
INTO exlfa1
WHERE lifnr = imlifnr
IF sy-subrc = 0.
WRITE : / exlfa1-lifnr,exlfa1-name1.
ELSE.
WRITE : / 'No vendor found'(002).
ENDIF.
endmethod.
below is the report I developed.
REPORT ztest_113.
parameters :plifnr type lfa1-lifnr obligatory.
data : obj type ref to ZCL_TEST_EVENT.
START-OF-SELECTION.
CREATE OBJECT obj.
CALL METHOD obj->displayvendor
EXPORTING
imlifnr = plifnr
Please help
Yes, you do need to write the SET HANDLER statement. As per your current design, you can set the event handler in your method CONSTRUCTOR. Like:
method constructor.
SET HANDLER me->CHECKRANGE FOR me.
endmethod.
Regards,
Naimesh Patel
Similar Messages
-
Hi,
I used this link for create Events in Global Class through SE24.....
[http://sapabapnotes.blogspot.com/]
I do same steps as given in this link....but it show some syntax error when i check it...
Error : "IT_LFA1" is not an internal table - the "OCCURS n" specification is missing...
Where i define it...
Plz tell me wat can i do...
Thanks...
Edited by: Prince Kumar on Jan 25, 2008 12:25 PM
Edited by: Prince Kumar on Jan 25, 2008 12:46 PMHi,
Thanks for reply....
I create a table type with structure LFA1....
Plz tell me that in the interface tab....wat i write....
Plz clear...
thanks.... -
Event handling in global class (abap object)
Hello friends
I have 1 problem regarding events in abap object... how to handel an event in global class in se24 .
Regards
Reema jain.
Message was edited by:
Reema JainHello Reema
The following sample report shows how to handle event in principle (see the § marks)..
The following sample report show customer data ("Header"; KNB1) in the first ALV list and sales areas ("Detail"; KNVV) for the selected customer (event double-click) in the second ALV list.
*& Report ZUS_SDN_TWO_ALV_GRIDS
REPORT zus_sdn_two_alv_grids.
DATA:
gd_okcode TYPE ui_func,
go_docking TYPE REF TO cl_gui_docking_container,
go_splitter TYPE REF TO cl_gui_splitter_container,
go_cell_top TYPE REF TO cl_gui_container,
go_cell_bottom TYPE REF TO cl_gui_container,
go_grid1 TYPE REF TO cl_gui_alv_grid,
go_grid2 TYPE REF TO cl_gui_alv_grid,
gs_layout TYPE lvc_s_layo.
DATA:
gt_knb1 TYPE STANDARD TABLE OF knb1,
gt_knvv TYPE STANDARD TABLE OF knvv.
"§1. Define and implement event handler method
" (Here: implemented as static methods of a local class)
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING
e_row
e_column
es_row_no
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_double_click.
* define local data
DATA:
ls_knb1 TYPE knb1.
CHECK ( sender = go_grid1 ).
READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row-index.
CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
CALL METHOD go_grid1->set_current_cell_via_id
EXPORTING
* IS_ROW_ID =
* IS_COLUMN_ID =
is_row_no = es_row_no.
* Triggers PAI of the dynpro with the specified ok-code
CALL METHOD cl_gui_cfw=>set_new_ok_code( 'DETAIL' ).
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1
WHERE bukrs = '1000'.
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Create splitter container
CREATE OBJECT go_splitter
EXPORTING
parent = go_docking
rows = 2
columns = 1
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Get cell container
CALL METHOD go_splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = go_cell_top.
CALL METHOD go_splitter->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = go_cell_bottom.
* Create ALV grids
CREATE OBJECT go_grid1
EXPORTING
i_parent = go_cell_top
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
"§2. Set event handler (after creating the ALV instance)
SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid1. " Or:
" SET HANDLER: lcl_eventhandler=>handle_double_click FOR all instances.
CREATE OBJECT go_grid2
EXPORTING
i_parent = go_cell_bottom
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Display data
gs_layout-grid_title = 'Customers'.
CALL METHOD go_grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'KNB1'
is_layout = gs_layout
CHANGING
it_outtab = gt_knb1
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
gs_layout-grid_title = 'Customers Details (Sales Areas)'.
CALL METHOD go_grid2->set_table_for_first_display
EXPORTING
i_structure_name = 'KNVV'
is_layout = gs_layout
CHANGING
it_outtab = gt_knvv " empty !!!
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Link the docking container to the target dynpro
CALL METHOD go_docking->link
EXPORTING
repid = syst-repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* NOTE: dynpro does not contain any elements
CALL SCREEN '0100'.
* Flow logic of dynpro (does not contain any dynpro elements):
*PROCESS BEFORE OUTPUT.
* MODULE STATUS_0100.
*PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0100.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'. " contains push button "DETAIL"
* SET TITLEBAR 'xxx'.
* Refresh display of detail ALV list
CALL METHOD go_grid2->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
EXCEPTIONS
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.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
CASE gd_okcode.
WHEN 'BACK' OR
'END' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
* User has pushed button "Display Details"
WHEN 'DETAIL'.
PERFORM entry_show_details.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form ENTRY_SHOW_DETAILS
* text
* --> p1 text
* <-- p2 text
FORM entry_show_details .
* define local data
DATA:
ld_row TYPE i,
ls_knb1 TYPE knb1.
CALL METHOD go_grid1->get_current_cell
IMPORTING
e_row = ld_row.
READ TABLE gt_knb1 INTO ls_knb1 INDEX ld_row.
CHECK ( syst-subrc = 0 ).
SELECT * FROM knvv INTO TABLE gt_knvv
WHERE kunnr = ls_knb1-kunnr.
ENDFORM. " ENTRY_SHOW_DETAILS
Regards
Uwe -
Global class event handler not called
I am having a problem where I created a function module that instatiates an application log class. This application log class has methods ON_* for public events of other classes.
The function module then processes its routines and as a result some of these events are raised. Ex: The function module creates a Purchase order and in that class I have a public even PO_CREATED that is raised upon succesfull creation of the PO. The global class APPLICATION_LOG I created has a method ON_PO_CREATED for event PO_CREATED of class ZCL_MAT_PO.
I put a break point in the APPLICATION LOG method but is os not called.
ANy idea of what Iam doing wrong or missing?
Thanks,
LeoHi Leo, did you set the handler method?
SET HANDLER <method_name> FOR <object>.
Regards,
Rich Heilman -
Hi,
I have created an ALV grid control and I am also handling the before_user_command event of cl_gui_alv_grid class.
My aim is to use POPUP_TO_CONFIRM function module when the users click on the add/delete row button.
Control is going to the event if I am clicking on any other button of the control except add/delete row buttons.
And in the class attributes those operation description is saying they are local.
Please let me know how make control to go to before_user_command event when users click on add/delete button.
Thanks in advance,
Suneel CHi Suneel,
For you requirement, I dont see why you cant include the functionality for the pop up within the USER_COMMAND event itself.
Algorithm for the USER_COMMAND event:
Step 1: Check E_UCOMM is 'ADD' or 'DELT'.
Step 2: If yes, call FM for POPUP_TO_CONFIRM; else continue to other E_UCOMM
Step 3: If ans is 'No', exit Method - else continue with Add/ Delete as required
Cheers,
Aditya -
Handling ALV Toolbar in Customized Global Class
Hi Experts!!
We have a global class ZCL_TEST_DISP in which there is a private attribute go_grid TYPE REF TO cl_gui_alv_grid. Now in this custom class, we have methods like SET_DISPLAY, EXCLUDE_TOOLBAR etc in which instance of go_grid is created and methods of cl_gui_alv_grid are called.
Now my requirement is to create a new pushbutton in ALV output. I know how to do it normally. I checked BCALV_GRID_05 for this. But as instance of grid is in ZCL_TEST_DISP, I must create methods to hanle toolbar using this class only. I am wondering how to proceed.
Can somebody please help me out?
Thanks a lot.Checked an existing global class as reference and solved.
-
How to use global classes and display returned data?
Hello experts,
I have the following code in a program which accesses a global class (found in the class library). It executes one it's static methods. What I would like to do is to get hold of some elements of the returned data. How do I do that please?
Your help is greatly appreciated.
***Use global class CL_ISU_CUSTOMER_CONTACT
DATA: o_ref TYPE REF TO CL_ISU_CUSTOMER_CONTACT.
DATA: dref_tab LIKE TABLE OF O_ref.
DATA: begin OF o_ref2,
CONTACTID TYPE CT_CONTACT,
P_INSTANCES TYPE string,
P_CONTEXT TYPE CT_BPCCONF,
P_CONTROL TYPE ISU_OBJECT_CONTROL_DATA,
P_DATA TYPE BCONTD, "<<<=== THIS IS A STRUCTURE CONTAINING OTHER DATA ELEMENTS
P_NOTICE TYPE EENOT_NOTICE_AUTO,
P_OBJECTS TYPE BAPIBCONTACT_OBJECT_TAB,
P_OBJECTS_WITH_ROLES TYPE BAPIBCONTACT_OBJROLE_TAB,
end of o_ref2.
TRY.
CALL METHOD CL_ISU_CUSTOMER_CONTACT=>SELECT "<<<=== STATIC METHODE & PUBLIC VISIBILITY
EXPORTING
X_CONTACTID = '000001114875' "Whatever value here
RECEIVING
Y_CONTACTLOG = o_ref
ENDTRY.
WHAT I WOULD LIKE TO DO IS TO MOVE o_ref TO o_ref2 and then display:
1) P_DATA-PARTNER
2) P_DATA-ALTPARTNER
How can I do this please?I now have the following code. But when I check for syntax I get different error. They are at the end of the list.
Here is the code the way it stands now:
================================================
***Use global class CL_ISU_CUSTOMER_CONTACT
DATA: oref TYPE REF TO CL_ISU_CUSTOMER_CONTACT.
DATA: dref_tab LIKE TABLE OF oref.
DATA: begin OF oref2,
CONTACTID TYPE CT_CONTACT,
P_INSTANCES TYPE string,
P_CONTEXT TYPE CT_BPCCONF,
P_CONTROL TYPE ISU_OBJECT_CONTROL_DATA,
P_DATA TYPE BCONTD, "THIS IS A STRUCTURE CONTAINING OTHER DATA ELEMENTS
P_NOTICE TYPE EENOT_NOTICE_AUTO,
P_OBJECTS TYPE BAPIBCONTACT_OBJECT_TAB,
P_OBJECTS_WITH_ROLES TYPE BAPIBCONTACT_OBJROLE_TAB,
end of oref2.
TRY.
CALL METHOD CL_ISU_CUSTOMER_CONTACT=>SELECT " STATIC METHODE & PUBLIC VISIBILITY
EXPORTING
X_CONTACTID = '000001114875' "Whatever value here
RECEIVING
Y_CONTACTLOG = oref
ENDTRY.
field-symbols: <FS1> type any table,
<wa_oref2> type any.
create data dref_tab type handle oref. " <<===ERROR LINE
assign dref->* to <FS1>.
Loop at <FS1> assigning <wa_oref2>.
*use <wa_orfe2> to transfer into oref2.
endloop.
write: / 'hello'.
=========================================
Here are the errors I get:
The field "DREF" is unknown, but there is a field with the similar name "OREF" . . . .
When I replace itr by OREF I get:
"OREF" is not a data reference variable.
I then try to change it to dref_tab. I get:
"DREF_TAB" is not a data reference variable.
Any idea? By the way, must there be a HANDLE event for this to work?
Thanks for your help. -
Greetings,
Using VS 2008 -VSTO - Word 2007 Add-In wizard.
Is there a way to add your own global references to the system generated Globals internal class? For example, I'd like to keep track of the document opened during a session. if an event handler gets a reference to the document deep clones it and adds it to a hash structure, I'd like this "structure" to be stored under the Global internal class.
On a different note, I do appreciate the ammount of work that went into build this framework. It makes it simple to build add-ins. The problem I have is that a lot of the power has been hidden by the framework, while that is very good for novices, it takes away control for an old guy like me. Would it be possible to build just a assembly that gets loaded into an office application address space and shares the document model with it? Once again, the wizard is good, but I'd like a little more room to wiggle.
Thanks,
PPYou can definately add your own properties to the generated Globals class. Globals is a partial class defined in your add-in's designer file. To extend it, simply add another partial implementation in another file. Below is an example in C#:
internal sealed partial class Globals
internal static string MyCustomString { get; set; }
public partial class ThisAddIn
private void ThisAddIn_Startup(object sender, System.EventArgs e)
Globals.MyCustomString = "Hello world!";
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
Here is another example in VB:
Partial Friend NotInheritable Class Globals
Private Shared _MyCustomString As String
Friend Shared Property MyCustomString() As String
Get
Return _MyCustomString
End Get
Set(ByVal value As String)
_MyCustomString = value
End Set
End Property
End Class
Public Class ThisAddIn
Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
Globals.MyCustomString = "Hello world!"
End Sub
Private Sub ThisAddIn_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown
End Sub
End Class
Regarding your second question, what control do you feel you have lost? VSTO add-ins have access to the same Word object model used by non-VSTO add-ins. Is there something in particular you would like to do in your add-in that you feel VSTO does not allow?
-Phil -
Global classes / Doppelclick
Hello Every Body,
please can someone tell me how can implement Doppelclick using Global classes.!!
Best regards.
danielHello Daniel
I assume you want to handle DOUBLE_CLICK events of controls (e.g. ALV grid, tree) using global classes.
That's a piece of cake. Below I outline a possible procedure:
(1) Create your control instance (e.g. go_grid, CL_GUI_ALV_GRID)
(2) Create an instance of your global class. The CONSTRUCTOR method may look like this:
CREATE OBJECT go_myclass
EXPORTING
io_instance = go_grid. " Assumption: class should only handle ALV grid events
METHOD constructor.
me->mo_grid = io_instance. " class may have instance attribute for grid instance
me->set_handler( ). " perhaps private method for setting event handler
ENDMETHOD.
METHOD set_handler.
SET HANDLER: handle_double_click FOR me->mo_grid.
ENDMETHOD.
(3) Create an event handler method (e.g. HANDLE_DOUBLE_CLICK for event DOUBLE_CLICK of cl_gui_alv_grid) within your global class.
That's it. As soon as the user double-clicks on a row in the ALV grid (go_grid) the method HANDLE_DOUBLE_CLICK of your global class will be called to handle the event.
Regards
Uwe -
Hi!
I would like to know which one of the following is the best way to handle events in Swing application.
Method 1
Write annonymus inner classes in the same class
Method 2
=======
Write a seperate class which extends the adapter class of the event handling and create an object of that in the main class and assign it to the components with addActionHandler() method.
I am trying to use the second one and I have the following design issue.
I have a class frmMain.java in which I have a frame and to that frame I am adding a panel which consists of 'N' No. of components.
I want to make this panel added to the frame when I click on a menu item (login) and want to remove the panel from frame when I click on a menu item(logout).
I have a main class called Application.java where I create the object of my frame(frmMain.java).
Thanks in advance,
AV1. Your JFrame is now subject to receive action events from anywhere. You will have to be more careful that you respond only to the right events.
2. If you have a lot of possible consequences to an event(for example, based on button pressed), you'll need a long if...then...else statement to determine what to do based on the source of the event.
3. With individual ActionListener classes, it's easier to add the same listener to multiple components and no need to worry about source.
4. Kind of the same thing: With individual classes, the event and its consequences are so tightly coupled.
End preaching....basically, my style boils down to what I call the tool set vs Swiss army knife rule. Java seems designed around the concept of a large number of specific purpose classes vs a smaller number of multi purpose classes and I think its a design methodology that makes sense, because I believe strongly in functional isolation in my code. -
hi,
Hi,
I am displaying some fields from VBAP in ALV gid and have give drop down check box to storage location making it editable so if the user changes Storage location of
some entries and clicks SAVE button, when we click save button i need to capture all the rows that were been changed and update VA02 using these records through bapi.
but iam not able to capture this SAVE event but iam able to capture Enter and cursor event.
i have written following code for this
LOCAL CLASSES: Definition
class lcl_event_receiver: local class to handle event CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed.
PRIVATE SECTION.
ENDCLASS. "lcl_event_receiver DEFINITION
LOCAL CLASSES: Implementation
class lcl_event_receiver (Implementation)
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_data_changed.
DATA: l_error_in_data TYPE c.
PERFORM handle_data_changed USING er_data_changed l_error_in_data.
*§7.Display application log if an error has occured.
IF l_error_in_data EQ 'X'.
CALL METHOD er_data_changed->display_protocol.
ENDIF.
ENDMETHOD. "handle_data_changed
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
*& Form handle_data_changed
Identify columns which were changed and check input
-->P_ER_DATA_CHANGED text
FORM handle_data_changed USING p_er_data_changed
TYPE REF TO cl_alv_changed_data_protocol
p_error_in_data TYPE c.
DATA : lw_mod_cell TYPE lvc_s_modi ,
l_value TYPE lvc_value ,
l_lgort TYPE lgort_d.
SORT p_er_data_changed->mt_mod_cells BY row_id .
LOOP AT p_er_data_changed->mt_mod_cells INTO lw_mod_cell
WHERE fieldname = 'LGORT'.
CALL METHOD p_er_data_changed->get_cell_value
EXPORTING
i_row_id = lw_mod_cell-row_id
i_fieldname = 'LGORT'
IMPORTING
e_value = l_value.
SELECT SINGLE lgort FROM t001l INTO l_lgort WHERE werks = p_werks
AND lgort = l_value.
IF sy-subrc NE 0.
In case of error, create a protocol entry in the *application log.
CALL METHOD p_er_data_changed->add_protocol_entry
EXPORTING
i_msgid = '0K'
i_msgno = '000'
i_msgty = 'E'
i_msgv1 = text-003
i_msgv2 = l_value
i_msgv3 = text-004
i_fieldname = lw_mod_cell-fieldname
i_row_id = lw_mod_cell-row_id.
p_error_in_data = 'X'.
EXIT.
ELSE.
*§5b.If the value is valid change values of
cells.
CALL METHOD p_er_data_changed->modify_cell
EXPORTING
i_row_id = lw_mod_cell-row_id
i_fieldname = lw_mod_cell-fieldname
i_value = l_value.
READ TABLE t_list1 INTO w_list1 INDEX lw_mod_cell-row_id.
IF sy-subrc EQ 0.
*comparing old value with the changed value
IF w_list1-lgort <> l_value.
MOVE: w_list1-werks TO w_list3-werks,
w_list1-matnr TO w_list3-matnr,
w_list1-arktx TO w_list3-arktx,
w_list1-vbeln TO w_list3-vbeln,
w_list1-posnr TO w_list3-posnr,
w_list1-pstyv TO w_list3-pstyv,
w_list1-vstel TO w_list3-vstel,
w_list1-auart TO w_list3-auart,
w_list1-kwmeng TO w_list3-kwmeng,
w_list1-vrkme TO w_list3-vrkme,
w_list1-mbdat TO w_list3-mbdat,
l_value TO w_list3-lgort.
APPEND w_list3 TO t_list3.
*t_list3 will contain all the records that are changed
CLEAR w_list3.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
*& Module STATUS_0100 OUTPUT
text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAIN100'.
IF go_custom_container IS INITIAL.
create a custom container control for our ALV Control
CREATE OBJECT go_custom_container
EXPORTING
container_name = g_cont_on_main
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF sy-subrc NE 0.
Display error message.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = sy-repid
txt2 = sy-subrc
txt1 = 'The control could not be created'.
ENDIF.
create an instance of alv control
CREATE OBJECT go_grid
EXPORTING
i_parent = go_custom_container.
*If display or change radio button is cheked
IF ( p_chng = 'X' OR p_disp = 'X' ) .
Set a titlebar for the grid control
g_layout-grid_title = 'Sales Orders'.
g_layout-excp_fname = 'TRAFFIC_LIGHT'.
Define a drop down table.
PERFORM set_drdn_table.
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
is_layout = g_layout
CHANGING
it_outtab = t_list1
it_fieldcatalog = t_fieldcat1
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
register ENTER and CURSOR to raise event DATA_CHANGED.
(Per default the user may check data by using the check icon).
CALL METHOD go_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
CALL METHOD go_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
CREATE OBJECT g_event_receiver.
SET HANDLER g_event_receiver->handle_double_click FOR go_grid.
SET HANDLER g_event_receiver->handle_hotspot_click FOR go_grid .
SET HANDLER g_event_receiver->handle_data_changed FOR go_grid .
ENDIF.
CALL METHOD cl_gui_control=>set_focus
EXPORTING
control = go_grid.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
text
MODULE user_command_0100 INPUT.
ok_code = sy-ucomm.
CASE ok_code.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN 'SAVE'.
PERFORM update_sales_order using t_list3[].
endcase.
Thanks in Advance,
SiriHi Sirisha,
You can get the event code for Enter because you have regitered in the event reciever .
But for the SAVE you will have to set in the PF-status of the screen and not the ALV-grid save .
Please award if helpful. -
Major global classes used in abap objects
Hi,
I am new to the abap objects and till now i am to understand that the role of the global classes are important in the abap object program. I had tried to search on the net but i was not able to get the desired result.
I want to know which are the major global classes which are used in the ABAP objects.
Plzz provide me guidelines for it.Ricx,
It depends on your requirement.
For alv's we use these global classes. For Webdynpro related alv we use different global classes.
CL_GUI_ALV_GRID (List Viewer)
CL_GUI_ALV_GRID_BASE (Basis Class for ALV grid)
CL_GUI_ALV_TREE (ALV Tree Control)
CL_GUI_ALV_TREE_SIMPLE (Simple ALV Tree)
CL_ALV_TABLE_CREATE (Dynamic Creation of ALV Data Table)
CL_ALV_TREE_BASE (Basis Class ALV Tree Control)
CL_CK_ALVTREE_NKEY_2_OBJECT (Converter Node Key Object)
CL_ALV_EVENT_DATA (Changing Data Container for Events)
CL_ALV_EVENT_TOOLBAR_SET (ALV Context menu)
Regards,
Arun. -
Listen for event in own class?
Hi
I dispatch events from models to classes listening. How do you set up an event and listener in the same class?
Eg for the former - a model "MyModel" to class - it's:
public static const MY_VAR:String = "myVar";
triggered by...
dispatchEvent(new Event(MY_VAR));
picked up in another class by...
modelVar.addEventListener(MyModel.MY_VAR, doSomething);
but what if the class that's dispatching also has the listener?
So if MyClass is dispatching the event, along the lines of...
addEventListener(MyClass.MY_VAR, doSomething);
Cheers for taking a lookVery often I'm waiting for a few key items before I can finally do something else. Setting simple flags or checking nulls can help with this.
Often I download multiple data structures (JSON/XML/etc) and I need all of them before I can parse them because the co-depend on each other. URLLoaders finish at different times so I just set a flag for what I need but check if all are complete before I continue each time one finishes.
e.g.
package
public class IHateWaiting extends EventDispatcher
public static const MY_VAR:String = "myVar";
private var _xmlA:XML;
private var _xmlB:XML;
public function IHateWaiting()
// load A
var ulA:URLLoader = new URLLoader();
ulA.addEventListener(Event.COMPLETE, _handleFinishedF);
ulA.load(new URLRequest("http://www.example.com/a.xml"));
// load B
var ulB:URLLoader = new URLLoader();
ulB.addEventListener(Event.COMPLETE, _handleFinishedF);
ulB.load(new URLRequest("http://www.example.com/b.xml"));
// listen to self
addEventListener(IHateWaiting.MY_VAR, _handleAppEventF);
private function _handleFinishedF(e:Event):void
if (e.type == Event.COMPLETE)
var data:XML = XML(e.target.data);
// A or B? any way you can tell
if (data.A.length() > 0) _xmlA = data;
else if (data.B.length() > 0) _xmlB = data;
// event method (requires extra handler or a fake event)
if (_xmlA && _xmlB) dispatchEvent(new Event(IHateWaiting.MY_VAR));
// preferred direct reference, no handler needed
// if (_xmlA && _xmlB) _parseXML();
private function _handleAppEventF(e:Event):void
if (e.type == IHateWaiting.MY_VAR) _parseXML();
private function _parseXML():void
// parse XML
I recommend the reference version from post #2. It's cleaner because you don't need to double up on functions (handler->reference) like you see above with dispatching. The only purpose for _handleAppEventF() in this case is just to run _parseXML(), which is a useless duplicate function.
I've always kept my handlers free of model-esque logic, so you see me calling a different function from that handler, _parseXML(). This is just because I want my handlers to only handle events and then hand off the work elsewhere.
Instead of dispatching the event, I agree with moccamaximum, run the method directly. Even if it's 2 lines of code to do 1 thing, I think the clarity of it is much cleaner coding. So I would recommend nuking the self-listener in the constructor above. When I have all the data I'm looking for, I'd run the methods in the class directly and If the parent needs to know, I'd dispatch when they complete.
e.g.
private function _handleFinishedF(e:Event):void
if (e.type == Event.COMPLETE)
var data:XML = XML(e.target.data);
// A or B? any way you can tell
if (data.A.length() > 0) _xmlA = data;
else if (data.B.length() > 0) _xmlB = data;
if (_xmlA && _xmlB)
// parse first (synchronous)
_parseXML();
// xml ready, dispatch to parent
dispatchEvent(new Event(IHateWaiting.MY_VAR)); -
How to handle events between two custom components?
Hi ,
i want to handle events between two custom components, example if an event is generated in one custom component ,and i want to handle it any where in the application.....can any one suggest me any tutorial or meterial in this concept...
thanksEvents don't really go sideways in ActionScript by default. They bubble upward. If you want to send an event sideways, you will probably have to coordinate with something higher up in the event hierarchy. You can send the event to a common ancestor, and then pass it down the hierarchy as a method argument.
Another option is to use a framework that supports Injection. There are a number around these days. The one I'm most familiar with is Mate, which allows you to handle events and inject data in MXML. Mate is meant to be used as an MVC framework, and you may want to look into it if your application is complex, but you can also use it to coordinate global event handling if you don't need that level of structure. -
Handeling listner and window events in another class
All if i have my one class that defines a JPanel how i put my listner events into another class.
so if i had
import javax.swing.*;
class MyFrame extends JFrame {
public MyFrame() {
setTitle("My Empty Frame");
setSize(300,200); // default size is 0,0
setLocation(10,200); // default is 0,0 (top left corner)
public static void main(String[] args) {
JFrame f = new MyFrame();
f.show();
}And then in a class WindowEvents.class i wanted to have all of the actions for any buttons
etc. How do i interface that with the main JPanel or JFrameI would make another class, for instance if you were doing an ActionListener event, you'd have a seperate class such as,
public class ButtonHandler implements ActionListener {
private YourPanelClass view;
public ButtonHandler(YourPanelClass view) {
this.view = view;
public void actionPerformed(ActionEvent e) {
//event handling code
view.updateGUI();
}Then in your main frame class, you'd want an updateGUI(); method which would perform the actions required and to add the event to your button you'd do something like this:
ImageIcon upIcon = new ImageIcon("navigationIcons/Up24.gif", "Up Button");
JButton upBtn = new JButton(upIcon);
upBtn.setToolTipText("Up");
UpdateButtonHandler ubh = new UpdateButtonHandler(this);
upBtn.setActionCommand("bob");
upBtn.addActionListener(ubh);I'm actually having a simular problem to you, where as I have 1 class for my main frame, one class for my button panel with the buttons on and 1 class for my graphics cpt which im moving about via pressing the buttons. Then another class for my actionListener event, im finding it hard to get the event to work correctly because the updateGUI(); method theoretically needs to be placed inside my button panel class, but if I do that I can't seem to update the graphics cpt properly to actually move it, unless I do it in the main frame class which then means I can't have a seperate class for my button panel. Anyone got any ideas on a solution?
Maybe you are looking for
-
Hi We have a networking issue that I hope someone may be able to help me with. We run a Windows domain - single domain, single subnet. Three domain controllers: Windows 2012 R2 Standard, Windows 2008 Standard (32bit) and Windows Server 2003 Standard.
-
May I get some insight, My PC (i know thats part of the problem but help if you can anyway) gives the APSDaemon.exe error wessage and will not allow my iTunes to open...if I delete and reinstall, will I still have my content as it may be an iCloud is
-
Some of the apps on my iPhone are much larger size-wise than claimed on their app page. Example: Wallpapers HD claims 4.4 MB, but the actual size on my phone is 4.9 GB! Pinterest & Facebook also end up being huge real estate hogs. How do I really kno
-
MAY I CHANGE HOST NAME AFTER SAP IS INSTALLED?
i have installed ecc6 in my computer.But after installation is completed i want to change my computer(system) name.If i change the computer name is there any problem occur.May i change computer name after installation also.
-
Simplest approach for creating database for small collection of data - new project design phase
Hello. I am at the design stage of a VB.NET project, which I hope will help me strengthen some skills I have learnt so far, and learn new ones. I have a couple of questions. Firstly regarding data types, is there a unified, standardised, all-converge