On-click on ALV sum line to raise an event
Hello, ladies and gentlemen,
Happy New Year first of all.
I have a following problem: I have an ALV grid and in each line I have an icon, which one can on-click and something happens. That works fine. But now I was challenged to add a sum line which should support the same on-click event, but should process the data of all lines that belong to this SUM group in one batch.
Of course I can put in the "manual sum lines" - define groups that will support these sum lines and then add extra lines into the grid data. Unfortunatelly there is no way of telling which lines will belong to which group. I need the ALV standard summing so any user can define his own groups.
Has anybody ever tried such thing? I am using cl_gui_alv_grid OO ALV.
Thanks for any input,
cheers Otto
Hi Otto.
You can check the logic below. Please try to disable the sort functionality as done below in the ALV because the subtotals returned by the method get_subtotals is always sorted in ascending order.
report z335_alv_sel.
class lcl definition deferred.
type-pools: slis.
types:begin of t_data,
werks type werks_d,
labst type mard-labst,
end of t_data.
data :i_exclude type ui_functions,
i_fcat type slis_t_fieldcat_alv ,
i_sort type lvc_t_sort,
i_data type table of t_data,
i_cat type lvc_t_fcat,
wa_sort like line of i_sort,
wa_exclude type ui_func,
wa type t_data,
wa_cat type lvc_s_fcat,
cont type ref to cl_gui_custom_container,
grid type ref to cl_gui_alv_grid,
receiver type ref to lcl.
class lcl definition.
public section.
methods handle_click for event double_click of
cl_gui_alv_grid importing e_row
e_column.
endclass. "lcl DEFINITION
class lcl implementation.
method handle_click.
data:val(10) type n,
it type ref to data.
field-symbols: <ft_tab> type standard table,
<fs_tab> type any,
<ff_field> type any.
if e_row+0(1) = 'S'. "Subtotal
val = e_row+23(10).
call method grid->get_subtotals
importing
ep_collect01 = it.
assign it->* to <ft_tab>.
read table <ft_tab> assigning <fs_tab> index val.
if sy-subrc = 0.
assign component 1 of structure <fs_tab> to <ff_field>.
if <ff_field> is assigned.
loop at i_data into wa where werks = <ff_field>.
"Process your block Here
endloop.
endif.
endif.
endif.
endmethod. "handle_click
endclass. "lcl IMPLEMENTATION
start-of-selection.
call screen 100.
module fill_data output.
select werks labst from mard
into corresponding fields of table i_data
up to 1000 rows where labst > 0.
if sy-subrc = 0.
wa_cat-fieldname = 'WERKS'.
append wa_cat to i_cat.
clear wa_cat.
wa_cat-fieldname = 'LABST'.
wa_cat-do_sum = 'X'.
append wa_cat to i_cat.
clear wa_cat.
wa_sort-fieldname = 'WERKS'.
wa_sort-subtot = 'X'.
wa_sort-group = 'X'.
wa_sort-up = 'X'.
append wa_sort to i_sort.
wa_exclude = cl_gui_alv_grid=>mc_fc_sort .
append wa_exclude to i_exclude.
wa_exclude = cl_gui_alv_grid=>mc_fc_sort_asc .
append wa_exclude to i_exclude.
wa_exclude = cl_gui_alv_grid=>mc_fc_sort_dsc .
append wa_exclude to i_exclude.
endif.
endmodule. " fill_data OUTPUT
module display output.
if cont is initial .
create object cont
exporting
container_name = 'CONT1'.
create object grid
exporting
i_parent = cont.
call method grid->set_table_for_first_display
exporting
it_toolbar_excluding = i_exclude
changing
it_outtab = i_data[]
it_sort = i_sort[]
it_fieldcatalog = i_cat[].
create object receiver.
set handler receiver->handle_click for grid.
endif.
endmodule. "DISPLAY OUTPUT
Similar Messages
-
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 -
Hi,
I have this doubt regarding ALV grid display.
I am displaying a list using REUSE_ALV_GRID_DISPLAY.
I need to go to a transaction when i double click on a particular line on the output list based on the content of the 1st cell of that line. (ie if i have 4 columns and 5 records and click on the 3rd column of 2nd record then i need to know the value of the 1st field of the 2nd record)
I am using a call back user command subroutine to capture the index and the field which has been clicked upon. This index is giving perfect result by which I am reading the output table and doing the later operations.
But what if i sort the list in ALV by any column? Then the index that I will get on double clicking will correspond to the index on the screen but not to the index on my internal output table. In that case I will get a wrong value of the 1st field.
I do not want to use OO alv. Is there a way to handle this situation?
Regards,
ShinjanHello Shinjan,
When i display an output table say t_out on ALV GRID, the records in the table shown on the grid is identical to what i have in t_out. Hence the tabindex will correspond to that very record in t_out.
But when i sort the table on the grid, the order of the rows changes... so for example a row which had index 2 will now have an index 6 (say). So on clicking this record, the tabindex will be 6 where as the same record exist in 2nd position in t_out. How to handle this?
{quote]
Did you try this scenario? Your output table t_out also gets refarranged after SORT. Good thing is you DONOT have to code anything for this )
As per your example the table t_out will be rearranged so that the initial 2nd record will be at 6th posn.
FORM f_user_command USING fp_v_ucomm TYPE syucomm
fp_selfield TYPE slis_selfield."#EC CALLED
CONSTANTS:
l_c_ic1 TYPE char4 VALUE '&IC1',
l_c_vl TYPE char2 VALUE 'VL',
l_c_vl03n TYPE char5 VALUE 'VL03N'.
CASE fp_v_ucomm.
* Ok code for double code
WHEN l_c_ic1.
IF fp_selfield-tabindex NE space.
READ TABLE it_final INTO wa_final "it_final gets rearranged as per the SORT condition
INDEX fp_selfield-tabindex. "tabindex keeps the correct index after SORT
SET PARAMETER ID l_c_vl FIELD wa_final-vbeln.
CALL TRANSACTION l_c_vl03n AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM. "f_user_command
Please check & let us know.
BR,
Suhas
Edited by: Suhas Saha on Jan 2, 2009 11:48 AM
Edited by: Suhas Saha on Jan 2, 2009 11:53 AM -
Hi
Can u tell me how to handle double click in alv?
Thanks and Regards
AnishDo you mean interactive Alv? is its that. check this out.
REPORT ZALV_OOINTERACTIVE.
*Class definition for handling double click
CLASS event_class DEFINITION DEFERRED.
*Internal table and work area declarations for dd02l and dd03l
DATA : it_dd02l TYPE TABLE OF dd02l,
wa_dd02l TYPE dd02l,
it_dd03l TYPE TABLE OF dd03l,
wa_dd03l TYPE dd03l.
*data declarations for ALV Main list
DATA : ty_lay1 TYPE lvc_s_layo,
it_fieldcat TYPE lvc_t_fcat ,
ty_fieldcat TYPE lvc_s_fcat ,
c_alv1 TYPE REF TO cl_gui_alv_grid,
c_cont1 TYPE REF TO cl_gui_custom_container,
event_receiver TYPE REF TO event_class.
*data declarations for ALV Interactive list
DATA : ty_lay2 TYPE lvc_s_layo,
it_fcat TYPE lvc_t_fcat ,
ty_fcat TYPE lvc_s_fcat ,
c_alv2 TYPE REF TO cl_gui_alv_grid,
c_cont2 TYPE REF TO cl_gui_custom_container.
**Select options for multiple values and NOT ranges
SELECT-OPTIONS : s_table FOR wa_dd02l-tabname NO INTERVALS.
Initialization event
INITIALIZATION.
*Start of selection event
START-OF-SELECTION.
*fetch data into table and field characteristics
PERFORM fetch_data.
*ALV display for output
PERFORM alv_output.
*& Form FETCH_DATA
text
--> p1 text
<-- p2 text
FORM fetch_data .
*Select the table details
SELECT * FROM dd02l INTO CORRESPONDING FIELDS OF TABLE it_dd02l
WHERE tabname IN s_table
AND tabclass = 'TRANSP'.
ENDFORM. " FETCH_DATA
----* CLASS lcl_event_receiver DEFINITION*-------
CLASS event_class DEFINITION.
*Handling double click
PUBLIC SECTION. METHODS:
handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid IMPORTING e_row .
ENDCLASS. "lcl_event_receiver DEFINITION
----* CLASS lcl_event_receiver IMPLEMENTATION
CLASS event_class IMPLEMENTATION.
METHOD handle_double_click.
DATA : ls_dd02l LIKE LINE OF it_dd02l.
*Reading the selected data into a variable
READ TABLE it_dd02l INDEX e_row-index INTO ls_dd02l.
*Select the field details of the selected table
SELECT * FROM dd03l INTO CORRESPONDING FIELDS OF TABLE it_dd03l
WHERE tabname EQ ls_dd02l-tabname.
*calling the ALV containing the field values
CALL SCREEN 101.
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
& Module pbo_100 OUTPUT&----
MODULE pbo_100 OUTPUT.
*set pf-status 'XXX'.
*set titlebar 'XXX'.
ENDMODULE. " PBO_100 OUTPUT
*& Module alv_100 OUTPUT
MODULE alv_100 OUTPUT.
*Check if there is no custom container in screen 100
IF c_cont1 IS INITIAL.
*Creating object of container
CREATE OBJECT c_cont1
EXPORTING
container_name = 'CCONT'.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*Creating object of alv
CREATE OBJECT c_alv1
EXPORTING
i_parent = c_cont1.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*alv layout
PERFORM alv_100_layout.
*alv field catalogue
PERFORM alv_100_fieldcat.
*Displaying the ALV grid
CALL METHOD c_alv1->set_table_for_first_display
EXPORTING
is_layout = ty_lay1
CHANGING
it_outtab = it_dd02l[]
it_fieldcatalog = it_fieldcat.
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 object of the event class and setting handler for double click
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_double_click FOR c_alv1.
ENDIF.
ENDMODULE. " ALV_100 OUTPUT
&----& Module pai_100 INPUT&----
MODULE pai_100 INPUT.
ENDMODULE. " pai_100 INPUT
----* MODULE PBO_101 OUTPUT----MODULE pbo_101 OUTPUT.
SET PF-STATUS 'XXX'.
SET TITLEBAR 'XXX'.
ENDMODULE. " PBO_101 INPUT
----* MODULE ALV_101 OUTPUT*----
MODULE alv_101 OUTPUT.
*Check if the Custom container exists.
IF c_cont2 IS INITIAL.
*Creating container object
CREATE OBJECT c_cont2
EXPORTING
container_name = 'CDCONT'.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*creating ALV grid for interactive list
CREATE OBJECT c_alv2
EXPORTING
i_parent = c_cont2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*ALV layout
PERFORM alv_101_layout.
*ALV fieldcatalogue
PERFORM alv_101_fieldcat.
*Sorting the output by field position
SORT it_dd03l BY position.
*ALV for display field details
CALL METHOD c_alv2->set_table_for_first_display
EXPORTING
is_layout = ty_lay2
CHANGING
it_outtab = it_dd03l[]
it_fieldcatalog = it_fcat.
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. " ALV_101 OUTPUT
&----& Module PAI_101 INPUT&----
MODULE pai_101 INPUT.
ENDMODULE. " PAI_101 INPUT
*& Form ALV_OUTPUT
text
--> p1 text
<-- p2 text
FORM alv_output .
CALL SCREEN 100.
ENDFORM. " ALV_OUTPUT
*& Form ALV_100_LAYOUT
text
--> p1 text
<-- p2 text
FORM alv_100_layout .
ty_lay1-grid_title = 'TABLES'.
ty_lay1-zebra = 'X'.
ty_lay1-no_toolbar = 'X'.
ENDFORM. " ALV_100_LAYOUT
*& Form ALV_100_FIELDCAT
text
--> p1 text
<-- p2 text
FORM alv_100_fieldcat .
CLEAR ty_fieldcat.
ty_fieldcat-row_pos = 1.
ty_fieldcat-col_pos = 1.
ty_fieldcat-fieldname = 'TABNAME'.
ty_fieldcat-tabname = 'GT_DD02L'.
ty_fieldcat-coltext = 'TableName'.
ty_fieldcat-outputlen = 10.
APPEND ty_fieldcat TO it_fieldcat.
CLEAR ty_fieldcat.
ty_fieldcat-row_pos = 1.
ty_fieldcat-col_pos = 2.
ty_fieldcat-fieldname = 'TABCLASS'.
ty_fieldcat-tabname = 'GT_DD02L'.
ty_fieldcat-coltext = 'CATEGORY'.
ty_fieldcat-outputlen = 10.
APPEND ty_fieldcat TO it_fieldcat.
CLEAR ty_fieldcat.
ty_fieldcat-row_pos = 1.
ty_fieldcat-col_pos = 3.
ty_fieldcat-fieldname = 'AS4USER'.
ty_fieldcat-tabname = 'GT_DD02L'.
ty_fieldcat-coltext = 'CREATED'.
ty_fieldcat-outputlen = 10.
APPEND ty_fieldcat TO it_fieldcat.
CLEAR ty_fieldcat.
ty_fieldcat-row_pos = 1.
ty_fieldcat-col_pos = 4.
ty_fieldcat-fieldname = 'AS4DATE'.
ty_fieldcat-tabname = 'GT_DD02L'.
ty_fieldcat-coltext = 'DATE'.
ty_fieldcat-outputlen = 10.
APPEND ty_fieldcat TO it_fieldcat.
CLEAR ty_fieldcat.
ty_fieldcat-row_pos = 1.
ty_fieldcat-col_pos = 5.
ty_fieldcat-fieldname = 'AS4TIME'.
ty_fieldcat-tabname = 'GT_DD02L'.
ty_fieldcat-coltext = 'TIME'.
ty_fieldcat-outputlen = 10.
APPEND ty_fieldcat TO it_fieldcat.
CLEAR ty_fieldcat.
ty_fieldcat-row_pos = 1.
ty_fieldcat-col_pos = 6.
ty_fieldcat-fieldname = 'CONTFLAG'.
ty_fieldcat-tabname = 'GT_DD02L'.
ty_fieldcat-coltext = 'Delivery Class'.
ty_fieldcat-outputlen = 15.
APPEND ty_fieldcat TO it_fieldcat.
CLEAR ty_fieldcat.
ENDFORM. " ALV_100_FIELDCAT
*& Form ALV_101_LAYOUT
text
--> p1 text
<-- p2 text
FORM alv_101_layout .
ty_lay2-grid_title = 'FIELDS'.
ty_lay2-zebra = 'X'.
ty_lay2-no_toolbar = 'X'.
ENDFORM. " ALV_101_LAYOUT
*& Form ALV_101_FIELDCAT
text
--> p1 text
<-- p2 text
FORM alv_101_fieldcat .
REFRESH it_fieldcat.
REFRESH it_fcat.
CLEAR ty_fcat.
ty_fcat-row_pos = 1.
ty_fcat-col_pos = 1.
ty_fcat-fieldname = 'FIELDNAME'.
ty_fcat-tabname = 'GT_DD03L'.
ty_fcat-coltext = 'Fieldname'.
ty_fcat-outputlen = 10.
APPEND ty_fcat TO it_fcat.
ty_fcat-row_pos = 1.
ty_fcat-col_pos = 2.
ty_fcat-fieldname = 'CHECKTABLE'.
ty_fcat-tabname = 'GT_DD03L'.
ty_fcat-coltext = 'CHECKTABLE'.
ty_fcat-outputlen = 10.
APPEND ty_fcat TO it_fcat.
ty_fcat-row_pos = 1.
ty_fcat-col_pos = 3.
ty_fcat-fieldname = 'KEYFLAG'.
ty_fcat-tabname = 'GT_DD03L'.
ty_fcat-coltext = 'Key Flag'.
ty_fcat-outputlen = 10.
APPEND ty_fcat TO it_fcat.
ENDFORM. " ALV_101_FIELDCAT -
Calling a transaction code on click on alv
how do i call a transaction on mouse double click on alv grid.
thanks
chinmayaCan u please explain wid reef. to this code thnx
report ztst_chin_alv3.
tables : lfb1.
Declarations *
selection-screen begin of block a with frame title text-001.
select-options : bukrs for lfb1-bukrs.
select-options : lifnr for lfb1-lifnr.
selection-screen end of block a.
data: r_container type ref to cl_gui_custom_container.
data: r_grid type ref to cl_gui_alv_grid.
data: g_fieldcat type lvc_t_fcat.
data: w_fieldcat like line of g_fieldcat.
data: g_layout type lvc_s_layo.
data: ok_code like sy-ucomm.
data: gs_variant type disvariant.
data: t_selected type lvc_t_row.
data wa_selected like line of t_selected.
data: it_items like eban occurs 0.
data: it_sort type lvc_t_sort.
data: s_sort type lvc_s_sort.
data: h_test_alv type lvc_s_col.
data: begin of it_lfb1 occurs 0,
lifnr like lfb1-lifnr,
bukrs like lfb1-bukrs,
akont like lfb1-akont,
fdgrv like lfb1-fdgrv,
end of it_lfb1.
Initialization *
initialization.
at selection-screen.
ok_code = sy-ucomm.
case ok_code.
when 'BACK'.
leave program.
when 'CANCEL'.
leave program.
when 'EXIT'.
leave program.
when 'ONLI' or 'CRET'.
call screen 100.
when others.
endcase.
GetData *
module getdata output.
if sy-ucomm <> 'STOP'.
*refresh control container_1 from screen scr.
refresh it_lfb1.
clear bukrs.
clear lifnr.
select lifnr bukrs akont fdgrv
into corresponding fields of table it_lfb1
from lfb1
where
bukrs in bukrs
and lifnr in lifnr.
endif.
refresh bukrs.
refresh lifnr.
endmodule.
Create ALV *
module create_alv output.
gs_variant-report = sy-repid.
if r_container is initial.
create object r_container
exporting container_name = 'CONTAINER_1'.
create object r_grid
exporting i_parent = r_container.
endif.
*modify the headings in the field catalogue
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_structure_name = 'ztest_alv'
changing
ct_fieldcat = g_fieldcat[].
loop at g_fieldcat into w_fieldcat.
case w_fieldcat-fieldname.
when 'ZCURSTAT'.
w_fieldcat-scrtext_l = 'Prev.RelCode'.
w_fieldcat-scrtext_m = 'Prev.RelCode'.
w_fieldcat-scrtext_s = 'Prev.RelCode'.
w_fieldcat-reptext = 'Prev.RelCode'.
endcase.
modify g_fieldcat from w_fieldcat.
endloop.
call method r_grid->set_table_for_first_display
exporting
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
I_CONSISTENCY_CHECK =
i_structure_name = 'ztest_alv'
is_variant = gs_variant
i_save = 'A'
I_DEFAULT = 'X'
is_layout = g_layout
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
changing
it_outtab = it_lfb1[]
it_fieldcatalog = g_fieldcat[]
it_sort = it_sort[]
IT_FILTER =
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.
call method r_grid->set_table_for_first_display
exporting i_structure_name = 'ztest_alv'
is_layout = g_layout
is_variant = gs_variant
i_save = 'A'
changing it_outtab = it_lfb1[]
it_fieldcatalog = g_fieldcat[].
*ELSE.
CALL METHOD r_grid->refresh_table_display
EXPORTING i_soft_refresh = ' '.
endmodule.
STATUS *
module status output.
set pf-status '0100'.
endmodule.
User Commands *
module user_command input.
ok_code = sy-ucomm.
case ok_code.
when 'BACK'.
call screen '1000'.
when 'CANCEL'.
leave program.
when 'EXIT'.
leave program.
endcase.
endmodule.
ALV Layout *
module layout output.
g_layout-zebra = 'X'.
g_layout-sel_mode = 'A'.
g_layout-grid_title = ''.
g_layout-detailtitl = ''.
endmodule.
MODULE sort_itab *
module sort_itab output.
*break-point.
*data s_Sort type lvc_s_sort.
perform sort_itab.
endmodule.
FORM sort_itab *
form sort_itab.
s_sort-spos = '1'.
s_sort-fieldname = 'FDGRV'.
s_sort-up = 'X'.
append s_sort to it_sort.
clear s_sort.
endform.
Select Rows *
form get_selected_rows.
call method r_grid->get_selected_rows
importing et_index_rows = t_selected.
if t_selected is initial.
call function 'WS_MSG'
exporting
msg_type = 'E'
text = 'Select Line'
titl = 'Select Line'.
sy-ucomm = 'STOP'.
endif.
endform.
This is Test code.
*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.
*class lcl_event_receiver implementation.
method handle_double_click.
**endmethod.
*endclass. -
Problem in raising the event DATA_CHANGED in OOP ALV
Hi experts,
I am currently having trouble in raising the event 'data_changed' in my OOP ALV . The event is triggered everytime I make changes to my editable cells but when it comes to clicking on the save button, it only calls 'data_changed_finished' and bypasses 'data_changed'.
I need to call 'data_changed' before the data is saved to do some verification.
My code is shown below.
CALL METHOD gr_alvgrid->register_edit_event
EXPORTING i_event_id = cl_gui_alv_grid=>mc_evt_modified.
*--functions
CALL METHOD gr_alvgrid->set_table_for_first_display
EXPORTING
is_variant = s_variant
i_save = 'A'
i_default = gc_true
is_layout = gs_layout
it_toolbar_excluding = gt_exclude
CHANGING
it_outtab = gt_list
it_fieldcatalog = gt_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4 .
IF sy-subrc <> 0.
"raise message
ENDIF.
CREATE OBJECT gr_event.
SET HANDLER gr_event->handle_data_changed FOR gr_alvgrid.
SET HANDLER gr_event->handle_data_changed_finished FOR gr_alvgrid.
CALL METHOD gr_alvgrid->set_toolbar_interactive.
CALL METHOD gr_alvgrid->set_ready_for_input
EXPORTING i_ready_for_input = 1.
In my PAI
CASE ok_code.
WHEN 'SAVE'.
*--->this calls the event 'data_changed_finished' and bypasses 'data_changed'.*
*Check if there's data changed.
CALL METHOD gr_alvgrid->check_changed_data
IMPORTING
e_valid = l_valid.
ENDCASE.
I checked the sap sample program BCALV_EDIT_04 and I don't see any difference except for register_edit_event but I don't think that I can leave this out in my code . Is there any points i'm missing here?
Thanks,
PatrickHi, Spin
do like below,
DATA: gr_alvgrid TYPE REF TO cl_gui_alv_grid,
cc_alv TYPE REF TO cl_gui_custom_container.
IF cc_alv IS INITIAL. " USE This Condition
CREATE OBJECT cc_alv
EXPORTING
container_name = 'CC_ALV'.
CREATE OBJECT gr_alvgrid
EXPORTING
i_parent = cc_alv.
CALL METHOD gr_alvgrid->set_table_for_first_display
EXPORTING
is_variant = s_variant
i_save = 'A'
i_default = gc_true
is_layout = gs_layout
it_toolbar_excluding = gt_exclude
CHANGING
it_outtab = gt_list
it_fieldcatalog = gt_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc = 0.
"raise message
ENDIF.
ENDIF.
Please reply if any Issue,
Thanks and Regard,
Faisal -
When double clicking on alv ,want to get the column name
Hello there,
I'm displaying the value of internal table in an alv using Reuse_alv_grid_display method ,using fieldcatalog.I want to know the column name when double clicking on a particular line .If the the fieldname is 'MATNR' then i want to check that column name.
If anybody have any idea plz terply me.
Thanking you neonfor that you have to use the USER_COMMAND event.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = it_fcat
TABLES
t_outtab = itab
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.
FORM USER_COMMAND using ucomm type sy-ucomm
selfield type slis_selfield.
data: fieldname(30).
case ucomm.
when '&IC1'.
case selfield-fieldname.
when 'MATNR'.
message 'clicked on Matnr' type 'I'.
when 'POSNR'.
endcase.
endcase.
ENDFORM. -
ALV SUM for non numeric fields.
Hello Gurus,
I have a requirement where i have a alv output and i have a check field of char 1 length...and it displays X as the output. Now i need to have X at the sum line at the end.is there is any possibility with the fieldcatalogue.Hi
U can not do sum for char type fields,it will only possible for numaric fields.
This u can do by program,after populating the output data,do the sums for the required fields in program and append that to output table as last record.Display the last row with differant color.
Regards,
Raghu/ -
Double Click on ALV Report Output, Bringing to selections creen
Hello Gurus,
Please help me When i do double click on ALV Report output , it is going back to Selection screen, actually its working as Back button. Now how to stop it.. I did debugging but i cannot trace it.PERFORM SUB_CREATE_FCAT.
DATA W_REPID LIKE SY-REPID.
W_REPID = SY-REPID.
ls_layout-colwidth_optimize = 'X'.
ls_layout-zebra = 'X'.
PERFORM SUB_SORT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-CPROG
I_CALLBACK_PF_STATUS_SET = 'STATUS'
I_CALLBACK_USER_COMMAND = 'C_USERCOMMAND '
* 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 =
IS_LAYOUT = ls_layout
IT_FIELDCAT = IT_FIELDCAT
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
IT_SORT = IT_SORT
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
I_SAVE = 'U'
* IS_VARIANT =
* IT_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
* 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 = T_FINAL
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF. -
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 -
Double click in ALV tree output????
Hi all,
I am able to display output in tree format. But I want to add the double click functionality to some of the fields in output. Means if I double click on some value in output tree, it should call some transaction. Please help me with this issue of double clicking.
Please tell how to handle events in this report tree display.
For the following code its displaying output in tree format and in right way. But i need to add double click functionality to this.
So provide me some sample program for this one....
* create hierarchy
CALL METHOD tree1->set_table_for_first_display
EXPORTING
it_list_commentary = lt_list_commentary
i_background_id = 'ALV_BACKGROUND'
i_save = 'A'
is_variant = ls_variant
CHANGING
it_sort = gt_sort[]
it_outtab = itab_outtab
it_fieldcatalog = t_fieldcat. "gt_fieldcatalog.
* expand first level
CALL METHOD tree1->expand_tree
EXPORTING
i_level = 1.
* optimize column-width
CALL METHOD tree1->column_optimize
EXPORTING
i_start_column = tree1->c_hierarchy_column_name
i_end_column = tree1->c_hierarchy_column_name.
In grid ALV we can have double cilck functionality using code:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = w_repid
i_callback_pf_status_set = 'PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
is_layout = ls_layout
it_fieldcat = gt_fc[]
Here we can write subroutine for USER_COMMAND and handle the double click evenet. But tell me how to provide this in tree ALV.
<REMOVED BY MODERATOR>
Regards,
Sachin
Edited by: Alvaro Tejada Galindo on Feb 14, 2008 1:47 PMHello Sachin
The following sample report ZUS_SDN_ALV_TREE_DEMO demonstrates the crucial parts for double-click event handling (nodes & items) in ALV trees.
*& Report ZUS_SDN_ALV_TREE_DEMO
*& Thread: double click in ALV tree output????
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="742412"></a>
REPORT zus_sdn_alv_tree_demo.
CLASS cl_gui_column_tree DEFINITION LOAD.
CLASS cl_gui_cfw DEFINITION LOAD.
TYPE-POOLS: abap.
TYPES: BEGIN OF ty_s_outtab.
INCLUDE TYPE knvv AS data.
TYPES: nkey TYPE lvc_nkey.
TYPES: parent_key TYPE lvc_nkey.
TYPES: END OF ty_s_outtab.
TYPES: ty_t_outtab TYPE STANDARD TABLE OF ty_s_outtab
WITH DEFAULT KEY.
DATA: gt_outtab TYPE ty_t_outtab.
DATA:
gd_okcode TYPE ui_func,
gd_repid TYPE syst-repid,
gt_fcat TYPE lvc_t_fcat,
gs_layout TYPE lvc_s_layo,
gs_variant TYPE disvariant,
go_docking TYPE REF TO cl_gui_docking_container,
go_tree TYPE REF TO cl_gui_alv_tree.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_node_double_click
FOR EVENT node_double_click OF cl_gui_alv_tree
IMPORTING node_key,
handle_item_double_click
FOR EVENT item_double_click OF cl_gui_alv_tree
IMPORTING node_key
fieldname.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_node_double_click.
message 'Event=Double-Click on Node' type 'I'.
call transaction 'XD03'.
ENDMETHOD. "handle_node_double_click
METHOD handle_item_double_click.
message 'Event=Double-Click on Item' type 'I'.
call transaction 'VA03'.
ENDMETHOD. "handle_item_double_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
PERFORM init_controls.
gd_repid = syst-repid.
CALL METHOD go_docking->link
EXPORTING
repid = gd_repid
dynnr = '0100'
* container =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
lifetime_dynpro_dynpro_link = 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.
CALL SCREEN '0100'.
** NOTE: no elements on screen
** 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'.
* SET TITLEBAR 'xxx'.
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
'EXIT' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
WHEN 'REFRESH'.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& 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 tree control
CREATE OBJECT go_tree
EXPORTING
parent = go_docking
node_selection_mode = cl_gui_column_tree=>node_sel_mode_multiple
item_selection = 'X' " required for double-click event on item
no_html_header = ''
no_toolbar = ''
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7.
IF sy-subrc <> 0.
MESSAGE x208(00) WITH 'ERROR'. "#EC NOTEXT
ENDIF.
* create Hierarchy-header
DATA ls_hierarchy_header TYPE treev_hhdr.
PERFORM build_hierarchy_header CHANGING ls_hierarchy_header.
PERFORM build_fieldcatalog.
PERFORM set_layout_and_variant.
* create emty tree-control
CALL METHOD go_tree->set_table_for_first_display
EXPORTING
** i_structure_name = 'KNVV'
is_variant = gs_variant
i_save = 'A'
* i_default = 'X'
is_hierarchy_header = ls_hierarchy_header
* is_exception_field =
* it_special_groups =
* it_list_commentary =
* i_logo =
* i_background_id =
* it_toolbar_excluding =
* it_except_qinfo =
CHANGING
it_outtab = gt_outtab
* it_filter =
it_fieldcatalog = gt_fcat.
* create hierarchy
PERFORM create_hierarchy.
* register events
PERFORM register_events.
* adjust column_width
CALL METHOD go_tree->column_optimize.
ENDFORM. " init_controls
*& Form build_hierarchy_header
* build hierarchy-header-information
* -->P_L_HIERARCHY_HEADER strucxture for hierarchy-header
FORM build_hierarchy_header CHANGING
p_hierarchy_header TYPE treev_hhdr.
p_hierarchy_header-heading = 'Hierarchy Header'. "#EC NOTEXT
p_hierarchy_header-tooltip =
'This is the Hierarchy Header !'. "#EC NOTEXT
p_hierarchy_header-width = 30.
p_hierarchy_header-width_pix = ''.
ENDFORM. " build_hierarchy_header
*& Form BUILD_FIELDCATALOG
* text
* --> p1 text
* <-- p2 text
FORM build_fieldcatalog .
REFRESH: gt_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'KNVV'
* 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 FROM 8.
ENDFORM. " BUILD_FIELDCATALOG
*& Form SET_LAYOUT_AND_VARIANT
* text
* --> p1 text
* <-- p2 text
FORM set_layout_and_variant .
CLEAR: gs_layout,
gs_variant.
gs_variant-report = syst-repid.
gs_variant-handle = 'TREE'.
ENDFORM. " SET_LAYOUT_AND_VARIANT
*& Form create_hierarchy
* text
* --> p1 text
* <-- p2 text
FORM create_hierarchy .
DATA: ls_knvv TYPE sflight,
ls_outtab TYPE ty_s_outtab,
lt_outtab TYPE ty_t_outtab.
* get data
SELECT * FROM knvv INTO CORRESPONDING FIELDS OF TABLE lt_outtab
UP TO 200 ROWS . "#EC CI_NOWHERE
SORT lt_outtab BY kunnr vkorg.
* add data to tree
DATA: ld_kunnr_key TYPE lvc_nkey,
ld_vkorg_key TYPE lvc_nkey,
ld_last_key TYPE lvc_nkey.
LOOP AT lt_outtab INTO ls_outtab.
ON CHANGE OF ls_outtab-kunnr.
PERFORM add_customer_line USING ls_outtab-data
CHANGING ld_kunnr_key.
ENDON.
ON CHANGE OF ls_outtab-vkorg.
PERFORM add_salesorg_line USING ls_outtab-data
ld_kunnr_key
CHANGING ld_vkorg_key.
ENDON.
PERFORM add_complete_line USING ls_outtab-data
ld_vkorg_key
CHANGING ld_last_key.
ENDLOOP.
* calculate totals
CALL METHOD go_tree->update_calculations.
* this method must be called to send the data to the frontend
CALL METHOD go_tree->frontend_update.
ENDFORM. " create_hierarchy
*& Form add_customer_line
* add hierarchy-level 1 to tree
* -->P_LS_SFLIGHT sflight
* -->P_RELEATKEY relatkey
* <-->p_node_key new node-key
FORM add_customer_line USING us_data TYPE ty_s_outtab-data
ud_relat_key TYPE lvc_nkey
CHANGING cd_node_key TYPE lvc_nkey.
DATA: l_node_text TYPE lvc_value,
ls_data TYPE ty_s_outtab-data.
* set item-layout
DATA: lt_item_layout TYPE lvc_t_layi,
ls_item_layout TYPE lvc_s_layi.
ls_item_layout-t_image = '@A0@'. " icon_customer.
ls_item_layout-fieldname = go_tree->c_hierarchy_column_name.
ls_item_layout-style =
cl_gui_column_tree=>style_intensifd_critical.
APPEND ls_item_layout TO lt_item_layout.
* add node
l_node_text = us_data-kunnr.
DATA: ls_node TYPE lvc_s_layn.
ls_node-n_image = space.
ls_node-exp_image = space.
CALL METHOD go_tree->add_node
EXPORTING
i_relat_node_key = ud_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_outtab_line = ls_data
is_node_layout = ls_node
it_item_layout = lt_item_layout
IMPORTING
e_new_node_key = cd_node_key.
ENDFORM. " add_customer_line
*& Form add_salesorg_line
* add hierarchy-level 1 to tree
* -->P_LS_SFLIGHT sflight
* -->P_RELEATKEY relatkey
* <-->p_node_key new node-key
FORM add_salesorg_line USING us_data TYPE ty_s_outtab-data
ud_relat_key TYPE lvc_nkey
CHANGING cd_node_key TYPE lvc_nkey.
DATA: l_node_text TYPE lvc_value,
ls_data TYPE ty_s_outtab-data.
* set item-layout
DATA: lt_item_layout TYPE lvc_t_layi,
ls_item_layout TYPE lvc_s_layi.
ls_item_layout-t_image = '@DS@'. " ICON_PARTNER_SALES_ACTIVITY
ls_item_layout-fieldname = go_tree->c_hierarchy_column_name.
ls_item_layout-style =
cl_gui_column_tree=>style_intensifd_critical.
APPEND ls_item_layout TO lt_item_layout.
* add node
l_node_text = us_data-vkorg.
DATA: ls_node TYPE lvc_s_layn.
ls_node-n_image = space.
ls_node-exp_image = space.
CALL METHOD go_tree->add_node
EXPORTING
i_relat_node_key = ud_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_outtab_line = ls_data
is_node_layout = ls_node
it_item_layout = lt_item_layout
IMPORTING
e_new_node_key = cd_node_key.
ENDFORM. " add_salesorg_line
*& Form add_cmplete_line
* add hierarchy-level 3 to tree
* -->P_LS_SFLIGHT sflight
* -->P_RELEATKEY relatkey
* <-->p_node_key new node-key
FORM add_complete_line USING us_data TYPE ty_s_outtab-data
ud_relat_key TYPE lvc_nkey
CHANGING cd_node_key TYPE lvc_nkey.
DATA: l_node_text TYPE lvc_value.
* set item-layout
DATA: lt_item_layout TYPE lvc_t_layi,
ls_item_layout TYPE lvc_s_layi.
ls_item_layout-fieldname = go_tree->c_hierarchy_column_name.
ls_item_layout-class = cl_gui_column_tree=>item_class_checkbox.
** ls_item_layout-editable = 'X'.
APPEND ls_item_layout TO lt_item_layout.
** CLEAR ls_item_layout.
** ls_item_layout-fieldname = 'PLANETYPE'.
** ls_item_layout-alignment = cl_gui_column_tree=>align_right.
** APPEND ls_item_layout TO lt_item_layout.
l_node_text = us_data-vtweg.
DATA: ls_node TYPE lvc_s_layn.
ls_node-n_image = space.
ls_node-exp_image = space.
CALL METHOD go_tree->add_node
EXPORTING
i_relat_node_key = ud_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
is_outtab_line = us_data
i_node_text = l_node_text
is_node_layout = ls_node
it_item_layout = lt_item_layout
IMPORTING
e_new_node_key = cd_node_key.
ENDFORM. " add_complete_line
*& Form register_events
* text
* --> p1 text
* <-- p2 text
FORM register_events.
* define the events which will be passed to the backend
DATA: lt_events TYPE cntl_simple_events,
l_event TYPE cntl_simple_event.
* define the events which will be passed to the backend
l_event-eventid = cl_gui_column_tree=>eventid_expand_no_children.
APPEND l_event TO lt_events.
** l_event-eventid = cl_gui_column_tree=>eventid_checkbox_change.
** APPEND l_event TO lt_events.
** l_event-eventid = cl_gui_column_tree=>eventid_header_context_men_req.
** APPEND l_event TO lt_events.
** l_event-eventid = cl_gui_column_tree=>eventid_node_context_menu_req.
** APPEND l_event TO lt_events.
** l_event-eventid = cl_gui_column_tree=>eventid_item_context_menu_req.
** APPEND l_event TO lt_events.
** l_event-eventid = cl_gui_column_tree=>eventid_header_click.
** APPEND l_event TO lt_events.
** l_event-eventid = cl_gui_column_tree=>eventid_item_keypress.
** APPEND l_event TO lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_node_double_click.
APPEND l_event TO lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_item_double_click.
APPEND l_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 x208(00) WITH 'ERROR'. "#EC NOTEXT
ENDIF.
* set Handler
set handler:
lcl_eventhandler=>handle_node_double_click for go_tree,
lcl_eventhandler=>handle_item_double_click for go_tree.
** DATA: l_event_receiver TYPE REF TO lcl_tree_event_receiver.
** CREATE OBJECT l_event_receiver.
** SET HANDLER l_event_receiver->handle_node_ctmenu_request
** FOR tree1.
** SET HANDLER l_event_receiver->handle_node_ctmenu_selected
** FOR tree1.
** SET HANDLER l_event_receiver->handle_item_ctmenu_request
** FOR tree1.
** SET HANDLER l_event_receiver->handle_item_ctmenu_selected
** FOR tree1.
** SET HANDLER l_event_receiver->handle_checkbox_change FOR tree1.
ENDFORM. " register_events
Regards
Uwe -
Hi all,
Here is the code:
my aim is to double click the alv list and display the correspoonding data .can any one tell me how to solve this.
regards,
Lisa
Message was edited by: Lisa RoyHi Lisa,
**-ALV list Display
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
<b> I_CALLBACK_PF_STATUS_SET = 'PF_STATUS_SET'</b>
<b> I_CALLBACK_USER_COMMAND = 'USER_COMMAND'</b>
IS_LAYOUT = X_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
IT_EVENTS = IT_EVENTS
TABLES
T_OUTTAB = IT_FINAL
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
you need to pass these two forms
FORM PF_STATUS_SET USING P_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'STANDARD' EXCLUDING P_EXTAB.
ENDFORM. "PF_STATUS_SET
FORM USER_COMMAND USING UCOMM LIKE SY-UCOMM SELFIELD TYPE
SLIS_SELFIELD.
case UCOMM.
when '&IC1'. "this is for double click.
"do some thing..
ENDCASE.
ENDFORM. "USER_COMMAND -
Double Click in ALV Report in Web dynpro ABAP4
Hi All,
I am very much new to WDA4 , can anybody plz guide me how to enable double click in ALV Report in Web dynpro ..
Plz help it is urgent .....
Thnks
SahilHi All,
I am very much new to WDA4 , can anybody plz guide me how to enable double click in ALV Report in Web dynpro ..
Plz help it is urgent .....
Thnks
Sahil -
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. -
Unable to double click after using at line-selection
hi all...
unable to double click after using at line-selection. But if i comment set pf-status, i can double click on the line but on first double click everytime i just get last record i.e. 200th and after second double click i'm not getting output. what is the problem? plz reply...
REPORT YP2 line-count 10(2).
tables: lfa1, LFB1.
data: itab like lfa1 occurs 0 with header line,
JTAB LIKE LFB1 OCCURS 0 WITH HEADER LINE.
SELECT-OPTIONS: vendor_n for lfa1-lifnr.
*SET PF-STATUS 'MENU'.
INITIALIZATION.
vendor_n-low = '1'.
vendor_n-high = '200'.
vendor_n-option = 'BT'.
APPEND vendor_n.
clear vendor_n.
At selection-screen.
IF VENDOR_N-LOW < 1.
MESSAGE w000(sabapdocu).
clear vendor_n.
ELSEIF vendor_n-HIGH > 200.
MESSAGE S001(sabapdocu).
ENDIF.
START-OF-SELECTION.
SELECT * FROM lfa1 INTO TABLE ITAB WHERE lifnr IN vendor_n.
WRITE:5 SY-ULINE(72).
LOOP AT ITAB.
WRITE: /5 SY-VLINE,9 ITAB-lifnr,20 SY-VLINE, 22 ITAB-name1,58 SY-VLINE, 60 ITAB-telf1, 76 SY-VLINE.
ENDLOOP.
top-of-page.
WRITE:/5 SY-ULINE(72).
WRITE: /5 SY-VLINE, 'Vendor_code', 20 SY-VLINE, 28 'Name' ,58 SY-VLINE, 60 'Phone', 76 SY-VLINE.
WRITE:/5 SY-ULINE(72).
end-of-page.
WRITE:5 SY-ULINE(72).
WRITE:/ 'THE PAGE NO IS',SY-PAGNO.
WRITE:/5 SY-ULINE(72).
END-OF-SELECTION.
WRITE: /5 sy-uline(72),/ 'THE RECORD IS CLOSED'.
AT LINE-SELECTION.
IF SY-LSIND = 1.
SELECT * FROM LFA1 INTO TABLE ITAB WHERE LIFNR = ITAB-LIFNR.
LOOP AT ITAB.
WRITE: /5 SY-VLINE,9 ITAB-lifnr,20 SY-VLINE, 22 ITAB-name1,58 SY-VLINE, 60 ITAB-telf1, 76 SY-VLINE.
ENDLOOP.
WRITE:/5 SY-ULINE(72).
ELSEIF SY-LSIND = 2.
WRITE:/5 SY-VLINE,6 'Vendor No.',17 SY-VLINE,18 'Company code',28 SY-VLINE, 29 'Created by',39 SY-VLINE.
SELECT * FROM LFB1 INTO TABLE JTAB WHERE LIFNR = JTAB-LIFNR.
LOOP AT JTAB.
WRITE:/5 SY-VLINE,6 JTAB-LIFNR,17 SY-VLINE,18 JTAB-BUKRS,28 SY-VLINE, 29 JTAB-ERNAM,39 SY-VLINE.
ENDLOOP.
WRITE:/5 SY-ULINE(72).
ENDIF.
AT PF7.
IF SY-LSIND = 1.
SELECT * FROM LFA1 INTO TABLE ITAB WHERE LIFNR = ITAB-LIFNR.
LOOP AT ITAB.
WRITE: /5 SY-VLINE,9 ITAB-lifnr,20 SY-VLINE, 22 ITAB-name1,58 SY-VLINE, 60 ITAB-telf1, 76 SY-VLINE.
ENDLOOP.
WRITE:/5 SY-ULINE(72).
ELSEIF SY-LSIND = 2.
SELECT * FROM LFB1 INTO TABLE JTAB WHERE LIFNR = JTAB-LIFNR.
LOOP AT JTAB.
WRITE:/5 SY-VLINE,6 JTAB-LIFNR,17 SY-VLINE,18 JTAB-BUKRS,28 SY-VLINE, 29 JTAB-ERNAM,39 SY-VLINE.
ENDLOOP.
WRITE:/5 SY-ULINE(72).
ENDIF.
AT USER-COMMAND.
IF SY-UCOMM = '0001'.
IF SY-LSIND = 1.
SELECT * FROM LFA1 INTO TABLE ITAB WHERE LIFNR = ITAB-LIFNR.
LOOP AT ITAB.
WRITE: /5 SY-VLINE,9 ITAB-lifnr,20 SY-VLINE, 22 ITAB-name1,58 SY-VLINE, 60 ITAB-telf1, 76 SY-VLINE.
ENDLOOP.
WRITE:/5 SY-ULINE(72).
ELSEIF SY-LSIND = 2.
SELECT * FROM LFB1 INTO TABLE JTAB WHERE LIFNR = JTAB-LIFNR.
LOOP AT JTAB.
WRITE:/5 SY-VLINE,6 JTAB-LIFNR,17 SY-VLINE,18 JTAB-BUKRS,28 SY-VLINE, 29 JTAB-ERNAM,39 SY-VLINE.
ENDLOOP.
WRITE:/5 SY-ULINE(72).
ENDIF.
ENDIF.Hi,
copy and paste the code given below it works....
START-OF-SELECTION.
SELECT * FROM lfa1 INTO TABLE ITAB WHERE lifnr IN vendor_n.
WRITE:5 SY-ULINE(72).
LOOP AT ITAB.
WRITE: /5 SY-VLINE,9 ITAB-lifnr,20 SY-VLINE, 22 ITAB-name1,58 SY-VLINE, 60 ITAB-telf1, 76 SY-VLINE.
hide : itab-lifnr.
ENDLOOP.
clear itab.
top-of-page.
WRITE:/5 SY-ULINE(72).
WRITE: /5 SY-VLINE, 'Vendor_code', 20 SY-VLINE, 28 'Name' ,58 SY-VLINE, 60 'Phone', 76 SY-VLINE.
WRITE:/5 SY-ULINE(72).
end-of-page.
WRITE:5 SY-ULINE(72).
WRITE:/ 'THE PAGE NO IS',SY-PAGNO.
WRITE:/5 SY-ULINE(72).
END-OF-SELECTION.
WRITE: /5 sy-uline(72),/ 'THE RECORD IS CLOSED'.
AT LINE-SELECTION.
IF itab-lifnr is not initial.
IF SY-LSIND = 1.
SELECT * FROM LFA1 INTO TABLE ITAB WHERE LIFNR = ITAB-LIFNR.
LOOP AT ITAB.
WRITE: /5 SY-VLINE,9 ITAB-lifnr,20 SY-VLINE, 22 ITAB-name1,58 SY-VLINE, 60 ITAB-telf1, 76 SY-VLINE.
HIDE ITAB-LIFNR.
ENDLOOP.
CLEAR ITAB.
WRITE:/5 SY-ULINE(72).
ELSEIF SY-LSIND = 2.
WRITE:/5 SY-VLINE,6 'Vendor No.',17 SY-VLINE,18 'Company code',28 SY-VLINE, 29 'Created by',39 SY-VLINE.
SELECT * FROM LFB1 INTO TABLE JTAB WHERE LIFNR = ITAB-LIFNR.
LOOP AT JTAB.
WRITE:/5 SY-VLINE,6 JTAB-LIFNR,17 SY-VLINE,18 JTAB-BUKRS,28 SY-VLINE, 29 JTAB-ERNAM,39 SY-VLINE.
ENDLOOP.
CLEAR ITAB.
WRITE:/5 SY-ULINE(72).
ENDIF.
ENDIF.
AT PF7.
IF itab-lifnr is not initial.
IF SY-LSIND = 1.
SELECT * FROM LFA1 INTO TABLE ITAB WHERE LIFNR = ITAB-LIFNR.
LOOP AT ITAB.
WRITE: /5 SY-VLINE,9 ITAB-lifnr,20 SY-VLINE, 22 ITAB-name1,58 SY-VLINE, 60 ITAB-telf1, 76 SY-VLINE.
HIDE ITAB-LIFNR.
ENDLOOP.
CLEAR ITAB.
WRITE:/5 SY-ULINE(72).
ELSEIF SY-LSIND = 2.
SELECT * FROM LFB1 INTO TABLE JTAB WHERE LIFNR = JTAB-LIFNR.
LOOP AT JTAB.
WRITE:/5 SY-VLINE,6 JTAB-LIFNR,17 SY-VLINE,18 JTAB-BUKRS,28 SY-VLINE, 29 JTAB-ERNAM,39 SY-VLINE.
ENDLOOP.
CLEAR ITAB.
WRITE:/5 SY-ULINE(72).
ENDIF.
ENDIF.
AT USER-COMMAND.
IF SY-UCOMM = '0001' and itab-lifnr is not initial.
IF SY-LSIND = 1.
SELECT * FROM LFA1 INTO TABLE ITAB WHERE LIFNR = ITAB-LIFNR.
LOOP AT ITAB.
WRITE: /5 SY-VLINE,9 ITAB-lifnr,20 SY-VLINE, 22 ITAB-name1,58 SY-VLINE, 60 ITAB-telf1, 76 SY-VLINE.
HIDE ITAB-LIFNR.
ENDLOOP.
clear ITAB.
WRITE:/5 SY-ULINE(72).
ELSEIF SY-LSIND = 2.
SELECT * FROM LFB1 INTO TABLE JTAB WHERE LIFNR = JTAB-LIFNR.
LOOP AT JTAB.
WRITE:/5 SY-VLINE,6 JTAB-LIFNR,17 SY-VLINE,18 JTAB-BUKRS,28 SY-VLINE, 29 JTAB-ERNAM,39 SY-VLINE.
ENDLOOP.
CLEAR ITAB.
WRITE:/5 SY-ULINE(72).
ENDIF.
ENDIF.
Regards,
Siddarth
Maybe you are looking for
-
Can't read or write to disk...
I know that there are a lot of similar posts out here, but they all seem to die out without a straight answer. But anyways, my problem is that about halfway through a sync, an error message pops up and says "Device _ cannot sync: disk cannot be read
-
IView not Visible in portal content Area
Hi experts, i got a problem when i try to access to the Area 'Travel and Expenses' of the portal after logging in. The Area should be point to a Page involving 2 IView, one of them contain the visualization of 4 links and the other one pointed to a c
-
Dear all, We are planning to archive a huge table, which is currently 65G. Our initiative plan of each archiving session will archive about data of 10G. We currently set file size as 100M. We are not sure if this size is appropriate. Can anyone g
-
Hi Friends, Can we run any reoprt in back ground which has GUI_DOWNLOAD function in it?If not, what is the alternative? Thanks in Advance
-
How many people who frequent this forum and help out, or develop games for a living or otherwise, are actually gamers? i am for one. I was just wondering how many people who develop games have actually played a game before and know what the gamers wa