EVENT HEADLING IN ALV
hi experts,
when i click on any field in the basic alv list , second alv list should appear with that field description.
for example: when i click the plant field in the alv baisc list the 2nd alv list should contain the description for that plant along with the storage location details.
regards,
vijay
first of all enable the HOTSPOT property for that field in the fieldcatalog to "X'.
Now do the following in user-command
FORM user_command USING u_ucomm TYPE syucomm
us_selfield TYPE slis_selfield. "#EC CALLED
CASE u_ucomm.
WHEN '&IC1'.
*Call the second ALV here
ENDCASE.
ENDFORM.
Similar Messages
-
Trigger DATA_CHANGED event from triggered DATA_CHANGED event in second ALV
Hello,
I do have 2 ALVs (class CL_GUI_ALV_GRID) in a Splitter-Control.
Both ALVs do have registered the event DATA_CHANGED in seperate handler methods.
If there is a change in first ALV(line insertion with values), there will be inserted a new line with values in the second ALV. After handling the event at first ALV, I call CHECK_CHANGED_DATA of the second ALV and REFRESH_TABLE_DISPLAY of the second ALV. I would expect that the call of CHECK_CHANGED_DATA would trigger the event DATA_CHANGED, but it does not trigger the event DATA_CHANGED of the second ALV.
The problem is maybe that the input at the data is not made by the user(UI).
What could I do to trigger this event and check the new data at second ALV?
Yours JoergHello ,
yeah thats correct , but in your case what you can do is
g_grid1(first alv) >CHECK_CHANGED_DATA( Importing E_VALID = l_Valid )>in the implementation method of this ..update global variable g_second = 'X' in order to refresh ALV2.
g_grid1(first alv) -->Refresh_table_display( ).
if g_second = 'X'.
g_grid2-->SET_TABLE_FOR_FIRST_DISPLAY. so it will refresh the second alv contents.
endif.
regards
Prabhu -
How to Process event when select ALV mark ?
Hi.
The Screen have ALV data.
How to Process event when select ALV mark ?
Regards.
LY.EVENT
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = it_events[]
EXCEPTIONS
list_type_wrong = 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.
READ TABLE it_events WITH KEY name = slis_ev_top_of_page
INTO it_events.
IF sy-subrc = 0.
MOVE t_formname_top_of_page TO it_events-form.
APPEND it_events.
ENDIF.
ALV
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = it_fieldcat
it_events = it_events[]
i_callback_program = sy-repid
is_layout = gs_layout
i_save = g_save
is_variant = gx_variant
TABLES
t_outtab = i_data[]. -
Hi,
I want to know the Purpose of using the below Events in Classical ALV (if possible with example).
1. CALLER_EXIT
2. REPREP_SEL_MODIFY
3. top_of_coverpage
4. END_OF_COVERPAGE
5. TOP_OF_FOREIGN_PAGE
6. END_OF_FOREIGN_PAGE
7.SUBTOTAL_TEXT
Thanks in Advance,
SumiThe I_EVENTS table returns with the following possible constants:
1. Slis_ev_item_data_expand TYPE slis_formname VALUE 'ITEM_DATA_EXPAND'.
Only relevant for hierarchical-sequential lists using the layout parameter IS_LAYOUT-EXPAND_FIELDNAME of the structure IS_LAYOUT. Exit for passing item entries (ITEM table) for a header record that was expanded interactively by the user.
2. Slis_ev_reprep_sel_modify TYPE slis_formname VALUE 'REPREP_SEL_MODIFY'.
RS_SELFIELD-TABINDEX contains the header table index for which the item entries are to be put in the global item output table (T_OUTTAB_SLAVE). The Callback is only called if ALV has no items for a header that is to be expanded.
RFLG_ALL is passed with 'X' if the user shows all items. The application must ensure that entries are not repeated in the item table.
RS_SELFIELD is initial in this case.
3. Slis_ev_caller_exit_at_start TYPE slis_formname VALUE 'CALLER_EXIT'.
Is called at the beginning of the function module to make special settings. It is not usually used.
4. Slis_ev_user_command TYPE slis_formname VALUE 'USER_COMMAND'.
As this is a frequently-used Callback event, the form routine can also be passed directly in the interface by passing the user command in the IMPORTING parameter I_CALLBACK_USER_COMMAND.
5. Slis_ev_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.
Equivalent to the list processing TOP-OF-PAGE event.
6. Slis_ev_top_of_coverpage TYPE slis_formname VALUE 'TOP_OF_COVERPAGE'.
The selection information and list status are output together (if they exist) on a separate page by default
7. Slis_ev_end_of_coverpage TYPE slis_formname VALUE 'END_OF_COVERPAGE'.
Analogously to TOP_OF_COVERPAGE the user can add other information
to the information output by ALV (selection information, list status) at this event.
8. Slis_ev_foreign_top_of_page TYPE slis_formname VALUE FOREIGN_TOP_OF_PAGE'.
The Top-of-page event is always processed in ALV and is only passed to the caller via the Callback mechanism. This is still the case if the caller, e.g. by a user action, processes a branch list which was not formatted by ALV (e.g. a popup with additional information about the list record selected and displayed by ALV).
In this case, top-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event top-of-page still occurs in ALV. When ALV notices a top-of-page which was not caused by an ALV output, the form routine in FOREIGN_TOP_OF_PAGE is called.
9. Slis_ev_foreign_end_of_page TYPE slis_formname VALUE 'FOREIGN_END_OF_PAGE'.
The event end-of-page is always processed in ALV and only passed to the caller via callback. This is still the case, e.g. when the caller processes a details list which was not formatted by ALV (e.g. a popup with further information about selected list records which were displayed by ALV).
In this case, end-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event end-of-page still occurs in ALV. When ALV notices an end-of-page that was not caused by an ALV output, the form routine in FOREIGN_END_OF_PAGE is called.
10. Slis_ev_pf_status_set TYPE slis_formname VALUE 'PF_STATUS_SET'.
If a user list status is to be set, it must be done in the form routine assigned to this event. The ALV function codes, which must not be active, are in the Parameter RT_EXTAB. This table must be passed with the SET PF-STATUS command (with inactive user function codes as well, if necessary).
The STANDARD status of the function group SALV should be used as a template for a user-specific status. As this is a frequently used Callback event, its form routine can also be passed directly in the interface in the IMPORTING parameter I_CALLBACK_PF_STATUS_SET.
11. Slis_ev_list_modify TYPE slis_formname VALUE 'LIST_MODIFY'.
LIST_MODIFY USING R_TABNAME TYPE SLIS_TABNAME
R_INDEX LIKE SY-TABIX
R_INDEX_ITEM LIKE SY-TABIX
R_INDEX_SUM LIKE SY-TABIX.
12. Slis_ev_top_of_list TYPE slis_formname VALUE 'TOP_OF_LIST'.
Information output at the start of the list
13. Slis_ev_end_of_page TYPE slis_formname VALUE 'END_OF_PAGE'.
Information output at the end of a page. This is only called for printing.
14. Slis_ev_end_of_list TYPE slis_formname VALUE 'END_OF_LIST'.
Information output at the end of the list
15. Slis_ev_after_line_output TYPE slis_formname VALUE 'AFTER_LINE_OUTPUT'.
Output information after each output line. Should only be used in justified cases because it costs a lot of performance.
16. Slis_ev_before_line_output TYPE slis_formname VALUE 'BEFORE_LINE_OUTPUT'.
Output information before each output line. Should only be used in justified cases because it costs a lot of performance.
17. Slis_ev_subtotal_text TYPE slis_formname VALUE 'SUBTOTAL_TEXT'.
This event table (I_EVENTS) is now checked with the desired constants. If the desired constant is found, then the corresponding field for the FORM NAME is populated with the name of the routine containing the corresponding event. -
ABAP WebDynpro: Handling the ON_ENTER Event in editable ALVs
Sub: ABAP WebDynpro : Handling the ON_ENTER Event in editable ALVs
Hi,
I would like to know if there exists an event to handle TABout (i.e, when user navigates out of the cell with a TAB key-press) for a cell of an editable ALV.
Alternatively, any help on how to handle ON_ENTER event and how it is triggered when data is entered by user into a cell of an editable ALV, would be really appreciated.
Thanks,
AdithyaHi
I had one similar problem where user enter something into the editable cell and press enter. to handle this scenario i used WDDOBEFOREACTION method of my view to call alv interface method check_data.
if there is any change in the any table cell, it will fire an event on_data_check..which has paramater column name, row index and new and old value of the cell.
you can handle this event and write your business logic in event handler method.
hope it will help
Regards
Saurabh Garg -
WHAT ARE EVENTS IN AN ALV REPORT ?
WHAT ARE EVENTS IN AN ALV REPORT ? PLEASE EXPLAIN HOW TO MAKE AN ALV REPORT AND WHAT THE EVENTS DO ?
BEST REGARDS,
RYANEvents are driven by user interaction...Like...
DATA_CHANGED
DOUBLE_CLICK
ONF4
Here's a sample code of OO ALV using events...
*& Report ZDUMMY_ATG_2
REPORT zdummy_atg_2.
TYPES: BEGIN OF ty_scarr,
carrid TYPE scarr-carrid,
carrname TYPE scarr-carrname,
currcode TYPE scarr-currcode,
END OF ty_scarr.
DATA: t_spfli TYPE STANDARD TABLE OF spfli,
w_spfli LIKE LINE OF t_spfli,
lt_f4 TYPE lvc_t_f4 WITH HEADER LINE,
return_tab TYPE STANDARD TABLE OF ddshretval WITH HEADER LINE,
t_custom_scarr TYPE STANDARD TABLE OF ty_scarr WITH HEADER LINE,
t_stable TYPE STANDARD TABLE OF lvc_s_stbl WITH HEADER LINE.
FIELD-SYMBOLS: <fs_spfli> LIKE LINE OF t_spfli,
<fs_scarr> LIKE LINE OF t_custom_scarr.
CLASS cl_gui_object DEFINITION LOAD.
CLASS lcl_event_receiver DEFINITION DEFERRED.
INCLUDE <cl_alv_control>.
DATA: ok_code LIKE sy-ucomm,
gt_fieldcat TYPE lvc_t_fcat,
gt_sort TYPE lvc_t_sort,
event_receiver TYPE REF TO lcl_event_receiver,
gs_layout TYPE lvc_s_layo,
mycontainer TYPE scrfname VALUE 'CUSTOM_ALV',
custom_container TYPE REF TO cl_gui_custom_container,
grid1 TYPE REF TO cl_gui_alv_grid,
gs_variant TYPE disvariant,
x_save,
w_error TYPE c,
l_valid(1) TYPE c.
* CLASS LCL_EVENT_RECEIVER DEFINITION
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS: handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed,
handle_f4_help
FOR EVENT onf4 OF cl_gui_alv_grid
IMPORTING e_fieldname es_row_no er_event_data.
ENDCLASS. "LCL_EVENT_RECEIVER DEFINITION
* CLASS lcl_event_receiver IMPLEMENTATION
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_data_changed.
PERFORM data_changed USING er_data_changed.
ENDMETHOD. "HANDLE_DATA_CHANGED
METHOD handle_f4_help.
PERFORM handle_onf4 USING e_fieldname es_row_no.
er_event_data->m_event_handled = 'X'.
ENDMETHOD. "HANDLE_F4_HELP
ENDCLASS. "LCL_EVENT_RECEIVER IMPLEMENTATION
*& START-OF-SELECTION *
START-OF-SELECTION.
PERFORM cargar_customs.
PERFORM cargar_datos.
PERFORM fill_layout.
PERFORM fill_catalog.
PERFORM llamar_alv.
CALL SCREEN 0100.
*& Form CARGAR_DATOS *
FORM cargar_datos.
SELECT mandt carrid connid countryfr cityfrom
airpfrom countryto cityto airpto
fltime deptime arrtime distance
distid fltype period
INTO TABLE t_spfli
FROM spfli.
ENDFORM. " CARGAR_DATOS
*& Form CARGAR_CUSTOMS *
FORM cargar_customs.
SELECT carrid carrname currcode
INTO TABLE t_custom_scarr
FROM scarr.
ENDFORM. " CARGAR_DATOS
*& Form FILL_LAYOUT *
FORM fill_layout.
gs_layout-sel_mode = 'A'.
ENDFORM. " FILL_LAYOUT
*& Form FILL_CATALOG *
FORM fill_catalog.
DATA: gs_fieldcat TYPE lvc_s_fcat.
CLEAR gs_fieldcat.
gs_fieldcat-col_pos = 1.
gs_fieldcat-fieldname = 'CARRID'.
gs_fieldcat-reptext = 'Compañia'.
gs_fieldcat-tabname = 'T_SPFLI'.
gs_fieldcat-edit = 'X'.
gs_fieldcat-f4availabl = 'X'.
gs_fieldcat-outputlen = '8'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-col_pos = 2.
gs_fieldcat-fieldname = 'CONNID'.
gs_fieldcat-reptext = 'Conexión'.
gs_fieldcat-tabname = 'T_SPFLI'.
gs_fieldcat-edit = 'X'.
gs_fieldcat-outputlen = '8'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-col_pos = 3.
gs_fieldcat-fieldname = 'COUNTRYFR'.
gs_fieldcat-reptext = 'País'.
gs_fieldcat-tabname = 'T_SPFLI'.
gs_fieldcat-edit = 'X'.
gs_fieldcat-outputlen = '4'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-col_pos = 4.
gs_fieldcat-fieldname = 'CITYFROM'.
gs_fieldcat-reptext = 'Ciudad Salida'.
gs_fieldcat-tabname = 'T_SPFLI'.
gs_fieldcat-edit = space.
gs_fieldcat-outputlen = '20'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-col_pos = 5.
gs_fieldcat-fieldname = 'AIRPFROM'.
gs_fieldcat-reptext = 'Arp. Salida'.
gs_fieldcat-tabname = 'T_SPFLI'.
gs_fieldcat-edit = 'X'.
gs_fieldcat-outputlen = '10'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-col_pos = 6.
gs_fieldcat-fieldname = 'COUNTRYTO'.
gs_fieldcat-reptext = 'País'.
gs_fieldcat-tabname = 'T_SPFLI'.
gs_fieldcat-edit = 'X'.
gs_fieldcat-outputlen = '4'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-col_pos = 7.
gs_fieldcat-fieldname = 'CITYTO'.
gs_fieldcat-reptext = 'Ciudad Llegada'.
gs_fieldcat-tabname = 'T_SPFLI'.
gs_fieldcat-edit = space.
gs_fieldcat-outputlen = '20'.
APPEND gs_fieldcat TO gt_fieldcat.
ENDFORM. " FILL_CATALOG
*& Form LLAMAR_ALV *
FORM llamar_alv.
IF custom_container IS INITIAL.
CREATE OBJECT custom_container
EXPORTING
container_name = mycontainer
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
ENDIF.
CREATE OBJECT grid1
EXPORTING
i_parent = custom_container.
CREATE OBJECT event_receiver.
lt_f4-fieldname = 'CARRID'.
lt_f4-register = 'X' .
lt_f4-getbefore = 'X' .
lt_f4-chngeafter = 'X' .
APPEND lt_f4.
SET HANDLER event_receiver->handle_data_changed FOR grid1.
SET HANDLER event_receiver->handle_f4_help FOR grid1.
CALL METHOD grid1->register_f4_for_fields
EXPORTING
it_f4 = lt_f4[].
IF sy-batch IS INITIAL.
CALL METHOD grid1->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
ENDIF.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
is_variant = gs_variant
i_save = x_save
i_default = 'X'
is_layout = gs_layout
CHANGING
it_fieldcatalog = gt_fieldcat
it_sort = gt_sort[]
it_outtab = t_spfli[].
CALL METHOD grid1->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
ENDFORM. " LLAMAR_ALV
*& Form HANDLE_ONF4 *
FORM handle_onf4 USING p_e_fieldname
p_es_row_no STRUCTURE lvc_s_roid.
CASE p_e_fieldname.
WHEN 'CARRID'.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'CARRID'
value_org = 'S'
TABLES
value_tab = t_custom_scarr
return_tab = return_tab
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF NOT return_tab[] IS INITIAL.
READ TABLE return_tab INDEX 1.
READ TABLE t_spfli INDEX p_es_row_no-row_id
ASSIGNING <fs_spfli>.
<fs_spfli>-carrid = return_tab-fieldval.
CALL METHOD grid1->refresh_table_display
EXPORTING
is_stable = t_stable.
ENDIF.
ENDCASE.
ENDFORM. " HANDLE_ONF4
*& Module STATUS_0100 OUTPUT *
MODULE status_0100 OUTPUT.
SET PF-STATUS 'MAIN_STATUS'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT *
MODULE user_command_0100 INPUT.
ok_code = sy-ucomm.
CASE ok_code.
WHEN 'BACK' OR 'STOP' OR 'CANCEL'.
SET SCREEN 0.
LEAVE SCREEN.
WHEN 'SAVE'.
CALL METHOD grid1->check_changed_data
IMPORTING
e_valid = l_valid.
IF l_valid EQ 'X'.
PERFORM grabar_datos.
ENDIF.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form DATA_CHANGED *
FORM data_changed USING rr_data_changed TYPE REF TO
cl_alv_changed_data_protocol.
DATA: w_new,
ls_mod_cells TYPE lvc_s_modi,
ls_cells TYPE lvc_s_modi.
DATA: l_carrid TYPE spfli-carrid.
CLEAR l_carrid.
LOOP AT rr_data_changed->mt_good_cells INTO ls_mod_cells.
CASE ls_mod_cells-fieldname.
WHEN 'CARRID'.
CALL METHOD rr_data_changed->get_cell_value
EXPORTING
i_row_id = ls_mod_cells-row_id
i_fieldname = ls_mod_cells-fieldname
IMPORTING
e_value = l_carrid.
IF l_carrid IS INITIAL.
CALL METHOD rr_data_changed->add_protocol_entry
EXPORTING
i_msgid = '0K'
i_msgno = '000'
i_msgty = 'E'
i_msgv1 = 'Seleccione algún código'
i_fieldname = ls_mod_cells-fieldname
i_row_id = ls_mod_cells-row_id.
w_error = 'X'.
ELSE.
READ TABLE t_custom_scarr WITH KEY carrid = l_carrid
ASSIGNING <fs_scarr>.
IF sy-subrc NE 0.
CALL METHOD rr_data_changed->add_protocol_entry
EXPORTING
i_msgid = '0K'
i_msgno = '000'
i_msgty = 'E'
i_msgv1 = 'Código ingresado no existe'
i_fieldname = ls_mod_cells-fieldname
i_row_id = ls_mod_cells-row_id.
w_error = 'X'.
ENDIF.
ENDIF.
ENDCASE.
ENDLOOP.
ENDFORM. " DATA_CHANGED
*& Form GRABAR_DATOS *
FORM grabar_datos.
LOOP AT t_spfli ASSIGNING <fs_spfli>.
w_spfli = <fs_spfli>.
MODIFY spfli FROM w_spfli.
IF sy-subrc EQ 0.
COMMIT WORK.
ELSE.
ROLLBACK WORK.
ENDIF.
ENDLOOP.
ENDFORM. " GRABAR_DATOS
Greetings,
Blag. -
How to handle the event "GROUPLEVEL_CHANGE" in ALV?
Hi,
I have done a BLOCL ALV report. In i am sorting the first field and not displaying it. But for every change in the first field page break should happen and the particular field is to be printed at every page break at the top. I am handling the page break by passing the IT_SORT-GROUP = '*'. there fore the page breaking is happening well. now i need to have a control such that i print the first field at every page break.
Please help on this...........
I think the event GROUPLEVEL_CHANGE is to used please tell me the parameters to be passed for this subroutine
(Defenitely point will be given)Hi,
Check the below thread...
Re: Adding row after subtotal in ALV
Regards,
Maha -
To display the typ, key field,info in the top-of -page event in OO ALV
Hi all,
I need to display the heading and the other select option details in the top-of-page event in ooalv.How can the key ,typ and the info of top of event in alv grid be passed in ooalv grid display.
Regards,
ArpitaCheck the blog.
TOP_OF_PAGE in ALV Using CL_GUI_ALV_GRID
Now you have to use the method ADD_TEXT to populate the Select options details.
I hope you know the Function to get the selection details
RS_REFRESH_FROM_SELECTOPTIONS,. it will give into a table. so use that table and populate the TOP_OF_PAGE uisng the class CL_DD_DOCUMENT. -
How to trigger ENTER event in oo ALV grid
Hi,
Can anybody help me out in catching the ENTER event in the oo ALV Grid. My requirement is as follows,
I have oo ALV Grid displaying hell lot of columns, in that vendor number column is an editable field so when the user enters the vendor number the immediate next cell showing the vendor name should be populated with the corresponding name as soon as he press enter button, I have search help also for vendor field.
Please give me some sample program which i can just do the copy+paste sort of as today is the deadline for the object.
Regards,
SumanHi,
This example is working. Please try this one.
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed e_onf4 e_ucomm.
ENDCLASS. "lcl_event_receiver DEFINITION
* CLASS lcl_event_receiver IMPLEMENTATION
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_data_changed.
DATA : modi TYPE TABLE OF lvc_s_modi ,
modis TYPE lvc_s_modi,
wa LIKE LINE OF git_alv_items,
lv_matnr TYPE matnr.
modi = er_data_changed->mt_mod_cells .
LOOP AT modi INTO modis WHERE fieldname = 'MATNR'.
MOVE modis-value TO lv_matnr.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = lv_matnr
IMPORTING
output = lv_matnr
EXCEPTIONS
length_error = 1
OTHERS = 2.
READ TABLE git_alv_items INTO wa INDEX modis-row_id .
IF sy-subrc = 0.
SELECT SINGLE maktx FROM makt
INTO wa-maktx
WHERE matnr = lv_matnr
AND spras = sy-langu.
MODIFY git_alv_items FROM wa INDEX modis-row_id.
ENDIF.
ENDLOOP.
IF sy-subrc = 0.
CALL METHOD alv_grid->refresh_table_display
EXPORTING
is_stable = gs_stbl.
ENDIF.
ENDMETHOD. "handle_data_changed
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
DATA : eventreceiver TYPE REF TO lcl_event_receiver.
SET HANDLER eventreceiver->handle_data_changed FOR alv_grid.
CALL METHOD alv_grid->set_table_for_first_display
EXPORTING
i_save = 'A'
is_layout = layo_alv
i_bypassing_buffer = 'X'
i_buffer_active = ''
CHANGING
it_outtab = git_alv_items
it_fieldcatalog = fcat_alv
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
CALL METHOD alv_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter. -
Event handling in alv oops With buttons
Hi Experts
I have some doubt in ALV OOPS using Events. Could any one please tell me the procedure to how to handle events in oops ( Like interactive reports using events ).
Thank you
Satyendra.Hello Satyendra
The following sample report shows you how to handle the event HOTSPOT_CLICK and BUTTON_CLICK.
DATA: gd_okcode TYPE ui_func,
gt_fcat TYPE lvc_t_fcat,
go_docking TYPE REF TO cl_gui_docking_container,
go_grid1 TYPE REF TO cl_gui_alv_grid.
DATA: gt_knb1 TYPE STANDARD TABLE OF knb1.
PARAMETERS: p_bukrs TYPE bukrs DEFAULT '2000' OBLIGATORY.
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING
e_row_id
e_column_id
es_row_no
sender, " grid instance that raised the event
handle_button_click FOR EVENT button_click OF cl_gui_alv_grid
IMPORTING
es_col_id
es_row_no
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_hotspot_click.
* define local data
DATA:
ls_knb1 TYPE knb1,
ls_col_id TYPE lvc_s_col.
READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row_id-index.
CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
CASE e_column_id-fieldname.
WHEN 'KUNNR'.
SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.
CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
WHEN 'ERNAM'.*
SET PARAMETER ID 'USR' FIELD ls_knb1-ernam.
CALL TRANSACTION 'SU01' AND SKIP FIRST SCREEN.
WHEN OTHERS.
ENDCASE.
* Set active cell to field BUKRS otherwise the focus is still on
* field KUNNR which will always raise event HOTSPOT_CLICK
ls_col_id-fieldname = 'BUKRS'.
CALL METHOD go_grid1->set_current_cell_via_id
EXPORTING
is_row_id = e_row_id
is_column_id = ls_col_id.
ENDMETHOD. "handle_hotspot_click
METHOD handle_button_click.
* define local data
DATA:
ls_knb1 TYPE knb1.
READ TABLE gt_knb1 INTO ls_knb1 INDEX es_row_no-row_id.
CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.
CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
ENDMETHOD. "handle_button_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1
WHERE bukrs = p_bukrs
* 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 ALV grid
CREATE OBJECT go_grid1
EXPORTING
i_parent = go_docking
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.
* Set event handler
SET HANDLER:
lcl_eventhandler=>handle_hotspot_click FOR go_grid1,
lcl_eventhandler=>handle_button_click FOR go_grid1.
* Build fieldcatalog and set hotspot for field KUNNR
PERFORM build_fieldcatalog_knb1.
* Display data
CALL METHOD go_grid1->set_table_for_first_display
CHANGING
it_outtab = gt_knb1
it_fieldcatalog = gt_fcat
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.
* ok-code field = GD_OKCODE
CALL SCREEN '0100'.
END-OF-SELECTION.
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
MODULE user_command_0100 INPUT.
CASE gd_okcode.
WHEN 'BACK' OR
'END' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
FORM build_fieldcatalog_knb1 .
* define local data
DATA:
ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'KNB1'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
* I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_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.
LOOP AT gt_fcat INTO ls_fcat
WHERE ( fieldname = 'KUNNR' OR
fieldname = 'ERNAM' OR
fieldname = 'BUKRS' ).
IF ( ls_fcat-fieldname = 'BUKRS' ).
ls_fcat-style = cl_gui_alv_grid=>mc_style_button. " column appears as button
ELSE.
ls_fcat-hotspot = abap_true.
ENDIF.
MODIFY gt_fcat FROM ls_fcat.
ENDLOOP.
ENDFORM. " BUILD_FIELDCATALOG_KNB1
Regards
Uwe -
Hi All,
I am using <b>CL_GUI_ALV_GRID</b> to create an ALV grid.This screen is called from a first screen.I am also using a custom defined button in the ALV tool bar for inserting a row into the ALV.I am handling the button click in the event <b>USER_COMMAND</b> of <b>CL_GUI_ALV_GRID</b>.When the ALV screen is called for the first time and when i click on the INSERT button it is inserting a row into the ALV and is working fine.But the problem is after i insert a row in the ALV and when I go back to the first screen and call the ALV screen again and when I try to insert a row in the ALV it is inserting 2 rows.ie from 2 clicks i m getting 3 rows.I went into the debuggng mode and could see that the method <b>handle_button</b> (written locally) is called 2 times the second time,3 times the third time..Have anybody faced this problem before..or could give any suggestions on this..
regards
Sandeephi
good
i think you have to check with that particular method handle_button and its function ,
check out when the final result printing in the alv output for the second time as you mentioned why it is calling the same field data again and again,during runtime you can check that using /h at your command promt.
thanks
mrutyun^ -
Hi All,
I am using ALV OOPS for handling events.I have a scenario like in my ALV, i will change/insert/delete the records, i need to update the DB table when i press the save button.
I need to throw an error if the user enters an invalid data like (material number which is not present in Mara table) How can i handle this using Events in OOPS?
Can anyone send any sample code if you any ??
Thanks in Advance...Hi
Check the following link.
EVENTS IN ALV OOPS
hope you got your solution
Regards
Sachin -
How to add Select event in dynamic ALV
Hi,
I have created dynamic ALV and now i want to checked the selected row value.
If in the selected row contain 'A' value then i have to disable the Button given on the screen.
If in the selected row contain B' value then i have to enable the Button given on the screen.
How to add the event once I select the row.
I have done like this . but it is not
lw_api_2->do_dynamic_navigation(
source_window_name = 'ZWDCHHR_EX_TASK_DELE'
source_vusage_name = 'ZWDVHHR_EX_TASK_DELE_USAGE_1'
source_plug_name = 'TO_ALV'
target_component_name = 'SALV_WD_TABLE'
target_component_usage = 'ALV_USAGE1'
target_view_name = 'TABLE'
target_plug_name = 'DEFAULT'
target_embedding_position = 'ZWDVHHR_EX_TASK_DELE/VIEW_DELEG_MY_TASKS' ).
register event handler
lw_cmp_usage_2->add_event_handler(
listener = lw_api_2
handler_name = 'ONSELECT_TAB1'
controller_name = 'INTERFACECONTROLLER'
event_name = 'ON_SELECT' ).
Thanks and regards
Amita GandhiHi Amita,
You can try fetch the number of the row which was leadselected through R_PARAM->INDEX. (This would be just a normal integer variable. You can try check this out in debugging mode. ) Now you can just read the data of this row from the context node by saying as GET_ATTRIBUTE up on the nodes reference with the index as R_PARAM->INDEX.
Regards,
Uday -
Enter Key Event in Editable ALV Grid
Hi all,
I am trying to create and editable ALV grid using the REUSE ALV FM.
On the grid after changing a value, if I press enter key the pai is not triggered. I have tried the various example programs (BCALV*) but could not find anything relevant.
Basically I need similar functionality to normal module pool programming as in validations on screen done when enter key is pressed after screen entry.
Is it possible to capture the Enter keypress on the ALV grid?Hello Preet
I can only tell you how I would solve this using the ALV grid control (CL_GUI_ALV_GRID) because I have abandoned using ALV function modules.
The problem with running through PAI is whether the focus (i.e. the cursor) is still on the control or already on the (surrounding) main program. If the control has the focus, you do not run through PAI.
I would add a "Refresh" button to the toolbar of the ALV list. Normally, this button is already there or you only have to make it visible.
When the user pushes this button you catch the corresponding user-command and call the CHECK_DATA_CHANGED method to see if values have been changed on the editable grid. If so, the previous method will fire event DATA_CHANGED.
Now, in the event handler method (e.g. HANDLE_DATA_CHANGED) you receive as input a data change object (CL_ALV_CHANGED_DATA_PROTOCOL). This object contains all changed values. These values you will need to make your checks.
I assume that the logic will be similar using ALV function modules.
Regards
Uwe -
Hello,
I have a problem in getting the event when adding a new row in ALV using OOP.
Here's my requirement:
I have an initial output, and I have a custom button, which when pressed, will make the fields editable. There is also a new set of toolbar shown. In the toolbar, is a button which the user can add a row, or delete a row. Now my problem is I can't handle the event in adding a new row, since I still need to do some validation on the input of the user.
Anyone who can give an insight on how to do this?
Any response is highly appreciated.
Thanks,
LouisseHello Preet
I can only tell you how I would solve this using the ALV grid control (CL_GUI_ALV_GRID) because I have abandoned using ALV function modules.
The problem with running through PAI is whether the focus (i.e. the cursor) is still on the control or already on the (surrounding) main program. If the control has the focus, you do not run through PAI.
I would add a "Refresh" button to the toolbar of the ALV list. Normally, this button is already there or you only have to make it visible.
When the user pushes this button you catch the corresponding user-command and call the CHECK_DATA_CHANGED method to see if values have been changed on the editable grid. If so, the previous method will fire event DATA_CHANGED.
Now, in the event handler method (e.g. HANDLE_DATA_CHANGED) you receive as input a data change object (CL_ALV_CHANGED_DATA_PROTOCOL). This object contains all changed values. These values you will need to make your checks.
I assume that the logic will be similar using ALV function modules.
Regards
Uwe
Maybe you are looking for
-
Mac Pro kernel panic, RAM does not seem to be problem
My Mac Pro (late 2006) now has kernel panics at startup. Problem first happened while computer was in sleep mode, a second kernel panic happened about 10-15 minutes after reboot the first time. Now it happens at startup every time. Zapped PRAM multip
-
Yosemite Filevault during installation process
Hello When I installed Yosemite I was asked to turn on the FileVault and encrypt my data, which I did. I never got a recovery key as I should have been (I would have guessed so reading about FileVault). Should I turn off the FileVault ? Thanks philoo
-
Veeam back to tape after Backup Exec completes
Yes, it's possible to use 2 mentioned solutions together. Hope, you're using Veeam latest version as it has enhanced support for tape devices. If not, have a look: http://www.veeam.com/kb1816 Tapes don't have to be directly connected to Veeam Backup
-
Get number of rows in ResultSet object
Can anybody guide me on how to get the total number of rows in a result set object without iterating through all rows? Thanks.
-
Why DBA_OBJECTS.TIMESTAMP is defined as VARCHAR2(19)
Oracle recomends to use TIME STAMP datatypes for timestamp information but itself it is using VARCHAR2(19) for DBA_OBJECTS.TIMESTAMP can any body explain Why it is so? Oracle version is 10.2.0 thanks in advance.