Handling Events in ALV Grid Display
Hi,
I need ur urgent help on how to trigger and handle the events associated with the class CL_GUI_ALV_GRID_DISPLAY .Events like
ONF4
ONF1
DATA_CHANGED
USER_COMMAND
TOOLBAR
HOTSPOT_CLICK
Please help me in this matter and post some valid codes depicting these events.Ur help will be really appreciated throught points.
Thnkx in advance.
Hi,
Please refer program "BCALV_TEST_GRID_EVENTS"
Best regards,
Prashant
*& Report BCALV_TEST_GRID_EVENTS *
report bcalv_test_grid_events.
types: g_ty_t_carrid type standard table of alv_tab,
g_ty_t_connid type standard table of alv_chck,
g_ty_t_curr type standard table of alv_cur,
g_ty_s_sflight type alv_t_t2,
g_ty_s_carrid type alv_tab,
g_ty_s_connid type alv_chck,
g_ty_s_curr type alv_cur.
constants: con_sflight type lvc_fname value 'ALV_T_T2',
con_scarr type lvc_fname value 'ALV_TAB',
con_spfli type lvc_fname value 'ALV_CHCK'.
* DATA *
class lcl_events_d0100 definition deferred.
types: begin of g_ty_s_plane,
carrid type g_ty_s_sflight-carrid,
connid type g_ty_s_sflight-connid,
planetype type g_ty_s_sflight-planetype,
seatsmax type g_ty_s_sflight-seatsmax,
end of g_ty_s_plane,
g_ty_t_plane type sorted table of g_ty_s_plane
with unique key carrid connid,
begin of g_ty_s_event,
user_command type char1,
before_user_command type char1,
after_user_command type char1,
double_click type char1,
hotspot_click type char1,
button_click type char1,
onf1 type char1,
onf4 type char1,
menu_button type char1,
toolbar type char1,
context_menu_request type char1,
ondrag type char1,
ondrop type char1,
ondropcomplete type char1,
ondropgetflavor type char1,
subtotal_text type char1,
data_changed type char1,
data_changed_finished type char1,
after_refresh type char1,
delayed_callback type char1,
delayed_changed_sel_callback type char1,
top_of_page type char1,
end_of_list type char1,
print_top_of_page type char1,
print_end_of_page type char1,
print_top_of_list type char1,
print_end_of_list type char1,
end of g_ty_s_event,
begin of g_ty_s_onf4,
register type char1,
get_before type char1,
change_after type char1,
internal_format type char1,
end of g_ty_s_onf4,
begin of g_ty_s_test,
select_amount type i,
no_info_popup type char1,
info_popup_once type char1,
events_info_popup type lvc_fname occurs 0,
application_events type char1,
event type g_ty_s_event,
onf4 type g_ty_s_onf4,
button_fields type lvc_fname occurs 0,
hotspot_fields type lvc_fname occurs 0,
onf1_fields type lvc_fname occurs 0,
onf4_fields type lvc_fname occurs 0,
bypassing_buffer type char1,
buffer_active type char1,
end of g_ty_s_test,
begin of g_ty_s_outtab.
include type g_ty_s_sflight.
types: box type char1,
lights type char1,
end of g_ty_s_outtab,
g_ty_t_outtab type table of g_ty_s_outtab.
constants: con_exit type sy-ucomm value 'EXIT',
con_canc type sy-ucomm value 'CANC',
con_back type sy-ucomm value 'BACK',
con_true type char1 value 'X'.
data: g_okcode type sy-ucomm.
data: gs_test type g_ty_s_test.
data: gt_outtab type g_ty_t_outtab with header line,
gr_container_d0100 type ref to cl_gui_custom_container,
gr_grid_d0100 type ref to cl_gui_alv_grid,
gr_events_d0100 type ref to lcl_events_d0100,
gr_grid_dragdrop type ref to cl_dragdrop.
data: g_static_menu type ref to cl_ctmenu,
g_static_menu_default type ref to cl_ctmenu.
data: g_field type lvc_s_fcat-fieldname.
* CLASS lcl_dragdrop_obj_d0100 DEFINITION
class lcl_dragdrop_obj_d0100 definition.
public section.
data: line type g_ty_s_outtab,
index type i.
endclass. "lcl_dragdrop_obj_d0100 DEFINITION
* CLASS lcl_events_d0100 DEFINITION
class lcl_events_d0100 definition.
public section.
methods:
user_command for event user_command
of cl_gui_alv_grid
importing e_ucomm sender,
before_user_command for event before_user_command
of cl_gui_alv_grid
importing e_ucomm,
after_user_command for event after_user_command
of cl_gui_alv_grid
importing e_ucomm
e_not_processed
e_saved,
double_click for event double_click
of cl_gui_alv_grid
importing e_row
e_column
es_row_no,
hotspot_click for event hotspot_click
of cl_gui_alv_grid
importing e_row_id
e_column_id
es_row_no,
menu_button for event menu_button
of cl_gui_alv_grid
importing e_object
e_ucomm,
toolbar for event toolbar
of cl_gui_alv_grid
importing e_object
e_interactive,
context_menu_request for event context_menu_request
of cl_gui_alv_grid
importing e_object,
top_of_page for event top_of_page
of cl_gui_alv_grid
importing e_dyndoc_id,
end_of_list for event end_of_list
of cl_gui_alv_grid
importing e_dyndoc_id,
print_top_of_page for event print_top_of_page
of cl_gui_alv_grid,
print_end_of_page for event print_end_of_page
of cl_gui_alv_grid,
print_top_of_list for event print_top_of_list
of cl_gui_alv_grid,
print_end_of_list for event print_end_of_list
of cl_gui_alv_grid,
after_refresh for event after_refresh
of cl_gui_alv_grid,
delayed_callback for event delayed_callback
of cl_gui_alv_grid,
delayed_changed_sel_callback
for event delayed_changed_sel_callback
of cl_gui_alv_grid,
subtotal_text for event subtotal_text
of cl_gui_alv_grid
importing es_subtottxt_info
ep_subtot_line
e_event_data,
ondrag for event ondrag
of cl_gui_alv_grid
importing e_row
e_column
es_row_no
e_dragdropobj,
ondrop for event ondrop
of cl_gui_alv_grid
importing e_row
e_column
es_row_no
e_dragdropobj,
ondropcomplete for event ondropcomplete
of cl_gui_alv_grid
importing e_row
e_column
es_row_no
e_dragdropobj,
ondropgetflavor for event ondropgetflavor
of cl_gui_alv_grid
importing e_row
e_column
es_row_no
e_dragdropobj
e_flavors,
data_changed for event data_changed
of cl_gui_alv_grid
importing er_data_changed
e_onf4
e_onf4_before
e_onf4_after,
data_changed_finished
for event data_changed_finished
of cl_gui_alv_grid,
button_click for event button_click
of cl_gui_alv_grid
importing es_col_id
es_row_no,
onf1 for event onf1
of cl_gui_alv_grid
importing e_fieldname
es_row_no
er_event_data,
onf4 for event onf4
of cl_gui_alv_grid
importing e_fieldname
e_fieldvalue
es_row_no
er_event_data
et_bad_cells
e_display.
endclass. "lcl_events_d0100 DEFINITION
* CLASS lcl_events_d0100 IMPLEMENTATION
class lcl_events_d0100 implementation.
* METHOD user_command *
method user_command.
perform d0100_event_ucomm using e_ucomm.
endmethod. "user_command
* METHOD before_user_command *
method before_user_command.
perform d0100_event_before_ucomm using e_ucomm.
endmethod. "before_user_command
* METHOD after_user_command *
method after_user_command.
perform d0100_event_after_ucomm using e_ucomm
e_not_processed
e_saved.
endmethod. "after_user_command
* METHOD double_click *
method double_click.
perform d0100_event_double_click using e_row
e_column.
endmethod. "double_click
* METHOD hotspot_click *
method hotspot_click.
* perform d0100_event_hotspot_click using e_row_id
* e_column_id.
gr_grid_d0100->refresh_table_display( ).
endmethod. "hotspot_click
* METHOD menu_button *
method menu_button.
perform d0100_event_menu_button using e_object
e_ucomm.
endmethod. "menu_button
* METHOD toolbar *
method toolbar.
perform d0100_event_toolbar using e_object
e_interactive.
endmethod. "toolbar
* METHOD context_menu_request *
method context_menu_request.
perform d0100_event_context_menu_reqst using e_object.
endmethod. "context_menu_request
* METHOD top_of_page *
method top_of_page.
perform d0100_event_top_of_page using e_dyndoc_id.
endmethod. "top_of_page
* METHOD end_of_list *
method end_of_list.
perform d0100_event_end_of_list using e_dyndoc_id.
endmethod. "end_of_list
* METHOD print_top_of_page *
method print_top_of_page.
perform d0100_event_print_top_of_page.
endmethod. "print_top_of_page
* METHOD print_end_of_page *
method print_end_of_page.
perform d0100_event_print_end_of_page.
endmethod. "print_end_of_page
* METHOD print_top_of_list *
method print_top_of_list.
perform d0100_event_print_top_of_list.
endmethod. "print_top_of_list
* METHOD print_end_of_list *
method print_end_of_list.
perform d0100_event_print_end_of_list.
endmethod. "print_end_of_list
* METHOD after_refresh *
method after_refresh.
perform d0100_event_after_refresh.
endmethod. "after_refresh
* METHOD delayed_callback *
method delayed_callback.
perform d0100_event_delayed_callback.
endmethod. "delayed_callback
* METHOD delayed_changed_sel_callback *
method delayed_changed_sel_callback.
perform d0100_event_changed_sel_callba.
endmethod. "delayed_changed_sel_callback
* METHOD subtotal_text *
method subtotal_text.
perform d0100_event_subtotal_text using es_subtottxt_info
ep_subtot_line
e_event_data.
endmethod. "subtotal_text
* METHOD ondrag *
method ondrag.
perform d0100_event_ondrag using e_row
e_column
e_dragdropobj.
endmethod. "ondrag
* METHOD ondrop *
method ondrop.
perform d0100_event_ondrop using e_row
e_column
e_dragdropobj.
endmethod. "ondrop
* METHOD ondropcomplete *
method ondropcomplete.
perform d0100_event_ondropcomplete using e_row
e_column
e_dragdropobj.
endmethod. "ondropcomplete
* METHOD ondropgetflavor *
method ondropgetflavor.
perform d0100_event_ondropgetflavor.
endmethod. "ondropgetflavor
* METHOD data_changed *
method data_changed.
perform d0100_event_data_changed using er_data_changed
e_onf4
e_onf4_before
e_onf4_after.
endmethod. "data_changed
* METHOD data_changed_finished *
method data_changed_finished.
perform d0100_event_data_changed_finis.
endmethod. "data_changed_finished
* METHOD button_click *
method button_click.
perform d0100_event_button_click using es_col_id
es_row_no.
endmethod. "button_click
* METHOD onf1 *
method onf1.
perform d0100_event_onf1 using e_fieldname
es_row_no
er_event_data.
endmethod. "onf1
* METHOD onf4 *
method onf4.
perform d0100_event_onf4 using e_fieldname
e_fieldvalue
es_row_no
er_event_data
et_bad_cells
e_display.
endmethod. "onf4
endclass. "lcl_events_d0100 IMPLEMENTATION
* SELECTION-SCREEN *
selection-screen begin of block gen with frame.
selection-screen begin of line.
parameters:
p_ext radiobutton group db.
selection-screen comment (29) for field p_ext.
selection-screen comment (29) for field p_d_file.
parameters:
p_d_file type char255.
selection-screen end of line.
selection-screen begin of line.
parameters:
p_db radiobutton group db default 'X'.
selection-screen comment (29) for field p_db.
selection-screen comment (29) for field p_amount.
parameters:
p_amount type i default 30.
selection-screen end of line.
selection-screen end of block gen.
selection-screen begin of block inf with frame.
parameters:
p_inf01 as checkbox default con_true,
p_inf02 as checkbox.
selection-screen end of block inf.
selection-screen begin of block app with frame.
parameters:
p_appevt as checkbox.
selection-screen end of block app.
selection-screen begin of block evt with frame.
parameters:
p_evt01 as checkbox, "USER_COMMAND
p_evt02 as checkbox, "BEFORE_USER_COMMAND
p_evt03 as checkbox. "AFTER_USER_COMMAND
selection-screen skip.
parameters:
p_evt04 as checkbox, "DOUBLE_CLICK
p_evt05 as checkbox. "HOTSPOT_CLICK
select-options:
p_hotspt for g_field no intervals default 'CARRID'.
parameters:
p_evt06 as checkbox. "BUTTON_CLICK
select-options:
p_button for g_field no intervals default 'CARRID'.
selection-screen skip.
parameters:
p_evt07 as checkbox. "ONF1
selection-screen begin of block of4 with frame.
parameters:
p_evt08 as checkbox. "ONF4
select-options:
p_onf4 for g_field no intervals default 'CARRID'.
selection-screen begin of line.
selection-screen comment 5(30) text-c01 for field p_f401.
parameters:
p_f401 as checkbox default con_true. "REGISTER
selection-screen end of line.
selection-screen begin of line.
selection-screen comment 5(30) text-c02 for field p_f402.
parameters:
p_f402 as checkbox. "GET_BEFORE
selection-screen end of line.
selection-screen begin of line.
selection-screen comment 5(30) text-c03 for field p_f403.
parameters:
p_f403 as checkbox. "CHANGE_AFTER
selection-screen end of line.
selection-screen begin of line.
selection-screen comment 5(30) text-c04 for field p_f404.
parameters:
p_f404 as checkbox. "INTERNAL_FORMAT
selection-screen end of line.
selection-screen end of block of4.
selection-screen skip.
parameters:
p_evt09 as checkbox, "MENU_BUTTON
p_evt10 as checkbox, "TOOLBAR
p_evt11 as checkbox. "CONTEXT_MENU_REQUEST
selection-screen skip.
parameters:
p_evt12 as checkbox, "ONDRAG
p_evt13 as checkbox, "ONDROP
p_evt14 as checkbox, "ONDROPCOMPLETE
p_evt15 as checkbox. "ONDROPGETFLAVOR
selection-screen skip.
parameters:
p_evt16 as checkbox. "SUBTOTAL_TEXT
selection-screen skip.
parameters:
p_evt17 as checkbox, "DATA_CHANGED
p_evt18 as checkbox, "DATA_CHANGED_FINISHED
p_evt19 as checkbox. "AFTER_REFRESH
selection-screen skip.
parameters:
p_evt20 as checkbox, "DELAYED_CALLBACK
p_evt21 as checkbox. "DELAYED_CHANGED_SEL_CALLBACK
selection-screen skip.
parameters:
p_evt22 as checkbox, "TOP_OF_PAGE
p_evt23 as checkbox, "END_OF_LIST
p_evt24 as checkbox, "PRINT_TOP_OF_PAGE
p_evt25 as checkbox, "PRINT_END_OF_PAGE
p_evt26 as checkbox, "PRINT_TOP_OF_LIST
p_evt27 as checkbox. "PRINT_END_OF_LIST
selection-screen end of block evt.
* AT SELECTION-SCREEN ON VALUE-REQUEST *
at selection-screen on value-request for p_hotspt-low.
perform d0100_f4_fcode changing p_hotspt-low.
at selection-screen on value-request for p_button-low.
perform d0100_f4_fcode changing p_button-low.
at selection-screen on value-request for p_onf4-low.
perform d0100_f4_fcode changing p_onf4-low.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_d_file.
PERFORM f4_file.
* START-OF-SELECTION *
start-of-selection.
gs_test-select_amount = p_amount.
gs_test-no_info_popup = p_inf01.
gs_test-info_popup_once = p_inf02.
gs_test-application_events = p_appevt.
gs_test-event-user_command = p_evt01.
gs_test-event-before_user_command = p_evt02.
gs_test-event-after_user_command = p_evt03.
gs_test-event-double_click = p_evt04.
gs_test-event-hotspot_click = p_evt05.
gs_test-event-button_click = p_evt06.
gs_test-event-onf1 = p_evt07.
gs_test-event-onf4 = p_evt08.
gs_test-event-menu_button = p_evt09.
gs_test-event-toolbar = p_evt10.
gs_test-event-context_menu_request = p_evt11.
gs_test-event-ondrag = p_evt12.
gs_test-event-ondrop = p_evt13.
gs_test-event-ondropcomplete = p_evt14.
gs_test-event-ondropgetflavor = p_evt15.
gs_test-event-subtotal_text = p_evt16.
gs_test-event-data_changed = p_evt17.
gs_test-event-data_changed_finished = p_evt18.
gs_test-event-after_refresh = p_evt19.
gs_test-event-delayed_callback = p_evt20.
gs_test-event-delayed_changed_sel_callback = p_evt21.
gs_test-event-top_of_page = p_evt22.
gs_test-event-end_of_list = p_evt23.
gs_test-event-print_top_of_page = p_evt24.
gs_test-event-print_end_of_page = p_evt25.
gs_test-event-print_top_of_list = p_evt26.
gs_test-event-print_end_of_list = p_evt27.
gs_test-onf4-register = p_f401.
gs_test-onf4-get_before = p_f402.
gs_test-onf4-change_after = p_f403.
gs_test-onf4-internal_format = p_f404.
if p_evt05 ne space.
loop at p_hotspt.
if not p_hotspt-low is initial.
append p_hotspt-low to gs_test-hotspot_fields.
endif.
endloop.
endif.
if p_evt06 ne space.
loop at p_button.
if not p_button-low is initial.
append p_button-low to gs_test-button_fields.
endif.
endloop.
endif.
if p_evt08 ne space.
loop at p_onf4.
if not p_onf4-low is initial.
append p_onf4-low to gs_test-onf4_fields.
endif.
endloop.
endif.
gs_test-bypassing_buffer = space.
gs_test-buffer_active = space.
* END-OF-SELECTION *
end-of-selection.
call screen 100.
*& Module d0100_set_status OUTPUT
* text
module d0100_set_status output.
perform d0100_set_status.
endmodule. " d0100_set_status OUTPUT
*& Module d0100_prepare_container OUTPUT
* text
module d0100_prepare_container output.
perform d0100_prepare_container.
endmodule. " d0100_prepare_container OUTPUT
*& Module d0100_exit INPUT
* text
module d0100_exit input.
perform d0100_exit.
endmodule. " d0100_exit INPUT
*& Module d0100_fcode INPUT
* text
module d0100_fcode input.
perform d0100_fcode.
endmodule. " d0100_fcode INPUT
*& Form d0100_set_status
* text
form d0100_set_status .
types: begin of l_ty_s_excl,
func type syucomm,
end of l_ty_s_excl,
l_ty_t_excl type standard table of l_ty_s_excl.
data: lt_excl type l_ty_t_excl.
set pf-status 'D0100' excluding lt_excl.
set titlebar 'D0100'.
endform. " d0100_set_status
*& Form d0100_prepare_container
* text
form d0100_prepare_container .
data: lt_fcat type lvc_t_fcat,
ls_layo type lvc_s_layo,
ls_vari type disvariant,
ls_prnt type lvc_s_prnt,
l_consistency_check type char1.
if gr_container_d0100 is initial.
if cl_gui_alv_grid=>offline( ) is initial.
create object gr_container_d0100
exporting container_name = 'D0100_CONTAINER'.
endif.
create object gr_grid_d0100
exporting i_parent = gr_container_d0100
i_appl_events = gs_test-application_events.
DATA: l_filename TYPE string,
l_struct TYPE string.
CASE con_true.
WHEN p_db.
perform d0100_get_outtab.
WHEN p_ext.
l_struct = 'g_ty_t_outtab'.
l_filename = p_d_file.
CALL METHOD cl_salv_test_data=>select_data
EXPORTING
structname = l_struct
SOURCE = 2
filename = l_filename
* AMOUNT = 30
CHANGING
data = gt_outtab[].
ENDCASE.
perform d0100_set_grid_vari changing ls_vari.
perform d0100_set_grid_layo changing ls_layo.
perform d0100_set_grid_fcat changing lt_fcat.
perform d0100_set_grid_onf4 changing lt_fcat.
perform d0100_set_grid_buttons changing lt_fcat.
perform d0100_set_grid_hotspot changing lt_fcat.
perform d0100_set_grid_dragdrop changing ls_layo.
perform d0100_set_grid_edit changing ls_layo.
perform d0100_set_grid_events.
ls_prnt-grpchgedit = con_true.
call method gr_grid_d0100->set_table_for_first_display
exporting
i_buffer_active = gs_test-buffer_active
i_bypassing_buffer = gs_test-bypassing_buffer
i_consistency_check = l_consistency_check
is_variant = ls_vari
i_save = 'A'
i_default = con_true
is_layout = ls_layo
is_print = ls_prnt
changing
it_outtab = gt_outtab[]
it_fieldcatalog = lt_fcat.
endif.
endform. " d0100_prepare_container
*& Form d0100_exit
* text
form d0100_exit .
data: l_okcode like sy-ucomm.
l_okcode = g_okcode.
clear g_okcode.
case l_okcode.
when con_exit or con_back or con_canc.
call method gr_grid_d0100->free.
call method gr_container_d0100->free.
call method cl_gui_cfw=>flush.
clear gr_container_d0100.
clear gr_grid_d0100.
clear gr_events_d0100.
set screen 0.
leave screen.
endcase.
endform. " d0100_exit
*& Form d0100_fcode
* text
form d0100_fcode .
data: l_okcode like sy-ucomm.
l_okcode = g_okcode.
clear g_okcode.
call method cl_gui_cfw=>dispatch.
case l_okcode.
when con_exit or con_back or con_canc.
g_okcode = l_okcode.
perform d0100_exit.
when others.
endcase.
endform. " d0100_fcode
*& Form d0100_set_grid_vari
* text
form d0100_set_grid_vari changing cs_vari type disvariant.
cs_vari-report = sy-repid.
cs_vari-handle = space.
cs_vari-log_group = space.
cs_vari-username = space.
cs_vari-variant = space.
cs_vari-text = space.
cs_vari-dependvars = space.
endform. " d0100_set_grid_vari
*& Form d0100_set_grid_layo
* text
form d0100_set_grid_layo changing cs_layo type lvc_s_layo.
*... ALV-Control: Allgemeine Anzeigeoptionen
cs_layo-stylefname = space.
cs_layo-cwidth_opt = con_true.
cs_layo-zebra = space.
cs_layo-smalltitle = space.
cs_layo-graphics = space.
cs_layo-frontend = space.
cs_layo-template = space.
*... ALV-Control: Gridcustomizing
cs_layo-no_colexpd = space.
cs_layo-no_hgridln = space.
cs_layo-no_vgridln = space.
cs_layo-no_rowmark = space.
cs_layo-no_headers = space.
cs_layo-no_merging = space.
cs_layo-grid_title = space.
cs_layo-no_toolbar = space.
cs_layo-sel_mode = 'D'.
cs_layo-box_fname = space.
cs_layo-sgl_clk_hd = space.
*... ALV-Control: Summenoptionen
cs_layo-totals_bef = space.
cs_layo-no_totline = space.
cs_layo-numc_total = space.
cs_layo-no_utsplit = space.
*... ALV-Control: Exceptions
cs_layo-excp_fname = 'LIGHTS'.
cs_layo-excp_rolln = space.
cs_layo-excp_conds = space.
cs_layo-excp_led = space.
*... ALV-Control: Steuerung Interaktion
cs_layo-detailinit = space.
cs_layo-detailtitl = space.
cs_layo-keyhot = space.
cs_layo-no_keyfix = space.
cs_layo-no_author = space.
clear cs_layo-s_dragdrop.
*... ALV-Control: Farben
cs_layo-info_fname = space.
cs_layo-ctab_fname = space.
*... ALV-Control: Eingabefähigkeit
cs_layo-edit = space.
cs_layo-edit_mode = space.
cs_layo-no_rowins = space.
cs_layo-no_rowmove = space.
*... ALV-Control: Web-Optionen
cs_layo-weblook = space.
cs_layo-webstyle = space.
cs_layo-webrows = space.
cs_layo-webxwidth = space.
cs_layo-webxheight = space.
endform. " d0100_set_grid_layo
*& Form d0100_set_grid_fcat
* text
form d0100_set_grid_fcat changing ct_fcat type lvc_t_fcat.
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_buffer_active = gs_test-buffer_active
i_structure_name = con_sflight
i_client_never_display = con_true
i_bypassing_buffer = gs_test-bypassing_buffer
changing
ct_fieldcat = ct_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.
endform. " d0100_set_grid_fcat
*& Form d0100_set_grid_onf4
* text
form d0100_set_grid_onf4 changing ct_fcat type lvc_t_fcat.
field-symbols: <ls_fcat> type lvc_s_fcat.
data: l_field type lvc_fname,
lt_f4 type lvc_t_f4,
ls_f4 type lvc_s_f4.
if gs_test-event-onf4 eq con_true.
loop at gs_test-onf4_fields into l_field.
read table ct_fcat assigning <ls_fcat>
with key fieldname = l_field.
if sy-subrc eq 0.
<ls_fcat>-f4availabl = con_true.
endif.
ls_f4-fieldname = l_field.
ls_f4-register = gs_test-onf4-register.
ls_f4-getbefore = gs_test-onf4-get_before.
ls_f4-chngeafter = gs_test-onf4-change_after.
ls_f4-internal = gs_test-onf4-internal_format.
insert ls_f4 into table lt_f4.
endloop.
endif.
check not lt_f4 is initial.
call method gr_grid_d0100->register_f4_for_fields
exporting
it_f4 = lt_f4.
endform. " d0100_set_grid_onf4
*& Form d0100_set_grid_buttons
* text
form d0100_set_grid_buttons changing ct_fcat type lvc_t_fcat.
field-symbols: <ls_fcat> type lvc_s_fcat.
data: l_field type lvc_fname.
loop at gs_test-button_fields into l_field.
*... Spaltenebene
* In Feldkatalog wird Feld STYLE für Spalte auf
* cl_gui_alv_grid=>mc_style_button gesetzt
read table ct_fcat assigning <ls_fcat>
with key fieldname = l_field.
if sy-subrc eq 0.
<ls_fcat>-style = cl_gui_alv_grid=>mc_style_button.
endif.
endloop.
endform. " d0100_set_grid_buttons
*& Form d0100_set_grid_hotspot
* text
form d0100_set_grid_hotspot changing ct_fcat type lvc_t_fcat.
field-symbols: <ls_fcat> type lvc_s_fcat.
data: l_field type lvc_fname.
loop at gs_test-hotspot_fields into l_field.
*... Spaltenebene
* In Feldkatalog wird Feld STYLE für Spalte auf
* cl_gui_alv_grid=>mc_style_hotspot gesetzt
read table ct_fcat assigning <ls_fcat>
with key fieldname = l_field.
if sy-subrc eq 0.
<ls_fcat>-style = cl_gui_alv_grid=>mc_style_hotspot.
endif.
endloop.
endform. " d0100_set_grid_hotspot
*& Form d0100_set_grid_edit
* text
form d0100_set_grid_edit changing cs_layo type lvc_s_layo.
if gs_test-event-data_changed eq con_true or
gs_test-event-data_changed_finished eq con_true or
gs_test-event-after_refresh eq con_true.
cs_layo-edit = con_true.
call method gr_grid_d0100->register_edit_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
endif.
endform. " d0100_set_grid_edit
*& Form d0100_set_grid_dragdrop
* text
form d0100_set_grid_dragdrop changing cs_layo type lvc_s_layo.
data: l_effect type i,
l_handle_grid type i,
ls_dragdrop type lvc_s_dd01.
*... setzen für Zeilen
create object gr_grid_dragdrop.
l_effect = cl_dragdrop=>move + cl_dragdrop=>copy.
call method gr_grid_dragdrop->add
exporting
flavor = 'Line' "#EC NOTEXT
dragsrc = 'X'
droptarget = 'X'
effect = l_effect.
call method gr_grid_dragdrop->get_handle
importing
handle = l_handle_grid.
ls_dragdrop-cntr_ddid = space.
ls_dragdrop-grid_ddid = space.
ls_dragdrop-col_ddid = space.
ls_dragdrop-row_ddid = l_handle_grid.
ls_dragdrop-fieldname = space.
cs_layo-s_dragdrop = ls_dragdrop.
endform. " d0100_set_grid_dragdrop
*& Form d0100_set_grid_events
* text
form d0100_set_grid_events .
create object gr_events_d0100.
if gs_test-event-user_command eq con_true.
set handler gr_events_d0100->user_command
for gr_grid_d0100.
endif.
if gs_test-event-before_user_command eq con_true.
set handler gr_events_d0100->before_user_command
for gr_grid_d0100.
endif.
if gs_test-event-after_user_command eq con_true.
set handler gr_events_d0100->after_user_command
for gr_grid_d0100.
endif.
if gs_test-event-double_click eq con_true.
set handler gr_events_d0100->double_click
for gr_grid_d0100.
endif.
if gs_test-event-hotspot_click eq con_true.
set handler gr_events_d0100->hotspot_click
for gr_grid_d0100.
endif.
if gs_test-event-button_click eq con_true.
set handler gr_events_d0100->button_click
for gr_grid_d0100.
endif.
if gs_test-event-onf1 eq con_true.
set handler gr_events_d0100->onf1
for gr_grid_d0100.
endif.
if gs_test-event-onf4 eq con_true.
set handler gr_events_d0100->onf4
for gr_grid_d0100.
endif.
if gs_test-event-menu_button eq con_true.
set handler gr_events_d0100->menu_button
for gr_grid_d0100.
endif.
if gs_test-event-toolbar eq con_true.
set handler gr_events_d0100->toolbar
for gr_grid_d0100.
endif.
if gs_test-event-context_menu_request eq con_true.
set handler gr_events_d0100->context_menu_request
for gr_grid_d0100.
endif.
if gs_test-event-ondrag eq con_true.
set handler gr_events_d0100->ondrag
for gr_grid_d0100.
endif.
if gs_test-event-ondrop eq con_true.
set handler gr_events_d0100->ondrop
for gr_grid_d0100.
endif.
if gs_test-event-ondropcomplete eq con_true.
set handler gr_events_d0100->ondropcomplete
for gr_grid_d0100.
endif.
if gs_test-event-ondropgetflavor eq con_true.
set handler gr_events_d0100->ondropgetflavor
for gr_grid_d0100.
endif.
if gs_test-event-subtotal_text eq con_true.
set handler gr_events_d0100->subtotal_text
for gr_grid_d0100.
endif.
if gs_test-event-data_changed eq con_true.
set handler gr_events_d0100->data_changed
for gr_grid_d0100.
endif.
if gs_test-event-data_changed_finished eq con_true.
set handler gr_events_d0100->data_changed_finished
for gr_grid_d0100.
endif.
if gs_test-event-after_refresh eq con_true.
set handler gr_events_d0100->after_refresh
for gr_grid_d0100.
endif.
if gs_test-event-delayed_callback eq con_true.
set handler gr_events_d0100->delayed_callback
for gr_grid_d0100.
call method gr_grid_d0100->register_delayed_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_delayed_move_curr_cell.
endif.
if gs_test-event-delayed_changed_sel_callback eq con_true.
set handler gr_events_d0100->delayed_changed_sel_callback
for gr_grid_d0100.
call method gr_grid_d0100->register_delayed_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_delayed_change_select.
endif.
if gs_test-event-top_of_page eq con_true.
set handler gr_events_d0100->top_of_page
for gr_grid_d0100.
endif.
if gs_test-event-end_of_list eq con_true.
set handler gr_events_d0100->end_of_list
for gr_grid_d0100.
endif.
if gs_test-event-print_top_of_page eq con_true.
set handler gr_events_d0100->print_top_of_page
for gr_grid_d0100.
endif.
if gs_test-event-print_end_of_page eq con_true.
set handler gr_events_d0100->print_end_of_page
for gr_grid_d0100.
endif.
if gs_test-event-print_top_of_list eq con_true.
set handler gr_events_d0100->print_top_of_list
for gr_grid_d0100.
endif.
if gs_test-event-print_end_of_list eq con_true.
set handler gr_events_d0100->print_end_of_list
for gr_grid_d0100.
endif.
endform. " d0100_set_grid_events
*& Form d0100_get_outtab
* text
form d0100_get_outtab .
field-symbols: <ls_outtab> type g_ty_s_outtab.
data: l_excp_mod type i,
l_excp_div type i,
l_excp_amnt type i value 4,
l_excp type i,
lt_carrid type g_ty_t_carrid,
ls_carrid type g_ty_s_carrid,
l_carrid_amount type i,
l_carrid_select type i,
l_carrid_index1 type i,
lt_connid type g_ty_t_connid,
ls_connid type g_ty_s_connid,
l_connid_amount type i, "#EC NEEDED
l_connid_select type i,
l_connid_index1 type i,
l_connid_index2 type i,
lt_plane type g_ty_t_plane,
ls_plane type g_ty_s_plane.
if gs_test-select_amount gt 0.
select * from (con_sflight) into corresponding fields
of table gt_outtab up to gs_test-select_amount rows.
endif.
gs_test-select_amount = sy-dbcnt.
perform d0100_get_carrid changing lt_carrid.
perform d0100_get_connid changing lt_connid.
perform d0100_get_plane using lt_connid changing lt_plane.
describe table lt_carrid lines l_carri
Similar Messages
-
How to capture the event in ALV grid display?
Hi experts,
How to capture the event in an ALV grid display which is editable. I have to capture the TAB key or ENTER key.
regards,
Arul Jothi.Hi Arul,
Take a look at sample program BCALV_EDIT_03. (Find string "register ENTER" in the program to see how to register)
Basically you have to Register edit events using method call REGISTER_EDIT_EVENT and then write a handler method for event DATA_CHANGED..
If you are using a REUSE..GRID fm then first get the grid reference using function module GET_GLOBALS_FROM_SLVC_FULLSCR and then repeat the above procedure..
Hope this helps..
Sri
Message was edited by: Srikanth Pinnamaneni -
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. -
Reg: Top_Of_List Events in ALV GRID Display
Hi ,
How can i use the the the Top_of_list Event Alv grid Disply.
I have passed Events table with event name and form name to GRID FM it_events.
Form details:-
T_LISTHEADER header deatils table with data. .
FORM TOP_OF_LIST.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = T_LISTHEADER.
ENDFORM.
But still its not calling the form and also end_of list is working with same coding but top_of_list is not working can u give solution for this.
Regards,
rajHi Rajviji,
Please change the coding to below :-
*& Report ZR2K9_ALV008
REPORT alv_top_of_list
TABLES : t001.
TYPE-POOLS: slis.
DATA : w_repid LIKE sy-repid.
TYPES : BEGIN OF ty_comp.
INCLUDE STRUCTURE t001.
TYPES : END OF ty_comp.
DATA: T_EVENTS TYPE slis_t_event.
DATA: WA_EVENTS TYPE slis_alv_event .
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv.
DATA : it_comp TYPE TABLE OF ty_comp.
INITIALIZATION.
w_repid = sy-repid.
*Need to change here
wa_events-name = 'TOP_OF_PAGE'. "Instead of TOP_OF_LIST
wa_events-form = 'TOP_OF_PAGE'.
APPEND wa_events TO t_events.
START-OF-SELECTION.
SELECT * FROM t001 INTO TABLE it_comp up to 20 rows.
END-OF-SELECTION.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = w_repid
i_internal_tabname = 'IT_COMP'
I_STRUCTURE_NAME = 't001'
i_inclname = w_repid
CHANGING
ct_fieldcat = it_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = w_repid
it_fieldcat = it_fieldcat[]
IT_EVENTS = T_EVENTS
TABLES
t_outtab = it_comp
EXCEPTIONS
program_error = 1
OTHERS = 2.
FORM TOP_OF_PAGE. "Form Name Changed
DATA: T_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA: LS_LISTHEADER TYPE SLIS_LISTHEADER.
CLEAR LS_LISTHEADER.
LS_LISTHEADER-TYP = 'S'.
LS_LISTHEADER-KEY = 'Po Heder Details :-'.
APPEND LS_LISTHEADER TO T_LISTHEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = T_LISTHEADER.
ENDFORM.
Regards
Sandipan -
Handling Right & Left Click Events in ALV Grid
Hi Friends,
Please give me the idea how to handle Right & Left mouse Click Events in ALV Grid.
My requirement is that when i click on the grid i need to pop up a message.
Eagerly waiting for your replies
Thanks
Satishyou have to Define a class and implement event handler methods for this purpose.
and the following events can help.
LEFT_CLICK_DESIGN
LEFT_CLICK_RUN
Regards
Raja -
Control of ALV Grid displayed on 2 screens
Hi all,
I'm working on a program that does the following:
1. Select option screen is displayed for user to query DB table.
2. Query results are stored in an internal table and displayed on second program screen within an ALV grid. Some columns in this grid are editable.
3. User edits columns in grid and selects rows to process. When the user pesses a button the data is processed and a third screen is displayed containing the selected and processed rows...again within an ALV grid.
All works well with one exception...I use one container and one grid to display the data on both screens. If I navigate to the second screen and then try to return from the second screen to the select option screen by pressing the BACK button all is good in the world...I go back. If I am on the third screen and I try to return to the second screen, again all is good, I return to the second screen. The problem is when I try to go back one more screen. It seems it takes me 3 clicks to get back to the select option screen at this point. Any ideas folks?Hi Ankur,
Let me give some more detail.
1. Each screen has a custom container embedded within it. I have defined one container handle and one alv grid handle in my program. I use a call to the custom container method link to point my container handle to the correct screen.
2. I call alv grid method set_table_for_first_display only...no call to refresh_table_display...as I insert a different table and layout in the grid on each screen.
3. I call flush after each call to set_table_for_first_display
4. Following are my pai events:
MODULE user_command_9000 INPUT.
save_okcode = okcode.
CLEAR okcode.
CASE sy-dynnr.
WHEN 9000.
CASE save_okcode.
WHEN 'CONVERT'.
PERFORM convert_orders.
CALL SCREEN 9100.
LEAVE SCREEN.
WHEN 'BACK'.
SET SCREEN 0.
LEAVE SCREEN.
WHEN 'CANCEL'.
SET SCREEN 0.
LEAVE SCREEN.
WHEN 'EXIT'.
PERFORM free_objects.
LEAVE PROGRAM.
ENDCASE.
ENDCASE.
ENDMODULE. " USER_COMMAND_9000 INPUT
MODULE user_command_9100 INPUT.
save_okcode = okcode.
CLEAR okcode.
CASE sy-dynnr.
WHEN 9100.
CASE save_okcode.
WHEN 'BACK'.
SET SCREEN 9000.
LEAVE SCREEN.
WHEN 'CANCEL'.
SET SCREEN 9000.
LEAVE SCREEN.
WHEN 'EXIT'.
PERFORM free_objects.
LEAVE PROGRAM.
ENDCASE.
ENDCASE.
ENDMODULE. " USER_COMMAND_9100 INPUT
Again...the trouble is navigating from screen 9000 to 0 after I have already navigated from screen 9100 back to screen 9000 via the back button. If I am on screen 9000 and click the bakckbutton I end up on screen 9100 again. If I click the back button 2 more times, now, I end up back at the selection screen. Thanks. -
Push Button on Alv Grid display
Hi experts,
I strcuk in the middle of one program, i need to have push buttons on the output ALV Grid display, i have copied the standard status and used the same in the Function module for pf-status, iam able to get the output
but my requirement is how to add the push buttons to the out put screen, as when iam clicking on status which i have copied iam unable to find where to add these push button in the application tool bar, iam unable to edit the push button can any body help me out, thanks in advance.Hello Madan
I cannot help you with the FM-based ALV lists. However, for OO-based ALV grids (CL_GUI_ALV_GRID) I have a sample program that simulates radio buttons by using icons with hotspots.
PROGRAM ZUS_SDN_BCALV_GRID_DEMO_2.
* Based on: BCALV_GRID_DEMO.
TYPE-POOLS: icon.
TYPES: BEGIN OF ty_s_sflight.
INCLUDE TYPE sflight.
TYPES: button1 TYPE lvc_emphsz.
TYPES: button2 TYPE lvc_emphsz.
TYPES: button3 TYPE lvc_emphsz.
TYPES: button4 TYPE lvc_emphsz.
TYPES: END OF ty_s_sflight.
DATA:
gt_sflight TYPE STANDARD TABLE OF ty_s_sflight,
gt_fcat TYPE lvc_t_fcat.
DATA: ok_code LIKE sy-ucomm,
* gt_sflight TYPE TABLE OF sflight,
g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
grid1 TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-DATA:
md_cnt TYPE i.
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.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_hotspot_click.
* define local data
FIELD-SYMBOLS:
<ls_entry> TYPE ty_s_sflight,
<ld_fld> TYPE ANY.
READ TABLE gt_sflight ASSIGNING <ls_entry> INDEX es_row_no-row_id.
CHECK ( <ls_entry> IS ASSIGNED ).
* Set all radio buttons "unselected"
<ls_entry>-button1 = icon_wd_radio_button_empty.
<ls_entry>-button2 = icon_wd_radio_button_empty.
<ls_entry>-button3 = icon_wd_radio_button_empty.
<ls_entry>-button4 = icon_wd_radio_button_empty.
ASSIGN COMPONENT e_column_id-fieldname OF STRUCTURE <ls_entry>
TO <ld_fld>.
IF ( <ld_fld> IS ASSIGNED ).
* Set selected radio button "selected".
<ld_fld> = icon_wd_radio_button.
ENDIF.
* Force PAI followed by refresh of table display in PBO
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'DUMMY'
* IMPORTING
* RC =
ENDMETHOD. "handle_hotspot_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
* MAIN *
PERFORM select_data.
CALL SCREEN 100.
* MODULE PBO OUTPUT *
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
CREATE OBJECT grid1
EXPORTING i_parent = g_custom_container.
PERFORM build_fieldcatalog.
CALL METHOD grid1->set_table_for_first_display
* EXPORTING
* i_structure_name = 'SFLIGHT'
CHANGING
it_fieldcatalog = gt_fcat
it_outtab = gt_sflight.
* Set event handler for event TOOLBAR
SET HANDLER:
lcl_eventhandler=>handle_hotspot_click FOR grid1.
else.
CALL METHOD grid1->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
EXCEPTIONS
FINISHED = 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.
ENDIF.
ENDMODULE. "PBO OUTPUT
* MODULE PAI INPUT *
MODULE pai INPUT.
* to react on oi_custom_events:
CALL METHOD cl_gui_cfw=>dispatch.
CASE ok_code.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN OTHERS.
* do nothing
ENDCASE.
CLEAR ok_code.
ENDMODULE. "PAI INPUT
* FORM EXIT_PROGRAM *
FORM exit_program.
* CALL METHOD G_CUSTOM_CONTAINER->FREE.
* CALL METHOD CL_GUI_CFW=>FLUSH.
LEAVE PROGRAM.
ENDFORM. "EXIT_PROGRAM
*& Form BUILD_FIELDCATALOG
* text
* --> p1 text
* <-- p2 text
FORM build_fieldcatalog .
* define local data
DATA:
ls_fcat TYPE lvc_s_fcat,
ls_hype TYPE lvc_s_hype.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'LVC_S_FCAT'
* 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.
DELETE gt_fcat WHERE ( fieldname <> 'EMPHASIZE' ).
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'SFLIGHT'
* 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.
READ TABLE gt_fcat INTO ls_fcat
WITH KEY fieldname = 'EMPHASIZE'.
IF ( syst-subrc = 0 ).
DELETE gt_fcat INDEX syst-tabix.
ENDIF.
ls_fcat-fieldname = 'BUTTON4'.
ls_fcat-icon = 'X'.
ls_fcat-hotspot = 'X'.
INSERT ls_fcat INTO gt_fcat INDEX 4.
ls_fcat-fieldname = 'BUTTON3'.
INSERT ls_fcat INTO gt_fcat INDEX 4.
ls_fcat-fieldname = 'BUTTON2'.
INSERT ls_fcat INTO gt_fcat INDEX 4.
ls_fcat-fieldname = 'BUTTON1'.
INSERT ls_fcat INTO gt_fcat INDEX 4.
LOOP AT gt_fcat INTO ls_fcat.
ls_fcat-col_pos = syst-tabix.
MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
ENDLOOP.
ENDFORM. " BUILD_FIELDCATALOG
*& Form SELECT_DATA
* text
* --> p1 text
* <-- p2 text
FORM select_data .
* define local data
DATA:
ls_sflight TYPE ty_s_sflight.
SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE gt_sflight.
ls_sflight-button1 = icon_wd_radio_button.
ls_sflight-button2 = icon_wd_radio_button_empty.
ls_sflight-button3 = icon_wd_radio_button_empty.
ls_sflight-button4 = icon_wd_radio_button_empty.
MODIFY gt_sflight FROM ls_sflight
TRANSPORTING button1 button2 button3 button4
WHERE ( carrid IS NOT INITIAL ).
ENDFORM. " SELECT_DATA
Regards
Uwe -
ALV GRID DISPLAY USING FACTORY METHODS
Hi all
I am using factory methods for my alv grid display.
I have a list of functionalities, for which i am not able to find a correct method..
1) Header of alv(with all the values of the selection-screen)
2)How to give text to a subtotal(ed) column, i.e. if i subtotal a qty field against a sorted field, i want to display ==> Nett Wt. = 123.00 (for first header entry) and so on for each header entry.
3)how to remove the zeroes from a quantity field?
4) Displaying the cells as blanks where data is 0( for quantity fields if i have a cell with zero value, it should be blank.)
5) double click on a cell to open a transaction with the cell's value.
Any help on this would be appreciated.
Points will be rewarded for sure...
Thanks & Regards
Ravish GargHello Ravish
Regarding the display of zero values as empty cells have a look at my <i>modified </i>sample report <b>ZUS_SDN_CL_SALV_TABLE_INTERACT</b>.
*& Report ZUS_SDN_CL_SALV_TABLE_INTERACT
REPORT zus_sdn_cl_salv_table_interact.
TYPE-POOLS: abap.
DATA:
gt_knb1 TYPE STANDARD TABLE OF knb1.
DATA:
go_table TYPE REF TO cl_salv_table,
go_events TYPE REF TO cl_salv_events_table.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_double_click FOR EVENT
if_salv_events_actions_table~double_click
OF cl_salv_events_table
IMPORTING
row
column.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_double_click.
* define local data
DATA:
lo_table TYPE REF TO cl_salv_table,
lt_orders TYPE STANDARD TABLE OF bapiorders,
ls_knb1 TYPE knb1.
READ TABLE gt_knb1 INTO ls_knb1 INDEX row.
IF ( syst-subrc = 0 ).
CALL FUNCTION 'BAPI_SALESORDER_GETLIST'
EXPORTING
customer_number = ls_knb1-kunnr
sales_organization = '1000'
* MATERIAL =
* DOCUMENT_DATE =
* DOCUMENT_DATE_TO =
* PURCHASE_ORDER =
* TRANSACTION_GROUP = 0
* PURCHASE_ORDER_NUMBER =
* IMPORTING
* RETURN =
TABLES
sales_orders = lt_orders.
* Create ALV grid instance
TRY.
CALL METHOD cl_salv_table=>factory
* EXPORTING
* LIST_DISPLAY = IF_SALV_C_BOOL_SAP=>FALSE
* R_CONTAINER =
* CONTAINER_NAME =
IMPORTING
r_salv_table = lo_table
CHANGING
t_table = lt_orders.
CATCH cx_salv_msg .
ENDTRY.
lo_table->display( ).
** SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.
** SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
** CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
ENDIF.
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1
WHERE bukrs = '1000'.
* Create ALV grid instance
TRY.
CALL METHOD cl_salv_table=>factory
* EXPORTING
* LIST_DISPLAY = IF_SALV_C_BOOL_SAP=>FALSE
* R_CONTAINER =
* CONTAINER_NAME =
IMPORTING
r_salv_table = go_table
CHANGING
t_table = gt_knb1.
CATCH cx_salv_msg .
ENDTRY.
* Create event instance
go_events = go_table->get_event( ).
* Set event handler
SET HANDLER:
lcl_eventhandler=>handle_double_click FOR go_events.
PERFORM modify_columns.
go_table->display( ).
END-OF-SELECTION.
*& Form MODIFY_COLUMNS
* text
* --> p1 text
* <-- p2 text
FORM modify_columns .
* define local data
DATA:
lt_dfies TYPE ddfields,
ls_dfies TYPE dfies,
lo_typedescr TYPE REF TO cl_abap_typedescr,
lo_strucdescr TYPE REF TO cl_abap_structdescr,
lo_tabledescr TYPE REF TO cl_abap_tabledescr,
lo_columns TYPE REF TO cl_salv_columns_table,
lo_column TYPE REF TO cl_salv_column.
lo_columns = go_table->get_columns( ).
lo_typedescr = cl_abap_typedescr=>describe_by_data( gt_knb1 ).
lo_tabledescr ?= lo_typedescr.
lo_strucdescr ?= lo_tabledescr->get_table_line_type( ).
lt_dfies = lo_strucdescr->get_ddic_field_list( ).
LOOP AT lt_dfies INTO ls_dfies.
lo_column = lo_columns->get_column( ls_dfies-fieldname ).
IF ( ls_dfies-keyflag = abap_true ).
CONTINUE.
ELSEIF ( ls_dfies-fieldname = 'WEBTR' ). " Bill of ex. limit
lo_column->set_zero( if_salv_c_bool_sap=>true ). " display zero
lo_column->set_zero( if_salv_c_bool_sap=>false ). " hide zero
ELSE.
lo_column->set_technical( if_salv_c_bool_sap=>true ). " hide col
ENDIF.
ENDLOOP.
ENDFORM. " MODIFY_COLUMNS
Regards
Uwe -
Drill down capabilities for an alv grid display field using oops concept
Hi All,
could anyone help me in how to achieve the drill down capabilities for an alv grid display field using oops concept.
Thanks & Regards,
padmasri.padmasri,
Hope your requirement is something like, when you click on a sales order number it should display that order (VA03), in a grid output displayed using set_table_for_first_display.
you can acheive it using event double click.
*& L O C A L C L A S S E S - D E F I N I T O N *
class lcl_event_receiver: local class to handle event DOUBLE_CLICK
CLASS LCL_EVENT_RECEIVER DEFINITION.
PUBLIC SECTION.
METHODS:
HANDLE_DOUBLE_CLICK
FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW E_COLUMN.
PRIVATE SECTION.
ENDCLASS. "lcl_event_receiver DEFINITION
*& L O C A L C L A S S E S - I M P L E M E N T A T I O N *
CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.
METHOD HANDLE_DOUBLE_CLICK.
PERFORM HANDLE_DOUBLE_CLICK USING E_ROW
E_COLUMN.
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
FORM HANDLE_DOUBLE_CLICK USING E_ROW TYPE LVC_S_ROW
E_COLUMN TYPE LVC_S_COL.
DATA: LS_DETAIL LIKE LINE OF T_OUTPUT.
WHEN 'T_OUTPUT'.
READ TABLE T_OUTPUT INDEX E_ROW-INDEX INTO LS_DETAIL.
If clicked on PO Number or PO Item, call ME23
IF E_COLUMN-FIELDNAME = 'EBELN' OR
E_COLUMN-FIELDNAME = 'EBELP' .
SET PARAMETER ID 'BES' FIELD LS_DETAIL-EBELN.
SET PARAMETER ID 'BSP' FIELD LS_DETAIL-EBELP.
CALL TRANSACTION 'ME23' AND SKIP FIRST SCREEN.
If clicked on sales order number or item, call VA03
ELSEIF E_COLUMN-FIELDNAME = 'VBELN' OR
E_COLUMN-FIELDNAME = 'POSNR'.
SET PARAMETER ID 'AUN' FIELD LS_DETAIL-VBELN.
SET PARAMETER ID 'APO' FIELD LS_DETAIL-POSNR.
CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
Hope this helps -
Update values in AlV grid display after entering value
Hi,
I have an issue in ALV grid display.
Let me explain.
i have 8 fields to display in which one is editiable.
Fields are: date
material,
material Description,
Opening Stock,
Closing stock- ( this field is editiable)
Closing stock,
Received Stock,
Actual production.
Actual production = Closing stock + removal stock
- receipt stock - opening stock.
when i change the value of closing stock and press enter, actual production should get update, the new values should display.
Thany you in advance.Hi,
Please refer the code below:
REPORT z_demo_alv_jg.*******************************************************************
* TYPE-POOLS *
TYPE-POOLS: slis. *******************************************************************
* INTERNAL TABLES/WORK AREAS/VARIABLES *
DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
i_index TYPE STANDARD TABLE OF i WITH HEADER LINE,
w_field TYPE slis_fieldcat_alv,
p_table LIKE dd02l-tabname,
dy_table TYPE REF TO data,
dy_tab TYPE REF TO data,
dy_line TYPE REF TO data.*******************************************************************
* FIELD-SYMBOLS *
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
<dyn_wa> TYPE ANY,
<dyn_field> TYPE ANY,
<dyn_tab_temp> TYPE STANDARD TABLE.*******************************************************************
* SELECTION SCREEN *
PARAMETERS: tabname(30) TYPE c,
lines(5) TYPE n.*******************************************************************
* START-OF-SELECTION *
START-OF-SELECTION.* Storing table name
p_table = tabname.* Create internal table dynamically with the stucture of table name
* entered in the selection screen
CREATE DATA dy_table TYPE STANDARD TABLE OF (p_table).
ASSIGN dy_table->* TO <dyn_table>.
IF sy-subrc <> 0.
MESSAGE i000(z_zzz_ca_messages) WITH ' No table found'. LEAVE TO LIST-PROCESSING.
ENDIF.
* Create workarea for the table
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.* Create another temp. table
CREATE DATA dy_tab TYPE STANDARD TABLE OF (p_table).
ASSIGN dy_tab->* TO <dyn_tab_temp>. SORT i_fieldcat BY col_pos.* Select data from table
SELECT * FROM (p_table)
INTO TABLE <dyn_table>
UP TO lines ROWS. REFRESH <dyn_tab_temp>.* Display report
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_structure_name = p_table
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'SET_PF_STATUS'
TABLES
t_outtab = <dyn_table>
EXCEPTIONS
program_error = 1
OTHERS = 2. IF sy-subrc <> 0. ENDIF.*&-----------------------------------------------------------------*
*& Form SET_PF_STATUS
* Setting custom PF-Status
* -->RT_EXTAB Excluding table
FORM set_pf_status USING rt_extab TYPE slis_t_extab. SET PF-STATUS 'Z_STANDARD'.ENDFORM. "SET_PF_STATUS*&----------------------------------------------------------------*
*& Form user_command
* Handling custom function codes
* -->R_UCOMM Function code value
* -->RS_SELFIELD Info. of cursor position in ALV
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.* Local data declaration
DATA: li_tab TYPE REF TO data,
l_line TYPE REF TO data.* Local field-symbols
FIELD-SYMBOLS:<l_tab> TYPE table,
<l_wa> TYPE ANY.* Create table
CREATE DATA li_tab TYPE STANDARD TABLE OF (p_table).
ASSIGN li_tab->* TO <l_tab>.* Create workarea
CREATE DATA l_line LIKE LINE OF <l_tab>.
ASSIGN l_line->* TO <l_wa>. CASE r_ucomm.* When a record is selected
WHEN '&IC1'.* Read the selected record
READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX
rs_selfield-tabindex. IF sy-subrc = 0.* Store the record in an internal table
APPEND <dyn_wa> TO <l_tab>.* Fetch the field catalog info
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = 'Z_DEMO_PDF_JG'
i_structure_name = p_table
CHANGING
ct_fieldcat = i_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc = 0.* Make all the fields input enabled except key fields
w_field-input = 'X'. MODIFY i_fieldcat FROM w_field TRANSPORTING input
WHERE key IS INITIAL. ENDIF.* Display the record for editing purpose
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_structure_name = p_table
it_fieldcat = i_fieldcat
i_screen_start_column = 10
i_screen_start_line = 15
i_screen_end_column = 200
i_screen_end_line = 20
TABLES
t_outtab = <l_tab>
EXCEPTIONS
program_error = 1
OTHERS = 2. IF sy-subrc = 0.* Read the modified data
READ TABLE <l_tab> INDEX 1 INTO <l_wa>.* If the record is changed then track its index no.
* and populate it in an internal table for future
* action
IF sy-subrc = 0 AND <dyn_wa> <> <l_wa>.
<dyn_wa> = <l_wa>.
i_index = rs_selfield-tabindex.
APPEND i_index.
ENDIF.
ENDIF. ENDIF.* When save button is pressed
WHEN 'SAVE'.* Sort the index table
SORT i_index.* Delete all duplicate records
DELETE ADJACENT DUPLICATES FROM i_index. LOOP AT i_index.* Find out the changes in the internal table
* and populate these changes in another internal table
READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX i_index.
IF sy-subrc = 0.
APPEND <dyn_wa> TO <dyn_tab_temp>.
ENDIF. ENDLOOP.* Lock the table
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = p_table
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3. IF sy-subrc = 0.* Modify the database table with these changes
MODIFY (p_table) FROM TABLE <dyn_tab_temp>. REFRESH <dyn_tab_temp>.* Unlock the table
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = p_table. ENDIF.
ENDCASE. rs_selfield-refresh = 'X'.ENDFORM. "user_command
Thanks,
Sriram Ponna. -
Hi,
I'm modifying a program with ALV Grid Display.There are lot of Classes and Methods which i don't understand.
In my program, the Program is executes and displays an Output. Now in the O/P , when I dbl click a field of a row a POP up is displayed with the existing value.now i can edit this value or Update with a new value.After closing the POP up the edited valueor the new value is displayed in the field. The program works good upto here.Now if my O/P has 20 Pages and if i edit a field in the 18 page, then after closing the popup the cursor ( or display ) is displayed in the 1 page( the 1 page of the O/P is displayed). Now, again, if i want to edit a field in the 18 page i have to scroll to the 18 page. Is there any way to hold the display at the 18 page after closing the POPUP.
I arrived at using CALL METHOD <ref.var. to CL_GUI_ALV_GRID > ->set_current_cell_via_id
EXPORTING
IS_ROW_ID = <structure of type LVC_S_ROW >
IS_COLUMN_ID = <structure of type LVC_S_COL >
IS_ROW_NO = <structure of type LVC_S_ROID >.
can some one help me how to pass values to is_row_id and all the parameters.
Is there any other way?Thanks in advance.
Thanks,
Bhaskar.Dear Bhaskar,
To acheieve this follow the below steps:
1. On double click first get the scroll information using the method GET_SCROLL_INFO_VIA_ID of class CL_GUI_ALV_GRID.
CALL METHOD go_alv_grid->get_scroll_info_via_id
IMPORTING
es_row_no = gv_s_roid
es_row_info = gv_s_row
es_col_info = gv_s_col.
2. Again at the end of your double click event call the method SET_SCROLL_INFO_VIA_ID to set the scroll.
CALL METHOD go_alv_grid->set_scroll_info_via_id
EXPORTING
is_row_info = gv_s_row
is_col_info = gv_s_col
is_row_no = gv_s_roid.
Regards
Kesava -
Push button in ALV Grid Display
Hi all,
I have a requirement wherin i need to place a button in the ALV Grid Display which should update all the records whatever are displayed in the specified infotype. This is to be done in a report.
Can anybody give me any pointers or sample code for the above query.
Regards,
AmritaSimply add a button on your GUI status. Then when pushed, code your logic for update IT0008.
AT USER-COMMAND event block will be triggered when you press your button.
AT USER-COMMAND.
if sy-ucomm = 'PUSHBUTTON'. "here comes function code of your pushbutton
"update your diplayed records
endif. -
ALV grid display the subtotal not getting for one column at the output
Hi,
I am working one report ALV grid display and subtotal is not getting for one paricular coulumn.
Eventhough that column has some values.
So can anyone give the proper solution.
Waiting quick response.
Best Regards,
BansiHi
see this link .
https://wiki.sdn.sap.com/wiki/display/ABAP/SUBTOTALinALV
or try this program.
REPORT zalv.
DATA:
t_sflight TYPE TABLE OF sflight,
fs_sflight TYPE sflight.
DATA:
r_container TYPE REF TO cl_gui_custom_container,
r_grid TYPE REF TO cl_gui_alv_grid.
*FIELD CATALOG
DATA:
t_fcat TYPE lvc_t_fcat,
fs_fcat TYPE lvc_s_fcat.
*SORTING THE BASIC LIST
DATA:
t_sort TYPE lvc_t_sort,
fs_sort TYPE lvc_s_sort.
fs_fcat-fieldname = 'PRICE'.
fs_fcat-do_sum = 'X'.
APPEND fs_fcat TO t_fcat.
fs_sort-spos ='1'.
fs_sort-fieldname = 'CARRID'.
fs_sort-down = 'X'.
fs_sort-group = '*'.
fs_sort-subtot = 'X'.
APPEND fs_sort TO t_sort.
SELECT * FROM sflight INTO TABLE t_sflight.
CALL SCREEN 100.
*& Module STATUS_0100 OUTPUT
MODULE status_0100 OUTPUT.
SET PF-STATUS 'SCREEN1'.
SET TITLEBAR 'TITLE1'.ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
**& Module HANDLER OUTPUT
MODULE list OUTPUT.
CREATE OBJECT r_container
EXPORTING
container_name = 'CONTAINER'.
CREATE OBJECT r_grid
EXPORTING
i_parent = r_container.
CALL METHOD r_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'SFLIGHT'
CHANGING
it_fieldcatalog = t_fcat
it_outtab = t_sflight
it_sort = t_sort.
ENDMODULE. "list OUTPUT
Regards
Hareesh Menon -
ALV Grid display Drop down lists
I have a alv grid display with a few records say 5 records which display 5 columns 5 rows. I want to know is it possible to have drop down lists for each column row cell but with different drop down values for each record.
So 5 columns 5 rows 25 cells but each cell have different drop down values.
Any info would be appreciatedHi,
Thanks for the replies.
Currently i do understand how to get the drop down handle per column and add values but this will only show the drop down values for each cell the same for each column.
What i am trying is that each cell of each colum of each row must have different drop down values.
Example below: Where the ; is devider for new value as a drop down value for that cell
Record-- column1---column2 column3 column4 column5
1 -
a;b;c -
d;e;f -
g;h;i -
k;l;m -
o;i
2 -
l;k;j -
i;j;g----
q;e;r -
o;u;g -
g;d;e -
How to devide the top of page in alv grid display
hi all
in the alv grid display am getting the page number and total number of pages in the left hand side
but what i need is i need in the right hand side
how to get thatHi,
PLease refer to the code below:
*& Report ZDEMO_ALVGRID *
*& Example of a simple ALV Grid Report *
*& The basic requirement for this demo is to display a number of *
*& fields from the EKKO table. *
REPORT zdemo_alvgrid .
TABLES: ekko.
type-pools: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid,
gt_events type slis_t_event,
gd_prntparams type slis_print_alv.
*Start-of-selection.
START-OF-SELECTION.
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform build_events.
perform build_print_params.
perform display_alv_report.
*& Form BUILD_FIELDCATALOG
* Build Fieldcatalog for ALV Report
form build_fieldcatalog.
* There are a number of ways to create a fieldcat.
* For the purpose of this example i will build the fieldcatalog manualy
* by populating the internal table fields individually and then
* appending the rows. This method can be the most time consuming but can
* also allow you more control of the final product.
* Beware though, you need to ensure that all fields required are
* populated. When using some of functionality available via ALV, such as
* total. You may need to provide more information than if you were
* simply displaying the result
* I.e. Field type may be required in-order for
* the 'TOTAL' function to work.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
* fieldcatalog-do_sum = 'X'.
* fieldcatalog-no_zero = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-col_pos = 5.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-do_sum = 'X'.
fieldcatalog-datatype = 'CURR'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
* Build layout for ALV grid report
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
* gd_layout-totals_only = 'X'.
* gd_layout-f2code = 'DISP'. "Sets fcode for when double
* "click(press f2)
* gd_layout-zebra = 'X'.
* gd_layout-group_change_edit = 'X'.
* gd_layout-header_text = 'helllllo'.
endform. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
* Display report using ALV grid
form display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
* i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
* it_special_groups = gd_tabgroup
it_events = gt_events
is_print = gd_prntparams
i_save = 'X'
* is_variant = z_template
tables
t_outtab = it_ekko
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.
endform. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
* Retrieve data form EKPO table and populate itab it_ekko
form data_retrieval.
select ebeln ebelp statu aedat matnr menge meins netpr peinh
up to 10 rows
from ekpo
into table it_ekko.
endform. " DATA_RETRIEVAL
* Form TOP-OF-PAGE *
* ALV Report Header *
Form top-of-page.
*ALV Header declarations
data: t_header type slis_t_listheader,
wa_header type slis_listheader,
t_line like wa_header-info,
ld_lines type i,
ld_linesc(10) type c.
* Title
wa_header-typ = 'H'.
wa_header-info = 'EKKO Table Report'.
append wa_header to t_header.
clear wa_header.
* Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info. "todays date
append wa_header to t_header.
clear: wa_header.
* Total No. of Records Selected
describe table it_ekko lines ld_lines.
ld_linesc = ld_lines.
concatenate 'Total No. of Records Selected: ' ld_linesc
into t_line separated by space.
wa_header-typ = 'A'.
wa_header-info = t_line.
append wa_header to t_header.
clear: wa_header, t_line.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = t_header.
* i_logo = 'Z_LOGO'.
endform.
* FORM USER_COMMAND *
* --> R_UCOMM *
* --> RS_SELFIELD *
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
* Check function code
CASE r_ucomm.
WHEN '&IC1'.
* Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'EBELN'.
* Read data table, using index of row user clicked on
READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
* Set parameter ID for transaction screen field
SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
* Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM.
*& Form BUILD_EVENTS
* Build events table
form build_events.
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = gt_events[].
read table gt_events with key name = slis_ev_end_of_page
into ls_event.
if sy-subrc = 0.
move 'END_OF_PAGE' to ls_event-form.
append ls_event to gt_events.
endif.
read table gt_events with key name = slis_ev_end_of_list
into ls_event.
if sy-subrc = 0.
move 'END_OF_LIST' to ls_event-form.
append ls_event to gt_events.
endif.
endform. " BUILD_EVENTS
*& Form BUILD_PRINT_PARAMS
* Setup print parameters
form build_print_params.
gd_prntparams-reserve_lines = '3'. "Lines reserved for footer
gd_prntparams-no_coverpage = 'X'.
endform. " BUILD_PRINT_PARAMS
*& Form END_OF_PAGE
form END_OF_PAGE.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
write: sy-uline(50).
skip.
write:/40 'Page:', sy-pagno .
endform.
*& Form END_OF_LIST
form END_OF_LIST.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
skip.
write:/40 'Page:', sy-pagno .
endform.
Thanks,
Sriram Ponna.
Maybe you are looking for
-
I am trying to re-print a portion of a photo enlarged through "poster" in the print dialog box. The original photo printed just fine with the exception of one "page." This is what I'm trying to re-print. I have gone into the Multi- page box clicked o
-
Reading A String at a random location in a file
Question: Given a file of English words (a dictionary file I guess�), delimited by commas, I want to know if it is possible to write a java program that can read a random word from the dictionary file and store it into a String. If this is possible,
-
Font size difference between Dreamweaver, view in Safari and on friend's PC
In Dreamweaver CS3, I have a table with two cells containing type. In order to get the type to not appear too large, I need to size the type down to 6pt size on screen in Dreamweaver, then it appears like about 10pt normal size text in my Safari brow
-
Satellite A500-1GM electric circuit touching touchpad and USB case
It's intermittent, but I seem to be able to create a current through my fingers from the two buttons at the front of the touchpad. Current plug configuration is like this: - 4 way splitter, including plugged in laptop and plugged in external hard dri
-
Hi, I purchased some apple applications and already paid for this in my credit card, but I did not get receipt for it. The purchase was on July 5, 2012. How can I get the receipt for this purchase? Thanks!