Regarding single click in alv's
hi guru's
i have a small problem.
iam using a alv grid display. after clicking on the row in alv , i need to navigate to a transaction mm03.
My problem is the navigation is happening in double-click. how can i use the single click option.
my program consists of:
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_structure_name = l_c_struc
i_inclname = sy-repid
CHANGING
ct_fieldcat = fp_l_i_fieldcat
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
i_callback_user_command = l_c_user_command
i_grid_title = text-004
is_layout = fp_wa_layout
it_fieldcat = fp_i_fieldcatalog
i_save = l_c_a
it_events = fp_i_event
TABLES
t_outtab = fp_i_makt
FORM at_user_command USING fp_ucom TYPE sy-ucomm
fp_selfield TYPE slis_selfield. "#EC *
CASE fp_ucom.
WHEN '&IC1'.
READ TABLE i_makt INTO wa_final
INDEX fp_selfield-tabindex.
IF sy-subrc EQ c_0.
SET PARAMETER ID 'MAT' FIELD wa_final-matnr.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
ENDIF.
WHEN OTHERS.
MESSAGE i009.
ENDCASE.
ENDFORM.
please give me a detailed description as iam new to abap programming.
HI USE THIS EXAMPLE ,
use the hot spot for this option.
*& Report Z_TEST001
REPORT Z_TEST001.
TYPE-POOLS: slis.
tables: rseg.
DATA: begin of TAB_ARSEG occurs 0.
INCLUDE STRUCTURE RSEG.
DATA: END OF TAB_ARSEG.
DATA: T_FIELDCAT TYPE slis_t_fieldcat_alv.
DATA: c_user_command TYPE slis_formname VALUE 'USER_COMMAND'.
START-OF-SELECTION.
<<< YOUR CODE >>> ***********************
select * from rseg into table tab_arseg .
END-OF-SELECTION.
perform build_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_buffer_active = space
i_callback_program = sy-repid
I_CALLBACK_USER_COMMAND = c_user_command
I_STRUCTURE_NAME =
IS_LAYOUT =
IT_FIELDCAT = T_FIELDCAT[]
TABLES
T_OUTTAB = TAB_ARSEG
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC ne 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
**& Form USER_COMMAND
FORM USER_COMMAND USING F_UCOMM LIKE SY-UCOMM
I_SELFIELD TYPE SLIS_SELFIELD.
DATA: F_SUBRC LIKE SY-SUBRC,
s_arseg like tab_arseg.
READ TABLE tab_arseg INDEX i_selfield-tabindex INTO s_arseg.
CASE F_UCOMM.
WHEN '&IC1'.
CASE i_SELFIELD-SEL_TAB_FIELD.
WHEN 'TAB_ARSEG-BELNR'.
CHECK NOT S_ARSEG-BELNR IS INITIAL.
SET PARAMETER ID 'RBN' FIELD S_ARSEG-BELNR.
SET PARAMETER ID 'GJR' FIELD S_ARSEG-GJAHR.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
ENDCASE.
ENDCASE.
ENDFORM.
**& Form build_fieldcat
FORM build_fieldcat .
DATA: FIELDCAT TYPE SLIS_FIELDCAT_ALV.
CLEAR FIELDCAT.
FIELDCAT-FIELDNAME = 'BELNR'.
FIELDCAT-TABNAME = 'TAB_ARSEG'.
FIELDCAT-REF_TABNAME = 'RSEG'.
FIELDCAT-REF_FIELDNAME = 'BELNR'.
fieldcat-hotspot = 'X'.
FIELDCAT-COL_POS = 1.
APPEND FIELDCAT TO t_fieldcat.
CLEAR FIELDCAT.
FIELDCAT-FIELDNAME = 'GJAHR'.
FIELDCAT-TABNAME = 'TAB_ARSEG'.
FIELDCAT-REF_TABNAME = 'RSEG'.
FIELDCAT-REF_FIELDNAME = 'GJAHR'.
FIELDCAT-COL_POS = 2.
APPEND FIELDCAT TO t_fieldcat.
ENDFORM. " build_fieldcat
REGARDS,
VENKAT.
Similar Messages
-
Hi friends,
below statement is for double clicking,
WHEN '&IC1'. " SAP standard code for double-clicking, but i need single click because when i select field(not doubble click only single click) in alv grid it has to trigger and perform some action ,can any one know please tell me.gwa_fldcat-col_pos = 2.
gwa_fldcat-fieldname = 'CHK'.
gwa_fldcat-tabname = 'GT_FINAL'.
gwa_fldcat-EMPHASIZE = 'C310'.
gwa_fldcat-input = 'X'.
gwa_fldcat-edit = 'X'.
gwa_fldcat-checkbox = 'X'.
gwa_fldcat-just = 'C'.
gwa_fldcat-key = 'X'.
gwa_fldcat-outputlen = 16.
gwa_fldcat-seltext_l = 'Selection'.
gwa_fldcat-hotspot = 'X'.
APPEND gwa_fldcat TO git_fldcat.
CLEAR gwa_fldcat.
gs_events-name = 'USER_COMMAND'.
gs_events-form = 'USER'.
append gs_events to gi_events.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = sy-repid
i_callback_pf_status_set = 'PFSTATUS'
i_callback_user_command = 'USER'
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS = wa_grid
is_layout = gs_layout
it_fieldcat = git_fldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
it_events = gi_events
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = gt_final.
gs_layout-colwidth_optimize = 'X'.
gs_layout-zebra = 'X'.
gs_layout-info_fieldname = 'COLOR'.
gs_layout-KEY_HOTSPOT = 'X'.
form user using lv_okcode like sy-ucomm
rs_selfield type slis_selfield.
lv_okcode = sy-ucomm.
case lv_okcode.
when '&IC1'.
loop at gt_final into gwa_final .
where chk = 'X'.
if gwa_final-chk is not initial.
gwa_final-color = 'C111' .
modify gt_final from gwa_final
index sy-tabix transporting color.
clear gwa_final.
endif.
endloop.
encase.
form Grid_settings .
wa_grid-EDT_CLL_CB = 'X'.
endform. -
How to Open new screen for single click on ALV icon.
Hi All,
Can any body help me regarding the below ALV requirement.
I need to create a executable program ZPROGRAM with a table having field to store long text.The ALV report should display records according to the selection screen parameters with a icon in each record when clicked should open a new screen with present data in the field and must be able to save the entered long text.
Can any body give me the idea after displaying the simple ALV in the output,
How to open new screen(not the Pop-ups) after single click on the icon,
in that I should be able to modify & save the long text in my ZTABLE and
able to retrieve the same text for single clicked icon record.
which function modules/Classes/Methods can we use for this requirement.
And how retrieve the same text for this record.
Thanks in advance.
Regards,
Kalam A.*& Report ZTEST_ALV
REPORT ZTEST_ALV.
TYPE-POOLS slis.
DATA: gt_fieldcat TYPE TABLE OF slis_fieldcat_alv .
DATA: gs_layout TYPE slis_layout_alv.
DATA: gt_list_top_of_page TYPE slis_t_listheader.
DATA: gt_sortinfo_alv TYPE slis_t_sortinfo_alv.
DATA: gs_print_alv TYPE slis_print_alv.
DATA: gs_grid TYPE lvc_s_glay.
DATA: gt_event TYPE slis_t_event.
DATA: gs_event TYPE slis_alv_event.
DATA: BEGIN OF GT_DISPLAY OCCURS 100.
INCLUDE STRUCTURE MARA.
DATA: BOX.
DATA: END OF GT_DISPLAY.
START-OF-SELECTION.
SELECT * FROM MARA UP TO 50 ROWS
INTO CORRESPONDING FIELDS OF TABLE GT_DISPLAY.
End-of-Selection.
PERFORM build_alv.
PERFORM display_screen .
FORM build_alv .
DATA: ls_fieldcat LIKE LINE OF gt_fieldcat.
DATA: ls_top TYPE LINE OF slis_t_listheader.
DATA: ls_sort TYPE slis_sortinfo_alv.
CLEAR: ls_fieldcat, gt_fieldcat[], ls_top,gt_list_top_of_page[],
ls_sort,gs_grid,gs_print_alv,gt_sortinfo_alv[].
*&-----gs_layout definition.
gs_layout-zebra = 'X'.
gs_layout-detail_popup = 'X'. "ÊÇ·ñµ¯³öÏêϸÐÅÏ¢´°¿Ú
gs_layout-f2code = '&ETA'. "ÉèÖô¥·¢µ¯³öÏêϸÐÅÏ¢´°¿ÚµÄ¹¦ÄÜÂë,ÕâÀïÊÇË«»÷
gs_layout-no_vline = ' '. "ÉèÖÃÁмä¸ôÏß
gs_layout-colwidth_optimize = 'X'. "ÓÅ»¯Áпí
gs_layout-detail_initial_lines = 'X'.
gs_layout-coltab_fieldname = 'LINE_COLOR'. "Line_colorΪgt_displayµÄÒ»¸ö×Ö¶Î,¾ßÌåÑÕÉ«ÉèÖüûÏÂÃæ˵Ã÷.
gs_layout-hotspot_fieldname = 'MATNR'.
gs_layout-detail_titlebar = 'ÏêϸÄÚÈÝ'. "ÉèÖõ¯³ö´°¿ÚµÄ±êÌâÀ¸
gs_layout-group_change_edit = 'X'.
*&-----gs_grid definition.
gs_grid-top_p_only = 'X'.
*&-----gs_print_alv definition.
gs_print_alv-prnt_title = 'X'.
gs_print_alv-prnt_info = 'X'.
*&-----gt_sortinfo_alv definition. С¼Æ
ls_sort-fieldname = 'MTART'.
ls_sort-tabname = 'GT_DISPLAY'.
ls_sort-subtot = 'X'.
ls_sort-spos = 1.
ls_sort-up = 'X'.
ls_sort-group = 'UL'.
APPEND ls_sort TO gt_sortinfo_alv.
ls_sort-fieldname = 'AENAM'.
ls_sort-tabname = 'GT_DISPLAY'.
ls_sort-subtot = 'X'.
ls_sort-spos = 1.
ls_sort-up = 'X'.
ls_sort-group = 'UL'.
APPEND ls_sort TO gt_sortinfo_alv.
*&-----slis_t_listheader definition. title.
CLEAR ls_top.
ls_top-key = 'µ±Ç°ÈÕÆÚ:'.
ls_top-typ = 'S'. " H = Header, S = Selection, A = Action
CONCATENATE sy-datum0(4) '-' sy-datum4(2) '-' sy-datum+6(2) INTO ls_top-info .
APPEND ls_top TO gt_list_top_of_page.
CLEAR ls_top.
ls_top-key = 'title'.
ls_top-typ = 'S'. " H = Header, S = Selection, A = Action
ls_top-info = space.
APPEND ls_top TO gt_list_top_of_page.
*&-----gs_print_alv definition.
gs_print_alv-prnt_title = 'X'.
gs_print_alv-prnt_info = 'X'.
*&-----gt_fieldcat definition.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'GT_DISPLAY'
i_structure_name = 'MARA'
I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = sy-repid
CHANGING
ct_fieldcat = gt_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
ls_fieldcat-hotspot = 'X'.
MODIFY gt_fieldcat FROM ls_fieldcat INDEX 2.
**-1. definition with macro.
DEFINE macro.
col_pos = col_pos + 1.
ls_fieldcat-tabname = 'it_typ_data'.
ls_fieldcat-fieldname = '&1'.
ls_fieldcat-seltext_l = &2.
ls_fieldcat-col_pos = col_pos.
ls_fieldcat-outputlen = '&3'.
ls_fieldcat-datatype = '&4'.
ls_fieldcat-do_sum = &5.
ls_fieldcat-edit = &6.
ls_fieldcat-checkbox = &7.
ls_fieldcat-key = &9.
ls_fieldcat-fix_column = &10.
ls_fieldcat-no_out = &11.
ls_fieldcat-ref_fieldname = &4. " System F4 Effect.
ls_fieldcat-ref_tabname = &5. " System F4 Effect.
ls_fieldcat-hotspot = &6.
append ls_fieldcat to gt_fieldcat.
clear ls_fieldcat.
END-OF-DEFINITION.
macro matnr 'matnr' 18 'MATNR' 'MARA' 'X'.
macro MTART 'MTART' 18 'MTART' 'MARA' ''.
macro AENAM 'AENAM' 18 'MAENAM' 'MARA' ''.
**-2. definition one-by-one.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'MATNR'.
ls_fieldcat-seltext_s = 'ÎïÁÏ'.
ls_fieldcat-ref_fieldname = 'ROLLNAME'.
ls_fieldcat-ref_tabname = 'DD03L'.
APPEND ls_fieldcat TO gt_fieldcat.
ENDFORM. "build_alv
FORM display_screen .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = gt_event
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 gt_event INTO gs_event WITH KEY name = 'TOP_OF_PAGE'.
IF sy-subrc EQ 0.
gs_event-form = 'TOP_OF_PAGE'.
MODIFY gt_event FROM gs_event INDEX sy-tabix.
ENDIF.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
i_callback_pf_status_set = 'PF_STATUS_SET '
i_callback_user_command = 'USER_COMMAND'
i_callback_top_of_page = 'TOP_OF_PAGE'
I_CALLBACK_HTML_TOP_OF_PAGE = 'HTML_TOP_OF_PAGE'
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = 'ALV_BACKGROUND' "When top-of-page is initial.
I_GRID_TITLE =
I_GRID_SETTINGS =
is_layout = gs_layout
it_fieldcat = gt_fieldcat[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
it_sort = gt_sortinfo_alv[]
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = 'A'
IS_VARIANT =
IT_EVENTS = gt_event
IT_EVENT_EXIT =
IS_PRINT = gs_print_alv
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = gt_display
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_screen
FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
Data ref1 type ref to cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR' "Check Box need fieldcat-checkbox, input and edit.
IMPORTING
E_GRID = ref1.
CASE ucomm.
WHEN '&IC1'. " SAP standard code for double-clicking
READ TABLE gt_display INTO gs_display INDEX slis_selfield-tabindex.
CHECK sy-subrc = 0.
CASE selfield-fieldname .
WHEN 'PLNUM'.
SET PARAMETER ID 'PAF' FIELD gs_display-plnum.
CALL TRANSACTION 'MD12' AND SKIP FIRST SCREEN.
WHEN 'POSNR'.
SUBMIT rvscd100 USING SELECTION-SCREEN '1000' WITH vbeln = gs_display-vbeln
WITH posnr = gs_display-posnr
WITH zinfo = 'X'
AND RETURN.
ENDCASE.
IF selfield-sel_tab_field = 'OUT_ITAB-PI_SL'. " Line detail.
READ TABLE i_output INTO pisl_itab INDEX selfield-tabindex.
IF sy-subrc EQ 0.
ENDIF.
WHEN 'CHANGE'.
CALL METHOD ref1->check_changed_data.
CALL METHOD ref1->refresh_table_display.
*5´Ë´¦´úÂë×èÖ¹'REUSE_ALV_GRID_DISPLAY´´½¨ÐµÄÆÁÄ»£¬Ôì³ÉÆÁÄ»¶à²ã
selfield-refresh = 'X'.
WHEN 'SWITCH'.
PERFORM switch_edit_mode.
WHEN OTHERS.
ENDCASE.
ENDFORM. "user_command
Add your code in user_command form.
WHEN you click matnr ucomm eq '&IC1'.
Message was edited by:
Chunhai Hu -
Handling single click in alv tree
Hello Friends,
Is there an event triggered,for single click on an alv tree.
regards
kaushikhi ,
it_fieldcat-hotspot = 'X'.
regards,
venkat.
Edited by: venkat appikonda on Mar 13, 2008 8:11 PM
Edited by: venkat appikonda on Mar 13, 2008 8:12 PM -
Single click on alv calls details in another alv
i have one alv where i can display main data. after i mak a click on the line in the alv i want to see ather details according to the first alv in a second alv.
is that possible?Hi,
Refer the below program
class lcl_event_receiver definition deferred.
data: ok_code like sy-ucomm,
save_ok like sy-ucomm,
g_max type i value 100,
gt_sflight type table of sflight,
gt_sbook type table of sbook,
g_repid like sy-repid,
gs_layout type lvc_s_layo,
cont_for_flights type scrfname value 'BCALV_GRID_02_100',
grid1 type ref to cl_gui_alv_grid,
custom_container type ref to cl_gui_custom_container,
grid2 type ref to cl_gui_alv_grid,
* reference to dialogbox container.
dialogbox_container type ref to cl_gui_dialogbox_container,
* reference to local class that handles events of GRID1 and
* DIALOGBOX_CONTAINER
event_receiver type ref to lcl_event_receiver.
* Set initial dynpro
set screen 100.
* LOCAL CLASSES: Definition
*===============================================================
* class lcl_event_receiver: local class to handle event DOUBLE_CLICK
* and CLOSE.
* Definition:
* ~~~~~~~~~~~
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,
handle_close
for event close of cl_gui_dialogbox_container
importing sender.
private section.
data: dialogbox_status type c. "'X': does exist, SPACE: does not ex.
endclass.
* lcl_event_receiver (Definition)
*===============================================================
* LOCAL CLASSES: Implementation
*===============================================================
* class c_event_receiver (Implementation)
* In this example, only event DOUBLE_CLICK is caught
class lcl_event_receiver implementation.
* §3.At doubleclick(1): The event DOUBLE_CLICK provides
* parameters of the clicked row and column.
* Use row parameter to select a line of the
* corresponding internal table.
method handle_double_click.
data: ls_sflight like line of gt_sflight.
* read selected row from internal table gt_sflight
read table gt_sflight index e_row-index into ls_sflight.
* §4.At Doubleclick(2): Select booking data
perform select_table_sbook using ls_sflight
changing gt_sbook.
* §5.At doubleclick(3): Create dialogbox to show detail list
* (if not already existent)
if dialogbox_status is initial.
dialogbox_status = 'X'.
perform create_detail_list.
else.
call method dialogbox_container->set_visible
exporting visible = 'X'.
call method grid2->refresh_table_display.
endif.
endmethod.
method handle_close.
* §6.Handle the CLOSE-button of the dialogbox
* set dialogbox invisible
* (the dialogbox is destroyed outomatically when the user
* switches to another dynpro).
call method sender->set_visible
exporting visible = space.
* In this example closing the dialogbox leads
* to make it invisible. It is also conceivable to destroy it
* and recreate it if the user doubleclicks a line again.
* Displaying a great amount of data has a greater impact on performance.
endmethod.
endclass.
* lcl_event_receiver (Implementation)
*===================================================================
* FORM EXIT_PROGRAM *
form exit_program.
call method custom_container->free.
call method cl_gui_cfw=>flush.
if sy-subrc ne 0.
* add your handling, for example
call function 'POPUP_TO_INFORM'
exporting
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error in FLush'(500).
endif.
leave program.
endform.
*& Module PBO_100 OUTPUT
* text
module pbo_100 output.
set pf-status 'MAIN100'.
set titlebar 'MAIN100'.
g_repid = sy-repid.
* §1.Create one ALV Control that shows the first table.
if custom_container is initial.
* select data from table SFLIGHT
perform select_table_sflight changing gt_sflight.
* create a custom container control for our ALV Control
create object custom_container
exporting
container_name = cont_for_flights
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
if sy-subrc ne 0.
* add your handling, for example
call function 'POPUP_TO_INFORM'
exporting
titel = g_repid
txt2 = sy-subrc
txt1 = 'The control could not be created'(510).
endif.
* create an instance of alv control
create object grid1
exporting i_parent = custom_container.
* Set a titlebar for the grid control
gs_layout-grid_title = 'Flights'(100).
call method grid1->set_table_for_first_display
exporting i_structure_name = 'SFLIGHT'
is_layout = gs_layout
changing it_outtab = gt_sflight.
* ->Create Object to receive events and link them to handler methods.
* When the ALV Control raises the event for the specified instance
* the corresponding method is automatically called.
create object event_receiver.
set handler event_receiver->handle_double_click for grid1.
endif. "IF custom_container IS INITIAL
call method cl_gui_control=>set_focus exporting control = grid1.
* Control Framework flushes at the end of PBO automatically!
endmodule. " PBO_100 OUTPUT
*& Module PAI_100 INPUT
* text
module pai_100 input.
save_ok = ok_code.
case save_ok.
when 'BACK'.
perform exit_program.
when 'EXIT'.
perform exit_program.
endcase.
clear save_ok.
endmodule. " PAI_100 INPUT
*& Form SELECT_TABLE_SFLIGHT
* text
* <--P_GT_SFLIGHT text
form select_table_sflight changing p_gt_sflight like gt_sflight[].
select * from sflight into table p_gt_sflight up to g_max rows.
endform. " SELECT_TABLE_SFLIGHT
*& Form SELECT_TABLE_SBOOK
* text
* -->P_LS_SFLIGHT text
* <--P_GT_SBOOK text
form select_table_sbook using p_ls_sflight like line of gt_sflight
changing p_gt_sbook like gt_sbook[].
select * from sbook into table p_gt_sbook
where carrid = p_ls_sflight-carrid
and connid = p_ls_sflight-connid
and fldate = p_ls_sflight-fldate.
endform. " SELECT_TABLE_SBOOK
*& Form create_detail_list
* text
* --> p1 text
* <-- p2 text
form create_detail_list.
* create dialogbox container as dynpro-instance
* When the user switches to another screen, it is
* destroyed by lifetime mangagement of CFW
create object dialogbox_container
exporting
top = 150
left = 150
lifetime = cntl_lifetime_dynpro
caption = 'Bookings'(200)
width = 800
height = 200.
create object grid2
exporting i_parent = dialogbox_container.
* Register ABAP OO event 'CLOSE'. It is not necessary to register this
* event at the frontend (this is done during creation).
set handler event_receiver->handle_close for dialogbox_container.
* display data
gs_layout-grid_title = space.
call method grid2->set_table_for_first_display
exporting i_structure_name = 'SBOOK'
is_layout = gs_layout
changing it_outtab = gt_sbook.
call method cl_gui_control=>set_focus exporting control = grid2.
endform.
Regards,
Nandha -
Single click in ALV Grid display
Hi All,
I need to trigger an event at the instant when a whole row is selected in ALV.
Not any HOTSPOT.
Is there any SY-UCOMM when a single row will be selected in ALV?
Thanks in advance,
TabraizHi,
In the below function module:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
i_callback_pf_status_set = 'PF_STATUS'
i_callback_user_command = 'COMM' -->this statement is used to catch the user command actions , i.e a subroutine will be created of this name
i_callback_top_of_page = 'TOP'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
i_grid_title = it_grid_title
I_GRID_SETTINGS =
is_layout = it_layout
it_fieldcat = it_field
it_excluding = itab_exclude
IT_SPECIAL_GROUPS =
it_sort = itab_sort
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = ''
I_SAVE = 'A'
IS_VARIANT = SVARIANT
it_events = itab_events
-->The subroutine created is like:
FORM comm USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
DATA: okcode TYPE sy-ucomm.
okcode = ucomm.
CASE okcode.
WHEN 'REF'.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = 'MANSI'
txt1 = 'CREATED BY'
txt2 = SY-UNAME
TXT3 = ' '
TXT4 = ' '
endcase.
Hope it helps you
Regrds
Mansi -
Handle single click event in ALV OOPS
Hi,
I have to display 2 ALV grid...one above the other.
Top ALV will contain Header info and bottom ALV witll display line item.
I am use ALV OOPS.
Now when user will click on the top ALV ...bottom ALV should show corresponding data.
I don't have to use HOTSPOT or Double click event.
How can I handle single click event.
Please guide me..thanks in advance
Regards,
Prasoonhi,
for this in ALV OOPS take <b>2 custom containers( cl_gui_custom_container)</b>in the same screen and on the 1st container display the header data<b>(use set_tale_for_first_display method of class cl_gui_alv_grid)</b>.
On the 2nd screen item data for this use<b> EVENT</b> handling(you want <b>single click</b>). use<b> hotspot_click</b> or <b>button_click </b>events.
for this you have to register the events. the code for that.
<b>CLASS lcl_event_handler DEFINITION .</b>
PUBLIC SECTION .
METHODS:
*--Hotspot click control
handle_hotspot_click
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id e_column_id es_row_no ,
*--To control button clicks
handle_button_click
FOR EVENT button_click OF cl_gui_alv_grid
IMPORTING e_oject e_ucomm .
PRIVATE SECTION.
ENDCLASS.
<b>CLASS lcl_event_handlerIMPLEMENTATION .</b>
*--Handle Hotspot Click
METHOD handle_hotspot_click .
PERFORM handle_hotspot_click USING e_row_id e_column_id es_row_no .
ENDMETHOD .
METHOD handle_button_click .
PERFORM handle_button_click USING e_object e_ucomm .
ENDMETHOD .
ENDCLASS .
DATA gr_event_handler TYPE REF TO lcl_event_handler .
<b>*--Creating an instance for the event handler</b>
CREATE OBJECT gr_event_handler.
<b>*--Registering handler methods to handle ALV Grid events</b>
SET HANDLER gr_event_handler->handle_hotspot_click FOR gr_alvgrid .
SET HANDLER gr_event_handler->handle_button_click FOR gr_alvgrid .
do n't forget to use<b> refresh_table_display
</b> other wise only the record which you first you clicked will display in the 2nd container.
<b>Reward points for useful Answers</b> -
Enabling screen for single click in OOABAP alvs
Hello All,
I have a requirement where I am displaying ALV grid in screen 100. In this grid I have defined double click event in which I call 101 screen (with coordinates i.e. starting at 10 10) which displays another grid. The problem here is that in screen 101 the buttons and screen fields are not responding to single click. I mean that for every action (change the cell value in 101 screen ot selecting a row or clicking on pushbutton in this 101 screen) I have to click twice. But I want all this actions to be performed with single click. If anyone knows the solution to know please let me know.
Note: <b>Helpful answers will be duly rewarded.</b>Please do not make duplicate postings.
Rob -
Single click event in alv grid.
Hi Experts,
i have done will my code..everything is working perfectly, but having an issue..pls help me...
in my output screen i have 2 check-boxes,when i select both of them i shuld get a message saying select only one..this is done when am using double click. Is single click possible in alv-grid...
please help me.
thanks.
anushaHi Anusha,
Did you Try by using get_selected_rows(Method)?
If the selected rows are 2 display a message such that 'Select only One record'.
data t_roid type lvc_t_roid.
CALL METHOD r_grid->get_selected_rows
IMPORTING
et_row_no = t_roid.
READ TABLE t_roid INDEX 1 TRANSPORTING NO FIELDS."to know how many No.Of records selected
if sy-tfill > 1.
Message 'Please Select only one record' type 'I'.
Exit.
endif. -
Hi all ,
In the code below ,
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
DATA: L_TA TYPE SY-TCODE VALUE 'SLIS_DUMMY'.
CASE R_UCOMM.
WHEN 'WAHL'. "menubutton
READ TABLE GT_OUTTAB INDEX RS_SELFIELD-TABINDEX. "cursorposit.
IF SY-SUBRC = 0.
SUBMIT SLIS_DUMMY WITH P_CARRID EQ GT_OUTTAB-CARRID
WITH P_CONNID EQ GT_OUTTAB-CONNID.
ENDIF.
CLEAR R_UCOMM.
WHEN '&IC1'. "doubleclick
READ TABLE GT_OUTTAB INTO GT_OUTTAB INDEX RS_SELFIELD-TABINDEX.
IF SY-SUBRC = 0.
SUBMIT SLIS_DUMMY WITH P_CARRID EQ GT_OUTTAB-CARRID
WITH P_CONNID EQ GT_OUTTAB-CONNID.
ENDIF.
CLEAR R_UCOMM.
ENDCASE.
ENDFORM.
this ( WHEN 'WAHL'.) is for "menubutton click.
& this ('&IC1'.) is for "doubleclick.
Anyone have any idea what should be the return command for single click in grid ?Hi Manish,
here a short examle:
REPORT ZGRO_TEST MESSAGE-ID ZZ NO STANDARD PAGE HEADING.
TABLES: VBAK.
TYPE-POOLS: SLIS.
INCLUDE <ICON>.
DATA: PROGNAME LIKE SY-REPID,
FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
EVENT_EXIT TYPE SLIS_T_EVENT_EXIT,
EVENTS TYPE SLIS_T_EVENT.
DATA: BEGIN OF ITAB OCCURS 0,
VBELN LIKE VBAK-VBELN,
KUNNR LIKE VBAK-KUNNR,
ICON LIKE ICONS-L4 VALUE ICON_OKAY,
END OF ITAB.
START-OF-SELECTION.
SELECT * FROM VBAK UP TO 100 ROWS.
ITAB-VBELN = VBAK-VBELN.
ITAB-KUNNR = VBAK-KUNNR.
APPEND ITAB.
ENDSELECT.
PERFORM AUSGABE_ALV_GRID.
END-OF-SELECTION.
FORM AUSGABE_ALV_GRID.
PROGNAME = SY-REPID.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = PROGNAME
I_INTERNAL_TABNAME = 'ITAB'
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = PROGNAME
CHANGING
CT_FIELDCAT = FIELDCAT.
PERFORM SPALTENEIGENSCHAFTEN USING FIELDCAT.
DATA: WA_EVENT_EXIT TYPE SLIS_EVENT_EXIT.
MOVE: '&IC1' TO WA_EVENT_EXIT-UCOMM,
'X' TO WA_EVENT_EXIT-BEFORE.
APPEND WA_EVENT_EXIT TO EVENT_EXIT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = PROGNAME
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = FIELDCAT
IT_EVENT_EXIT = EVENT_EXIT
TABLES
T_OUTTAB = ITAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM.
FORM SPALTENEIGENSCHAFTEN USING P_FIELDCAT
TYPE SLIS_T_FIELDCAT_ALV.
DATA: WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
LOOP AT P_FIELDCAT INTO WA_FIELDCAT.
CASE WA_FIELDCAT-FIELDNAME.
WHEN 'ICON'.
MOVE 'X' TO WA_FIELDCAT-HOTSPOT.
MOVE 'X' TO WA_FIELDCAT-ICON.
ENDCASE.
MODIFY P_FIELDCAT INDEX SY-TABIX FROM WA_FIELDCAT .
ENDLOOP.
ENDFORM.
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
READ TABLE ITAB INDEX RS_SELFIELD-TABINDEX.
IF R_UCOMM EQ '&IC1'.
SET PARAMETER ID 'AUN' FIELD itab-VBELN.
CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
ENDIF.
ENDFORM.
Have a nice weekend,
Regards, Dieter -
How to trigger single click event in ALV
Hi Experts,
I am trying to raise an event in a module pool program whereby an event will be triggered on a single click of a particular row in the ALV.
My requirement is that in the table display , which is being handled OO method, once the user clicks on a particular row - the details of the row should be displayed in another part of the screen.
I have used hotspots and done this - but I do not want all my entries underlined.Hi Atish,
Is there any other way to trigger the single click event in the ALV grid display for a particular row ? I have come across an event CLICK_ROW_COL, which I think may solve the problem, however this is a protected event and whenever I try to access it , I get the error that a protected event cannot be accessed.
Edited by: Aditya Niyogi on May 14, 2008 6:33 AM -
How to handle check box click in ALV grid
Hi Experts,
I use ALV grid using FM.
I have list of delivery note items with one custom field as check-box. When I check the checkbox, all other lines related to the same delivery note should be automaticaly checked.
Is there any event or function code, where I can handle single click to checkbox?
Thanks®ards,
JirkaHI
you can use following code in user command function .
DATA :BEGIN OF IT_MAINDATA OCCURS 0,
MAINDATA(1),
IT_RD1(1),
END OF IT_MAINDATA.
data: V_INDEX TYPE I.
DESCRIBE TABLE itab LINES LINE.
DO. " line times.
READ LINE SY-INDEX FIELD VALUE Iitab-RD1.
IF SY-SUBRC NE 0. EXIT. ENDIF.
CHECK V_INDEX > 0.
CHECK itab-RD1 = 'X'.
MODIFY itab INDEX V_INDEX.
IT_MAINDATA-IT_RD1 = Iitab-RD1.
ENDDO.
i think is work.
regards,
Abhi -
Single click on tree control navigation
Hello I have a tree control where I have include the navigation, I know that there is a method
HANDLE_NODE_DOUBLE_CLICK FOR G_TREE
but is there an method for only one click, I want to change my alv grid data when I click on several nodes in my tree controlHello Muhammet
I have re-written my sample report ZUS_SDN_TWO_ALV_GRIDS into ZUS_SDN_TREE_AND_GRID_CONTROL which is now display a tree control together with the ALV grid.
When you analyze this new report you will see that every step of the program logic is as I described in my previous e-mails.
*& Report ZUS_SDN_TWO_ALV_GRIDS
*& Screen '0100' contains no elements.
*& ok_code -> assigned to GD_OKCODE
*& Flow logic:
* PROCESS BEFORE OUTPUT.
* MODULE STATUS_0100.
* PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0100.
*& Thread: single click on tree control navigation
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1143770"></a>
REPORT zus_sdn_tree_and_grid_control.
TYPE-POOLS: abap, cntl.
TYPES: node_table_type LIKE STANDARD TABLE OF mtreesnode
WITH DEFAULT KEY.
* CAUTION: MTREESNODE is the name of the node structure which must
* be defined by the programmer. DO NOT USE MTREESNODE!
CONSTANTS:
BEGIN OF c_nodekey,
root TYPE tv_nodekey VALUE 'Root', "#EC NOTEXT
child1 TYPE tv_nodekey VALUE 'Child1', "#EC NOTEXT
* child2 type tv_nodekey value 'Child2', "#EC NOTEXT
new1 TYPE tv_nodekey VALUE 'New1', "#EC NOTEXT
new2 TYPE tv_nodekey VALUE 'New2', "#EC NOTEXT
* new3 type tv_nodekey value 'New3', "#EC NOTEXT
* new4 type tv_nodekey value 'New4', "#EC NOTEXT
END OF c_nodekey.
DATA:
gd_okcode TYPE ui_func,
gd_repid TYPE syst-repid,
go_docking TYPE REF TO cl_gui_docking_container,
go_splitter TYPE REF TO cl_gui_splitter_container,
go_cell_left TYPE REF TO cl_gui_container,
go_cell_right TYPE REF TO cl_gui_container,
go_tree TYPE REF TO cl_gui_simple_tree,
go_grid1 TYPE REF TO cl_gui_alv_grid,
** go_grid2 TYPE REF TO cl_gui_alv_grid,
gs_layout TYPE lvc_s_layo.
DATA:
gt_knb1 TYPE STANDARD TABLE OF knb1,
gt_knvv TYPE STANDARD TABLE OF knvv.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING
e_row
e_column
es_row_no
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_double_click.
* define local data
DATA:
ls_knb1 TYPE knb1.
CHECK ( sender = go_grid1 ).
READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row-index.
CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
** CALL METHOD go_grid1->set_current_cell_via_id
** EXPORTING
*** IS_ROW_ID =
*** IS_COLUMN_ID =
** is_row_no = es_row_no.
* Triggers PAI of the dynpro with the specified ok-code
CALL METHOD cl_gui_cfw=>set_new_ok_code( 'DETAIL' ).
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
* CLASS LCL_APPLICATION DEFINITION
CLASS lcl_application DEFINITION.
PUBLIC SECTION.
CLASS-DATA:
md_event TYPE string READ-ONLY,
md_node_key TYPE tv_nodekey READ-ONLY.
CLASS-METHODS:
handle_node_double_click
FOR EVENT node_double_click
OF cl_gui_simple_tree
IMPORTING node_key,
handle_expand_no_children
FOR EVENT expand_no_children
OF cl_gui_simple_tree
IMPORTING node_key.
ENDCLASS. "LCL_APPLICATION DEFINITION
* CLASS LCL_APPLICATION IMPLEMENTATION
CLASS lcl_application IMPLEMENTATION.
METHOD handle_node_double_click.
" this method handles the node double click event of the tree
" control instance
" show the key of the double clicked node in a dynpro field
md_event = 'NODE_DOUBLE_CLICK'.
md_node_key = node_key.
" Trigger PAI and set ok-code = 'DETAIL'
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'DETAIL'
* IMPORTING
* rc =
MESSAGE md_node_key TYPE 'I'.
ENDMETHOD. "HANDLE_NODE_DOUBLE_CLICK
METHOD handle_expand_no_children.
" this method handles the expand no children event of the tree
" control instance
DATA: node_table TYPE node_table_type,
node TYPE mtreesnode.
" show the key of the double clicked node in a dynpro field
md_event = 'EXPAND_NO_CHILDREN'.
md_node_key = node_key.
IF node_key = 'Child1'.
* add two nodes to the tree control (the children of 'Child1')
* Node with key 'New1'
CLEAR node.
node-node_key = c_nodekey-new1.
node-relatkey = c_nodekey-child1.
node-relatship = cl_gui_simple_tree=>relat_last_child.
node-isfolder = ' '.
node-text = 'New1'(ne1).
APPEND node TO node_table.
* Node with key 'New2'
CLEAR node.
node-node_key = c_nodekey-new2.
node-relatkey = c_nodekey-child1.
node-relatship = cl_gui_simple_tree=>relat_last_child.
node-n_image = '@10@'.
node-expander = ' '.
node-text = 'New2'(ne2).
APPEND node TO node_table.
CALL METHOD go_tree->add_nodes
EXPORTING
table_structure_name = 'MTREESNODE'
node_table = node_table
EXCEPTIONS
failed = 1
error_in_node_table = 2
dp_error = 3
table_structure_name_not_found = 4
OTHERS = 5.
IF sy-subrc <> 0.
** MESSAGE A000.
ENDIF.
ENDIF.
ENDMETHOD. "HANDLE_EXPAND_NO_CHILDREN
ENDCLASS. "LCL_APPLICATION IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1 UP TO 100 ROWS
WHERE bukrs = '1000'.
PERFORM init_controls.
* Display data
gs_layout-grid_title = 'Customers: Sales Areas'.
CALL METHOD go_grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'KNVV'
is_layout = gs_layout
CHANGING
it_outtab = gt_knvv
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
gd_repid = syst-repid.
CALL METHOD go_docking->link
EXPORTING
repid = gd_repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* NOTE: dynpro does not contain any elements
CALL SCREEN '0100'.
* Flow logic of dynpro (does not contain any dynpro elements):
*PROCESS BEFORE OUTPUT.
* MODULE STATUS_0100.
*PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0100.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'. " contains push button "DETAIL"
* SET TITLEBAR 'xxx'.
* Refresh display of detail ALV list
CALL METHOD go_grid1->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
EXCEPTIONS
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
TRANSLATE gd_okcode TO UPPER CASE.
CASE gd_okcode.
WHEN 'BACK' OR
'END' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
* User has pushed button "Display Details"
WHEN 'DETAIL'.
MESSAGE gd_okcode TYPE 'I'.
PERFORM entry_show_details.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form ENTRY_SHOW_DETAILS
* text
* --> p1 text
* <-- p2 text
FORM entry_show_details .
* define local data
DATA:
ld_row TYPE i,
ls_knb1 TYPE knb1.
IF ( gt_knvv IS INITIAL ).
SELECT * FROM knvv INTO TABLE gt_knvv
FOR ALL ENTRIES IN gt_knb1
WHERE kunnr = gt_knb1-kunnr.
ELSE.
REFRESH: gt_knvv.
ENDIF.
ENDFORM. " ENTRY_SHOW_DETAILS
*& Form INIT_CONTROLS
* text
* --> p1 text
* <-- p2 text
FORM init_controls .
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Create splitter container
CREATE OBJECT go_splitter
EXPORTING
parent = go_docking
rows = 1
columns = 2
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Get cell container
CALL METHOD go_splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = go_cell_left.
CALL METHOD go_splitter->get_container
EXPORTING
row = 1
column = 2
RECEIVING
container = go_cell_right.
* Create ALV grids
CREATE OBJECT go_grid1
EXPORTING
i_parent = go_cell_right
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_double_click FOR go_grid1.
PERFORM create_and_init_tree.
ENDFORM. " INIT_CONTROLS
*& Form CREATE_AND_INIT_TREE
* text
* --> p1 text
* <-- p2 text
FORM create_and_init_tree .
DATA: lt_node_table TYPE node_table_type,
lt_events TYPE cntl_simple_events,
ls_event TYPE cntl_simple_event.
* create a tree control
CREATE OBJECT go_tree
EXPORTING
parent = go_cell_left
node_selection_mode = cl_gui_simple_tree=>node_sel_mode_single " single node selection is used
EXCEPTIONS
lifetime_error = 1
cntl_system_error = 2
create_error = 3
failed = 4
illegal_node_selection_mode = 5.
IF sy-subrc <> 0.
** MESSAGE a000.
ENDIF.
* define the events which will be passed to the backend
" node double click
ls_event-eventid = cl_gui_simple_tree=>eventid_node_double_click.
** ls_event-appl_event = 'X'. " process PAI if event occurs
" NOTE: Do NOT register as application event !!!!!
APPEND ls_event TO lt_events.
CALL METHOD go_tree->set_registered_events
EXPORTING
events = lt_events
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3.
IF sy-subrc <> 0.
** MESSAGE a000.
ENDIF.
SET HANDLER:
lcl_application=>handle_node_double_click FOR go_tree,
lcl_application=>handle_expand_no_children FOR go_tree.
* add some nodes to the tree control
* NOTE: the tree control does not store data at the backend. If an
* application wants to access tree data later, it must store the
* tree data itself.
PERFORM build_node_table USING lt_node_table.
* node_table_structure_name = 'MTREESNODE'
* A programmer using the tree control must create a structure in the
* dictionary. This structure must include the structure TREEV_NODE
* and must contain a character field with the name 'TEXT'.
CALL METHOD go_tree->add_nodes
EXPORTING
table_structure_name = 'MTREESNODE'
node_table = lt_node_table
EXCEPTIONS
failed = 1
error_in_node_table = 2
dp_error = 3
table_structure_name_not_found = 4
OTHERS = 5.
IF sy-subrc <> 0.
** MESSAGE a000.
ENDIF.
ENDFORM. " CREATE_AND_INIT_TREE
*& Form build_node_table
* text
* --> p1 text
* <-- p2 text
FORM build_node_table
USING
node_table TYPE node_table_type.
DATA: node LIKE mtreesnode.
* Build the node table.
* Caution: The nodes are inserted into the tree according to the order
* in which they occur in the table. In consequence, a node must not
* occur in the node table before its parent node.
* Node with key 'Root'
node-node_key = c_nodekey-root.
" Key of the node
CLEAR node-relatkey. " Special case: A root node has no parent
CLEAR node-relatship. " node.
node-hidden = ' '. " The node is visible,
node-disabled = ' '. " selectable,
node-isfolder = 'X'. " a folder.
CLEAR node-n_image. " Folder-/ Leaf-Symbol in state "closed":
" use default.
CLEAR node-exp_image. " Folder-/ Leaf-Symbol in state "open":
" use default
CLEAR node-expander. " see below.
node-text = 'Root'(roo).
APPEND node TO node_table.
* Node with key 'Child1'
node-node_key = c_nodekey-child1.
" Key of the node
" Node is inserted as child of the node with key 'Root'.
node-relatkey = c_nodekey-root.
node-relatship = cl_gui_simple_tree=>relat_last_child.
node-hidden = ' '.
node-disabled = ' '.
node-isfolder = 'X'.
CLEAR node-n_image.
CLEAR node-exp_image.
node-expander = 'X'. " The node is marked with a '+', although
" it has no children. When the user clicks on the
" + to open the node, the event
" expand_no_children is fired. The programmer can
" add the children of the
" node within the event handler of the
" expand_no_children event
" (see method handle_expand_no_children
" of class lcl_application)
node-text = 'Child1'(ch1).
node-style = cl_gui_simple_tree=>style_emphasized_positive.
APPEND node TO node_table.
ENDFORM. " build_node_table
Regards
Uwe -
hi,
can any1 pls explain me the single click event LINK_CLICK in abap object.
does this single click event mean that if i click anywhere on my alv report it will trigger the event.
pls explain me about this LINK_CLICK event in details plsanswered the similar question last week. You can see here Event
Link_click or ALV_Object Model HYPERLINK.
This example demonstrates how to use a Hiperlink field in ALV. These example was based on 'SALV_DEMO_TABLE_COLUMNS' that contains Hiperlink, icon, Hotspot...
The Code is:
REPORT zsalv_mar NO STANDARD PAGE HEADING.
CLASS lcl_handle_events DEFINITION
CLASS lcl_handle_events DEFINITION.
PUBLIC SECTION.
METHODS:
on_link_click FOR EVENT link_click OF cl_salv_events_table
IMPORTING row column.
ENDCLASS. "lcl_handle_events DEFINITION
CLASS lcl_handle_events IMPLEMENTATION
CLASS lcl_handle_events IMPLEMENTATION.
METHOD on_link_click.
DATA: l_row_string TYPE string,
l_col_string TYPE string,
l_row TYPE char128.
WRITE row TO l_row LEFT-JUSTIFIED.
CONCATENATE text-i02 l_row INTO l_row_string SEPARATED BY space.
CONCATENATE text-i03 column INTO l_col_string SEPARATED BY space.
MESSAGE i000(0k) WITH 'Single Click' l_row_string l_col_string.
ENDMETHOD. "on_single_click
ENDCLASS. "lcl_handle_events IMPLEMENTATION
DATA: gr_events TYPE REF TO lcl_handle_events.
TYPES: BEGIN OF g_type_s_outtab.
INCLUDE TYPE alv_tab.
TYPES: t_hyperlink TYPE salv_t_int4_column,
END OF g_type_s_outtab.
DATA: gt_outtab TYPE STANDARD TABLE OF g_type_s_outtab.
DATA: gr_table TYPE REF TO cl_salv_table.
TYPES: BEGIN OF g_type_s_hyperlink,
handle TYPE salv_de_hyperlink_handle,
hyperlink TYPE service_rl,
carrid TYPE s_carrid,
END OF g_type_s_hyperlink.
DATA: gt_hyperlink TYPE STANDARD TABLE OF g_type_s_hyperlink.
SELECTION-SCREEN BEGIN OF BLOCK gen WITH FRAME.
PARAMETERS: p_amount TYPE i DEFAULT 30.
SELECTION-SCREEN END OF BLOCK gen.
START-OF-SELECTION.
PERFORM select_data.
PERFORM display.
*& Form select_data
text
--> p1 text
<-- p2 text
FORM select_data .
DATA: line_outtab TYPE g_type_s_outtab,
ls_hype TYPE g_type_s_hyperlink,
lt_hyperlink TYPE salv_t_int4_column,
ls_hyperlink TYPE salv_s_int4_column,
v_tabix TYPE sytabix.
SELECT *
FROM alv_tab
INTO CORRESPONDING FIELDS OF TABLE gt_outtab
UP TO p_amount ROWS.
LOOP AT gt_outtab INTO line_outtab.
v_tabix = sy-tabix.
ls_hype-handle = sy-tabix.
ls_hype-hyperlink = line_outtab-url.
ls_hype-carrid = line_outtab-carrid.
INSERT ls_hype INTO TABLE gt_hyperlink.
ls_hyperlink-columnname = 'URL'.
ls_hyperlink-value = sy-tabix.
APPEND ls_hyperlink TO lt_hyperlink.
line_outtab-t_hyperlink = lt_hyperlink.
MODIFY gt_outtab FROM line_outtab INDEX v_tabix.
CLEAR line_outtab.
CLEAR lt_hyperlink.
CLEAR ls_hyperlink.
ENDLOOP.
ENDFORM. " select_data
*& Form display
text
--> p1 text
<-- p2 text
FORM display .
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = gt_outtab ).
CATCH cx_salv_msg. "#EC NO_HANDLER
ENDTRY.
DATA: lr_functions TYPE REF TO cl_salv_functions_list.
lr_functions = gr_table->get_functions( ).
lr_functions->set_default( abap_true ).
*... set the columns technical
DATA: lr_columns TYPE REF TO cl_salv_columns_table,
lr_column TYPE REF TO cl_salv_column_table.
lr_columns = gr_table->get_columns( ).
lr_columns->set_optimize( abap_true ).
*... §4.7 set hyperlink column
DATA: lr_hyperlinks TYPE REF TO cl_salv_hyperlinks,
ls_hyperlink TYPE g_type_s_hyperlink.
DATA: lr_functional_settings TYPE REF TO cl_salv_functional_settings.
TRY.
lr_columns->set_hyperlink_entry_column( 'T_HYPERLINK' ).
CATCH cx_salv_data_error. "#EC NO_HANDLER
ENDTRY.
TRY.
lr_column ?= lr_columns->get_column( 'URL' ).
lr_column->set_cell_type( if_salv_c_cell_type=>link ).
lr_column->set_long_text( 'URL' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
lr_functional_settings = gr_table->get_functional_settings( ).
lr_hyperlinks = lr_functional_settings->get_hyperlinks( ).
LOOP AT gt_hyperlink INTO ls_hyperlink.
TRY.
lr_hyperlinks->add_hyperlink(
handle = ls_hyperlink-handle
hyperlink = ls_hyperlink-hyperlink ).
CATCH cx_salv_existing. "#EC NO_HANDLER
ENDTRY.
ENDLOOP.
DATA: lr_events TYPE REF TO cl_salv_events_table.
lr_events = gr_table->get_event( ).
CREATE OBJECT gr_events.
SET HANDLER gr_events->on_link_click FOR lr_events.
gr_table->display( ).
ENDFORM. " display -
How do I execute Double click event in grid and list disaplay?
Hi
Kindly check the following threads:
Re: Double click event of alv grid control
double click on alv grid
Re: Using double click event in ALV Grid
you can find some code samples from the above links.
Hope this helps!
best regards,
Thangesh
Maybe you are looking for
-
How to share files from iCloud Drive
Hey guys! So here is the story: Up until now, I have been using MS OneDrive (formerly Sky Drive) to store files, images and videos. The very simple reason is because Facebook shreds the quality into pieces. So instead of sharing pictures and albums b
-
I just got a 2g 32 gig ipod touch, the wi fi worked fine for the first day then I updated the software to the 2.2 version and now whenever I connect my ipod to my computer I get the error message "itunes cannot read the contents of the Ipod---. go to
-
Can't print to Canon IPF610 after upgrading to Mavericks. HELP!!
Since updateing to the OS 10.9 Mavericks, I am no longer able to print to my Canon IPF610 Large Format Printer. I tried upgrading the driver at the Canon website for the OS 10.9 but it's still not working.
-
Implementing Boolean operators during find object for qualification
Hi Team We would like to maintain requirements profiles for PD object (position,job etc.) in terms of qualifications (Q) using complicated boolean operators , for example : ((Q=English>4 OR (Q=French=5 and Q=Spanish>2)) OR (Q=German=6 and english<3)
-
I've tried to download my regularly purchased Logic Pro 9 from the Apple Store. Some time has passed since the last time I've used, but now I'd need to get it again. The store now says it's unavailable! Weird, less than a year has passed since then.