Events : CL_SALV_TABLE
Hi All,
How can i handle top_of_page events using the data displayed thru cl_salv_table?
Also can i make the columns displayed thru cl_salv_table editable? If i can how? Also how can i handle the changed values?
A sample code will greatly help.
Thanks in advance for your help.
Thanks,
Balaji
Hello,
I suggest you to read this, [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907].
There's some information about how to handle events.
Regards,
Similar Messages
-
Handling standard toolbar event in CL_SALV_TABLE
Hi Experts,
I have created a ALV report using class CL_SAL_TABLE. I have created some buttons in the application toolbar of ALV by which I can jump to other ALV views. Now my requirement is if I click on the Exit (Shift+F3) button on the standard toolbar at that time, I'd be taken back to the selection screen. Currently both the back and exit button behaves the same way (i.e. set screen 0. leave screen.). I want to change the behaviour for exit button.
Can anybody help me how to implement that?
Thanks,
MainakHi Mainak,
Call the screen number that you wish to. (Selection-screen number).
CASE sy-ucomm.
WHEN EXIT.
CALL SCREEN 'xxxx'. -
Event handling in abap objects
hello friends,
i want to use the event RAISE_LINK_CLICK for single click.
but i dont want 2 use this event for alv table.
i am displaying vendor name in my top of page,if the user click of the vendor name a new window should pop-up displaying the vendor details.
my code for top of page is
DATA: lr_grid TYPE REF TO cl_salv_form_layout_grid,
lr_grid_1 TYPE REF TO cl_salv_form_layout_grid,
lr_flow TYPE REF TO cl_salv_form_layout_flow,
lr_label TYPE REF TO cl_salv_form_label,
lr_text TYPE REF TO cl_salv_form_text,
l_text TYPE string.
CREATE OBJECT lr_grid.
lr_grid_1 = lr_grid->create_grid( row = 1 column = 1 ).
lr_text = lr_grid_1->create_text( row = 1 column = 1 colspan = 2 text = <b>vendor_name</b> ).
lr_grid_1 = lr_grid->create_grid( row = 2 column = 1 ).
lr_flow = lr_grid_1->create_flow( row = 2 column = 1 ).
lr_text = lr_flow->create_text( text = 'Reconcillation Statement'(t02) tooltip = 'Reconcillation Statement'(t02) ).
alv->set_top_of_list( lr_grid ).
do uc the VENDOR NAME in bold,wen the user clicks on it the pop should appear.
so how to use the event RAISE_LINK_CLICK for this purpose,or is there another way throughHi Amit,
I answered the similar question last week. You can see here or .
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
Regards.
Marcelo Ramos -
Program using class "cl_salv_table"
Hi Experts,
I am new to this class (cl_salv_table). I wrote a program with general ABAP code. But, according to my standard I should use standard ALV factory class i.e., 'CL_SALV_TABLE'. I wouls appreciate if anybody could send me the code using this class. Here is the code which I have written.
REPORT zrgae_acctquery
NO STANDARD PAGE HEADING
LINE-SIZE 190
LINE-COUNT 65
MESSAGE-ID zrga.
Program Title : SAP Account Coding Block Transaction Query Program*
Description : This program loads the legacy General Ledger *
account monthly net activity into the SAP-FI *
system using LSMW. This conversion pertains to *
companyu2019s GL account balances beginning with *
FY07 YE, posting monthly net changes in the *
accounts for FY2008 and FY2009 through go-live. *
Run Frequency: The Z-transaction must be available at any time *
an end user requires the conversion information. *
T A B L E D E C L A R A T I O N
TABLES: ztt_rga_xreft.
D A T A D E C L A R A T I O N
DATA: group_id(3) TYPE c,
l_line TYPE i.
I N T E R N A L T A B L E S
TYPES: BEGIN OF lty_ztt_rga_xreft,
ctacct TYPE ztt_rga_xreft-ctacct,
ctrc01 TYPE ztt_rga_xreft-ctrc01,
ctrc02 TYPE ztt_rga_xreft-ctrc02,
ctrc03 TYPE ztt_rga_xreft-ctrc03,
ctrc04 TYPE ztt_rga_xreft-ctrc04,
ctrc05 TYPE ztt_rga_xreft-ctrc05,
ctrc06 TYPE ztt_rga_xreft-ctrc06,
ctrc07 TYPE ztt_rga_xreft-ctrc07,
ctrc08 TYPE ztt_rga_xreft-ctrc08,
bukrs TYPE ztt_rga_xreft-bukrs,
prctr TYPE ztt_rga_xreft-prctr,
kostl TYPE ztt_rga_xreft-kostl,
saknr TYPE ztt_rga_xreft-saknr,
aufnr TYPE ztt_rga_xreft-aufnr,
sap_offset TYPE ztt_rga_xreft-sap_offset,
END OF lty_ztt_rga_xreft.
DATA: lt_data TYPE STANDARD TABLE OF lty_ztt_rga_xreft, lwa_data TYPE lty_ztt_rga_xreft.
S E L E C T I O N S C R E E N D E F I N I T I O N S *
SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-001.
PARAMETERS: p_lgsap RADIOBUTTON GROUP b1 USER-COMMAND rad DEFAULT 'X',
p_saplg RADIOBUTTON GROUP b1.
SELECTION-SCREEN END OF BLOCK a1.
SKIP.
SELECTION-SCREEN BEGIN OF BLOCK a2 WITH FRAME TITLE text-002. "ACC
SELECT-OPTIONS: s_lccode FOR ztt_rga_xreft-ctrc01 MODIF ID acc,
s_ldiv FOR ztt_rga_xreft-ctrc02 MODIF ID acc,
s_lreg FOR ztt_rga_xreft-ctrc03 MODIF ID acc,
s_lloc FOR ztt_rga_xreft-ctrc04 MODIF ID acc,
s_lcctr FOR ztt_rga_xreft-ctrc05 MODIF ID acc,
s_lacct FOR ztt_rga_xreft-ctrc06 MODIF ID acc,
s_lsacct FOR ztt_rga_xreft-ctrc07 MODIF ID acc.
SELECTION-SCREEN END OF BLOCK a2.
SKIP.
SELECTION-SCREEN BEGIN OF BLOCK a3 WITH FRAME TITLE text-003. "ALL
SELECT-OPTIONS: s_bukrs FOR ztt_rga_xreft-bukrs MODIF ID all,
s_prctr FOR ztt_rga_xreft-prctr MODIF ID all,
s_kostl FOR ztt_rga_xreft-kostl MODIF ID all,
s_saknr FOR ztt_rga_xreft-saknr MODIF ID all,
s_aufnr FOR ztt_rga_xreft-aufnr MODIF ID all.
SELECTION-SCREEN END OF BLOCK a3.
A T S E L E C T I O N S C R E E N
AT SELECTION-SCREEN OUTPUT.
CASE 'X'.
WHEN p_saplg.
group_id = 'ACC'.
SET CURSOR FIELD 'S_BUKRS-LOW'.
WHEN p_lgsap.
group_id = 'ALL'.
SET CURSOR FIELD 'S_LCCTR-LOW'.
ENDCASE.
LOOP AT SCREEN.
IF screen-group1 = group_id.
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
S T A R T O F S E L E C T I O N
START-OF-SELECTION.
CLEAR l_line.
IF p_lgsap = 'X'. " If legacy input filled
INFINIUM CASE-I VALIDATIONS & OUTPUT *
PASSING INFINIUM 'COST CENTER','ACCOUNT',& 'SUB ACCT' *
IF s_lcctr-low NE ' ' AND s_lacct-low NE ' ' AND s_lsacct-low NE ' '.
SELECT ctrc01
ctrc02
ctrc03
ctrc04
ctrc05
ctrc06
ctrc07
ctrc08
bukrs
prctr
kostl
saknr
aufnr
sap_offset
FROM ztt_rga_xreft INTO TABLE lt_data
WHERE ctrc05 IN s_lcctr
AND ctrc06 IN s_lacct
AND ctrc07 IN s_lsacct.
DESCRIBE TABLE lt_data LINES l_line.
IF l_line < 0.
MESSAGE e001(zrga) with 'Cost Ctr,Acct,SubAcct are not valid.pl check'.
ENDIF.
INFINIUM CASE-II VALIDATIONS & OUTPUT *
PASSING INFINIUM 'COST CENTER'&'ACCOUNT' *
ELSEIF s_lcctr-low NE ' ' AND s_lacct-low NE ' '
AND s_lsacct-low EQ ' '.
SELECT ctrc01
ctrc02
ctrc03
ctrc04
ctrc05
ctrc06
ctrc07
ctrc08
bukrs
prctr
kostl
saknr
aufnr
sap_offset
FROM ztt_rga_xreft INTO TABLE lt_data WHERE ctrc05 IN s_lcctr
AND ctrc06 IN s_lacct.
DESCRIBE TABLE lt_data LINES l_line.
IF l_line < 0.
MESSAGE e002(zrga) with 'Cost Center,Account are not valid...pl check'.
ENDIF.
ENDIF.
INFINIUM CASE-III VALIDATIONS & OUTPUT *
PASSING INFINIUM 'COMPANY CODE'&'ACCOUNT' *
ELSEIF s_lccode-low NE ' ' AND s_lacct-low NE ' '.
SELECT ctrc01
ctrc02
ctrc03
ctrc04
ctrc05
ctrc06
ctrc07
ctrc08
bukrs
prctr
kostl
saknr
aufnr
sap_offset
FROM ztt_rga_xreft INTO TABLE lt_data WHERE ctrc01 IN s_lccode
AND ctrc06 IN s_lacct.
DESCRIBE TABLE lt_data LINES l_line.
IF l_line < 0.
MESSAGE e003(zrga) with 'Company code,Acct are not valid.pl check'.
ENDIF.
ELSE. " If SAP input filled
SAP CASE-I VALIDATIONS & OUTPUT *
PASSING SAP 'COST CENTER','ACCOUNT'&'INTERNAL ORDER' *
IF s_kostl-low NE ' ' AND s_saknr-low NE ' ' AND s_aufnr-low NE ' '.
SELECT ctrc01
ctrc02
ctrc03
ctrc04
ctrc05
ctrc06
ctrc07
ctrc08
bukrs
prctr
kostl
saknr
aufnr
sap_offset
FROM ztt_rga_xreft INTO TABLE lt_data WHERE kostl IN s_kostl
AND saknr IN s_saknr
AND aufnr IN s_aufnr.
DESCRIBE TABLE lt_data LINES l_line.
IF l_line < 0.
MESSAGE e004(zrga) with 'Cost Ctr,Acct,Int order are not valid...pl check'.
ENDIF.
SAP CASE-II VALIDATIONS & OUTPUT *
PASSING SAP 'COST CENTER'&'ACCOUNT' *
ELSEIF s_kostl-low NE ' ' AND s_saknr-low NE ' ' AND s_aufnr-low EQ ' '.
SELECT ctrc01
ctrc02
ctrc03
ctrc04
ctrc05
ctrc06
ctrc07
ctrc08
bukrs
prctr
kostl
saknr
aufnr
sap_offset
FROM ztt_rga_xreft INTO TABLE lt_data WHERE kostl IN s_kostl
AND saknr IN s_saknr.
DESCRIBE TABLE lt_data LINES l_line.
IF l_line < 0.
MESSAGE e005(zrga) with 'Cost Ctr,Acct are not valid...pl check'.
ENDIF.
ENDIF.
ENDIF.
O U T P U T
IF p_lgsap = 'X'. " If legacy input filled
WRITE:/2 'Infinium Company', 40 s_lccode-low,
/2 'Infinium Division', 40 s_ldiv-low,
/2 'Infinium Region', 40 s_lreg-low,
/2 'Infinium Location', 40 s_lloc-low,
/2 'Infinium Cost center', 40 s_lcctr-low,
/2 'Infinium Account', 40 s_lacct-low,
/2 'Infinium Sub-account', 40 s_lsacct-low.
ELSE. "If SAP input filled
WRITE:/2 'SAP Company', 40 s_bukrs-low,
/2 'SAP Cost center', 40 s_kostl-low,
/2 'SAP Profit center', 40 s_prctr-low,
/2 'SAP Account', 40 s_saknr-low,
/2 'SAP order', 40 s_aufnr-low.
ENDIF.
WRITE:/ sy-uline(190).
FORMAT COLOR COL_HEADING ON.
WRITE:/1 sy-vline,
2 'Infinium Company',
17 sy-vline,
18 'Infinium Division',
37 sy-vline,
38 'Infinium Region',
57 sy-vline,
58 'Infinium Location',
77 sy-vline,
78 'Infinium Cost Center',
97 sy-vline,
98 'Infinium Account',
114 sy-vline,
115 'Infinium Sub Account',
134 sy-vline.
FORMAT COLOR COL_HEADING OFF.
FORMAT COLOR COL_POSITIVE ON.
WRITE: 135 'SAP Company',
144 sy-vline,
145 'SAP Profit Center',
154 sy-vline,
155 'SAP Cost Center',
164 sy-vline,
165 'SAP Account',
174 sy-vline,
175 'SAP Order',
190 sy-vline.
FORMAT COLOR COL_POSITIVE OFF.
WRITE:/1 sy-vline.
WRITE:/ sy-uline(190).
WRITE:/ sy-uline(190).
LOOP AT lt_data into lwa_data.
FORMAT COLOR COL_HEADING ON.
WRITE:/1 sy-vline,
2 lwa_data-ctrc01,
17 sy-vline,
18 lwa_data-ctrc02,
37 sy-vline,
38 lwa_data-ctrc03,
57 sy-vline,
58 lwa_data-ctrc04,
77 sy-vline,
78 lwa_data-ctrc05,
97 sy-vline,
98 lwa_data-ctrc06,
114 sy-vline,
115 lwa_data-ctrc07,
134 sy-vline.
FORMAT COLOR COL_HEADING OFF.
FORMAT COLOR COL_POSITIVE ON.
WRITE: 135 lwa_data-bukrs,
144 sy-vline,
145 lwa_data-prctr,
154 sy-vline,
155 lwa_data-kostl,
164 sy-vline,
165 lwa_data-saknr,
174 sy-vline,
175 lwa_data-aufnr,
190 sy-vline.
FORMAT COLOR COL_POSITIVE OFF.
WRITE:/ sy-uline(190).
append lwa_data to lt_data.
clear lwa_data.
ENDLOOP.HI nani,
welcome
This is a sample program to illustrate several techniques:
use of dynamic selections
persistent data stored into cluster INDX
data definition at runtime
display internal table using SALV class
Just copy the code into a new program, create include for events, then copy status STANDARD from program SAPLSALV.
u have to add the SAVE function code to the disk button. It allow you to save modifications to the database.
&u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
*& Report zkarthik_update
&u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
report zkarthik_update.
Data definition
type-pools: rsds.
data: is_x030l type x030l,
it_x031l type table of x031l,
is_x031l type x031l.
data: w_selid type rsdynsel-selid,
it_tables type table of rsdstabs,
is_tables type rsdstabs,
it_fields type table of rsdsfields,
it_expr type rsds_texpr,
it_ranges type rsds_trange,
it_where type rsds_twhere,
is_where type rsds_where,
w_active type i.
data: w_repid type sy-repid,
w_dynnr type sy-dynnr,
wt_dynp type table of dynpread,
ws_dynp type dynpread.
data: it_content type ref to data,
is_content type ref to data.
data: w_okcode type sy-ucomm.
data: w_fdkey type x value u201801u2032.
data: w_akey type indx-srtfd,
w_rkey type indx-srtfd,
w_fkey type indx-srtfd.
Include to handle events on ALV display screen
include zbc_query_events.
field-symbols: <itab> type standard table,
<irec> type any.
Macros
define table_error.
message e398(00) with u2018Tableu2019 p_table &1.
end-of-definition.
define fixed_val.
assign component is_x031l-fieldname of structure <irec> to <fld>.
if sy-subrc = 0.
<fld> = &1.
endif.
end-of-definition.
Selection screen
selection-screen: begin of block b01 with frame.
parameters: p_table type tabname obligatory u201Ctable
memory id dtb
matchcode object dd_dbtb_16.
selection-screen: begin of line,
pushbutton 33(20) selopt user-command sel,
comment 55(15) selcnt,
end of line.
selection-screen: skip.
parameters: p_field type fieldname, u201Cfield
p_value type text132. u201Cvalue
selection-screen: end of block b01,
skip,
begin of block b02 with frame.
parameters: p_displ type c as checkbox default u2018Xu2019, u201Cdisplay
p_systm type c as checkbox. u201Csystem
selection-screen: end of block b02.
Initialization
initialization.
move u2018@4G@ Filter recordsu2019 to selopt.
ws_dynp-fieldname = u2018P_TABLEu2019.
append ws_dynp to wt_dynp.
Get dynamic selection from cluster
w_akey(1) = u2018Au2019.
w_akey+1(12) = sy-uname.
import w_active from database indx(xy) id w_akey.
w_rkey(1) = u2018Ru2019.
w_rkey+1(12) = sy-uname.
import it_expr from database indx(xy) id w_rkey.
w_rkey(1) = u2018Fu2019.
w_rkey+1(12) = sy-uname.
import it_fields from database indx(xy) id w_fkey.
PBO
at selection-screen output.
if w_active is initial.
clear: selcnt.
else.
write w_active to selcnt left-justified.
endif.
PAI
at selection-screen.
if p_table ne is_x030l-tabname.
perform f_init_table.
endif.
if sy-ucomm = u2018SELu2019.
if w_selid is initial.
perform f_init_selections.
endif.
Display free selection dialog
call function u2018FREE_SELECTIONS_DIALOGu2019
exporting
selection_id = w_selid
title = u2018Selectionu2019
status = 1
as_window = u2018Xu2019
importing
expressions = it_expr
field_ranges = it_ranges
number_of_active_fields = w_active
tables
fields_tab = it_fields
exceptions
others = 1.
Write dynamic selection to cluster
w_akey(1) = u2018Au2019.
w_akey+1(12) = sy-uname.
export w_active to database indx(xy) id w_akey.
w_rkey(1) = u2018Ru2019.
w_rkey+1(12) = sy-uname.
export it_expr to database indx(xy) id w_rkey.
w_rkey(1) = u2018Fu2019.
w_rkey+1(12) = sy-uname.
export it_fields to database indx(xy) id w_fkey.
endif.
if p_field is not initial.
read table it_x031l into is_x031l
with key fieldname = p_field.
if sy-subrc = 0.
if is_x031l-flag1 o w_fdkey.
message e129(53) with p_field p_table.
endif.
else.
message e804(5g) with p_field p_table.
endif.
endif.
at selection-screen on value-request for p_field.
w_repid = sy-repid.
w_dynnr = sy-dynnr.
call function u2018DYNP_VALUES_READu2019
exporting
dyname = w_repid
dynumb = w_dynnr
tables
dynpfields = wt_dynp
exceptions
others = 1.
if sy-subrc = 0.
read table wt_dynp into ws_dynp index 1.
p_table = ws_dynp-fieldvalue.
call function u2018F4_DD_TABLE_FIELDSu2019
exporting
table = p_table
importing
result = p_field.
endif.
Start of processing
start-of-selection.
perform f_create_table using p_table.
perform f_select_table.
perform f_modify_table.
perform f_display_table using <itab>.
&u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
*& Form f_init_table
&u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
form f_init_table.
Prepare free selection on table
perform f_table_def using p_table.
refresh it_tables.
is_tables-prim_tab = p_table.
append is_tables to it_tables.
clear: w_selid.
endform. u201Cf_init_table
&u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
*& Form f_init_selections
&u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
form f_init_selections.
Init free selection dialog
call function u2018FREE_SELECTIONS_INITu2019
exporting
expressions = it_expr
importing
selection_id = w_selid
expressions = it_expr
tables
tables_tab = it_tables
fields_tab = it_fields
exceptions
others = 1.
endform. u201Cf_init_selections
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
FORM f_table_def *
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
form f_table_def using in_tabname.
call function u2018DDIF_NAMETAB_GETu2019
exporting
tabname = p_table
importing
x030l_wa = is_x030l
tables
x031l_tab = it_x031l
exceptions
others = 1.
if is_x030l is initial.
table_error u2018does not exist or is not activeu2019.
elseif is_x030l-tabtype ne u2018Tu2019.
table_error u2018is not selectableu2019.
endif.
endform. u201Cf_table_def
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
FORM f_create_table *
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
form f_create_table using in_tabname.
create data it_content type table of (in_tabname).
if sy-subrc = 0.
assign it_content->* to <itab>.
else.
write: u2018Error creating internal tableu2019.
stop.
endif.
endform. u201Cf_create_table
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
FORM f_select_table *
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
form f_select_table.
if w_active = 0.
select * from (p_table)
into corresponding fields of table <itab>.
else.
Selection with parameters
call function u2018FREE_SELECTIONS_EX_2_WHEREu2019
exporting
expressions = it_expr
importing
where_clauses = it_where
exceptions
expression_not_supported = 1
others = 2.
read table it_where into is_where with key tablename = p_table.
select * from (p_table)
into corresponding fields of table <itab>
where (is_where-where_tab).
endif.
if sy-dbcnt = 0.
write: u2018No record selectedu2019.
stop.
endif.
endform. u201Cf_select_table
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
FORM f_modify_table *
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
form f_modify_table.
field-symbols: <fld> type any.
loop at <itab> assigning <irec>.
if p_field is not initial.
assign component p_field of structure <irec> to <fld>.
if sy-subrc = 0.
call function u2018GENERIC_CONVERSION_EXIT_INPUTu2019
exporting
i_tabname = p_table
i_fieldname = p_field
input_text = p_value
importing
output_text = <fld>
exceptions
invalid_ddic_parameters = 1
invalid_input = 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.
endif.
endif.
if p_systm is not initial.
Default values for system fields
loop at it_x031l into is_x031l.
if is_x031l-dtyp = u2018CLNTu2019.
fixed_val sy-mandt.
elseif is_x031l-rollname = u2018ERDATu2019
or is_x031l-rollname = u2018ERSDAu2019
or is_x031l-rollname = u2018AEDATu2019
or is_x031l-rollname = u2018LAEDAu2019.
fixed_val sy-datum.
elseif is_x031l-rollname = u2018ERTIMu2019
or is_x031l-rollname = u2018AETIMu2019.
fixed_val sy-uzeit.
elseif is_x031l-rollname = u2018ERNAMu2019
or is_x031l-rollname = u2018AENAMu2019.
fixed_val sy-uname.
endif.
endloop.
endif.
endloop.
endform. u201Cf_modify_table
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
FORM f_display_table *
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
form f_display_table using in_table.
data: ob_table type ref to cl_salv_table,
ob_event type ref to cl_salv_events_table,
cx_error type ref to cx_salv_msg.
try.
call method cl_salv_table=>factory
importing
r_salv_table = ob_table
changing
t_table = in_table.
catch cx_salv_msg into cx_error.
exit.
endtry.
if p_displ is initial and
p_field is not initial.
call method ob_table->set_screen_status
exporting
report = u2018ZBC_UPDATE_TABLEu2019
pfstatus = u2018STANDARDu2019
set_functions = ob_table->c_functions_all.
ob_event = ob_table->get_event( ).
create object ob_appl.
set handler ob_appl->on_user_command for ob_event.
else.
call method ob_table->set_screen_status
exporting
report = u2018SAPLSALVu2019
pfstatus = u2018STANDARDu2019
set_functions = ob_table->c_functions_all.
endif.
call method ob_table->display.
endform. u201Cf_display_table
&u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
*& Form user_command
&u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
form user_command using in_command type salv_de_function.
data: l_messg type string,
l_answer type c.
data: ls_expr type string.
check in_command = u2018SAVEu2019.
l_messg = u2018Overwrite field for all selected records ?u2019.
call function u2018POPUP_TO_CONFIRMu2019
exporting
titlebar = u2018Update tableu2019
text_question = l_messg
default_button = u20182u2032
display_cancel_button = u2018 u2018
popup_type = u2018@1A@u2019
importing
answer = l_answer
exceptions
text_not_found = 1
others = 2.
if l_answer = u20181u2032.
concatenate p_field u2018= u201Du2019 into ls_expr
separated by space.
concatenate ls_expr p_value u201Du201D into ls_expr.
try.
update (p_table) set (ls_expr)
where (is_where-where_tab).
catch cx_sy_dynamic_osql_error.
rollback work.
message u2018Error during update!u2019 type u2018Iu2019.
endtry.
if sy-subrc = 0.
commit work.
endif.
endif.
endform. u201Cuser_command
&u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
*& Include ZBC_QUERY_EVENTS
&u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014
class lcl_handle_events definition deferred.
data: ob_appl type ref to lcl_handle_events.
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014-
CLASS lcl_handle_events DEFINITION
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014-
class lcl_handle_events definition.
public section.
methods:
on_user_command for event added_function of cl_salv_events
importing e_salv_function,
on_before_salv_function for event before_salv_function of cl_salv_events
importing e_salv_function,
on_after_salv_function for event after_salv_function of cl_salv_events
importing e_salv_function,
on_double_click for event double_click of cl_salv_events_table
importing row column,
on_link_click for event link_click of cl_salv_events_table
importing row column.
endclass. u201Clcl_handle_events DEFINITION
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014-
CLASS lcl_handle_events IMPLEMENTATION
u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014u2014-
class lcl_handle_events implementation.
method on_user_command.
perform user_command in program (sy-repid) if found
using e_salv_function.
endmethod. u201Con_user_command
method on_before_salv_function.
perform before_function in program (sy-repid) if found
using e_salv_function.
endmethod. u201Con_before_salv_function
method on_after_salv_function.
perform after_function in program (sy-repid) if found
using e_salv_function.
endmethod. u201Con_after_salv_function
method on_double_click.
perform double_click in program (sy-repid) if found
using row column.
endmethod. u201Con_double_click
method on_link_click.
perform link_click in program (sy-repid) if found
using row column.
endmethod. u201Con_single_click
endclass. u201Clcl_handle_events IMPLEMENTATION
thanks
karthik -
CL_SALV_TABLE to display details
It seems quite simple but I could not get it works. I need to write a report with header data and when double click on a selected line or click a push button to trigger event, it will show detailed data on a separate screen using CL_SALV_TABLE.
My program show the header data and it work the first time, but when I choose a different header line, it still show the same item data because I have a code when the object is not bound, display the data. I was able to get the correct header line and populate detailed data into the table. The only obstacle I have is that in my code it said
IF gr_cont IS NOT BOUND.
CREATE OBJECT gr_cont
EXPORTING
container_name = 'CONTAINER_100'
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE a052(zvn) WITH
' No container object found'.
ENDIF.
TRY.
cl_salv_table=>factory(
EXPORTING
* list_display = list_display
r_container = gr_cont
* container_name =
IMPORTING
r_salv_table = gr_alv
CHANGING
t_table = gt_orders
CATCH cx_salv_msg INTO gr_error.
ENDTRY.
* Display alv
gr_alv->display( ).
So when come the second time, the object is not initial. Please help. thanks.
PS: I can use cl_gui_alv_grid but I want to use factory method in cl_salv_table.
Edited by: Matt on Aug 18, 2009 9:21 PM - added tags surround the ABAP so it looks nice...You need to use
gr_alv->refresh( ).
Its works as same refresh_table_display in cl_gui_alv_grid
a® -
CL_SALV_TABLE - how to trigger Double_Click question
I am trying to find how to trigger an event on double click similar to using Event Double_Click in Class CL_GUI_ALV_GRID I am fresh out of the ABAP OO class and everything is a blur. This is what I did. I created a program that with
Data: r_grid TYPE REF TO cl_salv_table.
CALL METHOD CL_SALV_TABLE=>FACTORY
Importing R_SALV_TABLE = r_grid
Changing ITAB.
I then tried to create an Include program to define a Local Class
*& Include ZSD_DISPLAY_CUSTOMER
class lcl_event_handler definition.
PUBLIC SECTION.
METHODS: on_double_click for event double_click of cl_gui_alv_grid
METHODS: on_double_click for event double_click of cl_salv_table
IMPORTING es_row_no e_column.
ENDCLASS.
class lcl_event_handler IMPLEMENTATION.
METHOD on_double_click.
Data: IT_CUSTHIER type ZSD11_CUST_HIER_TABLE_TYPE.
Data: WK_CUSTHIER LIKE LINE OF IT_CUSTHIER.
types: BEGIN OF custhier_x,
custhier like WK_CUSTHIER,
number TYPE int4,
quantity type MENGE_D,
dollars_n_cents type DMBTR,
END OF custhier_x.
data: it_custhier_x type STANDARD TABLE OF custhier_x.
data: wk_custhier_x like LINE OF it_custhier_x.
read table it_custhier_x into wk_custhier_x
index es_row_no-row_id.
data: wk_vkorg type vkorg.
data: wk_vtweg type vtweg.
data: wk_spart type spart.
wk_vkorg = '3290'.
wk_vtweg = '00'.
wk_spart = '00'.
SET PARAMETER ID: 'KUN' field wk_custhier_x-custhier-kunnr.
SET PARAMETER ID: 'VKO' field wk_vkorg.
SET PARAMETER ID: 'VTW' field wk_vtweg.
SET PARAMETER ID: 'SPA' field wk_spart.
call TRANSACTION 'VD03' AND SKIP FIRST SCREEN.
ENDMETHOD.
ENDCLASS.
When I try to do a syntax check I get this error
The Handler Method ON_DOUBLE_CLICK is only defined for trigger objects of CL_GUI_ALV_GRID, but the system tried to register a trigger object of CL_SALV_TABLE
Any suggestions on what I need to do in order to trigger a event for double click ?
Thanks
Edited by: Bob Ackerman on Sep 22, 2010 11:25 AMI am not getting anything to happen on double click. In debug mode, I see that it calls program SAPLSLVC_FULLSCREEN and gets to FORM SELFIELD_GET which gets the row, column, and value of the field that was double clicked. But, nothing seems to be returned to my program. I am fresh out of the ABAP OO class and everything is a blur. My test program is listed below, if you would be so kind as to take a look and maybe see what I am missing.
Include program ZSD_DISPLAY_CUSTOMER
class lcl_event_handler definition.
PUBLIC SECTION.
** METHODS: on_double_click for event double_click of cl_gui_alv_grid
** IMPORTING es_row_no e_column.
METHODS:
on_DOUBLE_CLICK
FOR EVENT DOUBLE_CLICK OF cl_salv_events_table
IMPORTING
row
column .
ENDCLASS.
class lcl_event_handler IMPLEMENTATION.
METHOD on_double_click.
** data: it_sflight type TABLE OF sflight,
** wa_spfli type spfli.
Data: IT_CUSTHIER type ZSD11_CUST_HIER_TABLE_TYPE.
Data: WK_CUSTHIER LIKE LINE OF IT_CUSTHIER.
types: BEGIN OF custhier_x,
custhier like WK_CUSTHIER,
number TYPE int4,
quantity type MENGE_D,
dollars_n_cents type DMBTR,
END OF custhier_x.
data: it_custhier_x type STANDARD TABLE OF custhier_x.
data: wk_custhier_x like LINE OF it_custhier_x.
data: ls_row_id type lvc_s_row.
data: ls_col_id type lvc_s_col.
data: l_value type lvc_s_data-value.
data: ls_selfield type lvc_s_self.
data: ls_fieldcat type slis_fieldcat_alv.
data: ls_fieldcat_lvc type lvc_s_fcat.
data: wk_vkorg type vkorg.
data: wk_vtweg type vtweg.
data: wk_spart type spart.
wk_vkorg = '3290'.
wk_vtweg = '00'.
wk_spart = '00'.
SET PARAMETER ID: 'KUN' field wk_custhier_x-custhier-kunnr.
SET PARAMETER ID: 'VKO' field wk_vkorg.
SET PARAMETER ID: 'VTW' field wk_vtweg.
SET PARAMETER ID: 'SPA' field wk_spart.
call TRANSACTION 'VD03' AND SKIP FIRST SCREEN.
ENDMETHOD.
ENDCLASS.
In the main program :
CREATE OBJECT CUST_HIER
EXPORTING
IM_HIERARCHY_TYPE = 'A'
* IM_CUSTOMER_NUMBER =
IM_SALES_ORG = '3290'
IM_DIST_CHANNEL = '00'
IM_DIVISION = '00'
IM_VALIDITY_DATE = '99991215'.
CALL METHOD CUST_HIER->GET_CUSTHIER_NODES
IMPORTING EX_CUSTHIER = IT_CUSTHIER.
it_custhier_x = IT_CUSTHIER.
TRY.
CALL METHOD CL_SALV_TABLE=>FACTORY
* EXPORTING
* LIST_DISPLAY = IF_SALV_C_BOOL_SAP=>FALSE
* R_CONTAINER =
* CONTAINER_NAME =
IMPORTING
R_SALV_TABLE = r_grid
CHANGING
T_TABLE = IT_CUSTHIER_X.
CATCH CX_SALV_MSG .
ENDTRY.
*... §3 Functions
*... §3.1 activate ALV generic Functions
data: lr_functions type ref to cl_salv_functions_list.
lr_functions = r_grid->get_functions( ).
lr_functions->set_default( abap_true ).
*... set the columns technical
data: lr_columns type ref to cl_salv_columns.
lr_columns = r_grid->get_columns( ).
lr_columns->set_optimize( abap_true ).
perform set_columns_technical using lr_columns.
r_grid->display( ).
lr_events = r_grid->get_event( ).
create object gr_events.
set handler gr_events->on_double_click for lr_events.
Edited by: Bob Ackerman on Sep 22, 2010 5:30 PM
Edited by: Bob Ackerman on Sep 22, 2010 5:35 PM
Edited by: Bob Ackerman on Sep 22, 2010 5:37 PM -
How could control the scroll events in ALV OO?
Hello experts!
I'm programing a report, inside there is a field that need time of processing. I'm using ALV OO.
I have thought that it could only calculate the field for the lines that visualize.
How could control the scroll events to calculate the field of the visualized lines?
I'm using CL_SALV_TABLE class and cl_salv_events_table to control the events, but there aren't any event to control the scroll.
best regards!Hi Sriram,
I did view the information that you was attaching, but this don't resolve my problem. With methods get_scroll_info_via_id and set_scroll_info_via_id, we can get and put information of selection and view rows in the screen but we don't control when the user click in the scroll for advance or to back down a page.
I would like to refresh the data in ALV when the user view news rows.
I want your genial ideas.
Best regards! -
Hi,
Does anyone know how to create a context menu (right click on line or field) in the new ALV object model (class CL_SALV_TABLE)?
Thanks in advance
Keld Gregersen
PS: In the past we could use event CONTEXT_MENU_REQUEST in class CL_GUI_ALV_GRID, so it must be possibleI don't think there's "any such animal" in the new class. I'm not 100% certain however but the new class is only useful for fairly simple display only type grids.
There's no edit capability either.
I'd stick with cl_gui_alv_grid until there's some decent extra functionality in the cl_salv_table class.
It's fine for quick "bog standard" displays as it doesn't need a field catalog or any screens to be created by the user or developer - but you pay a price for that in limited fnctionality.
Cheers
jimbo -
Top of List event when using class cl_salv_hierseq_table
Hi all,
I am using above class to display Top of List .
I am to able to display one line at top using following :
gr_hierseq->set_top_of_list( lr_content ).
But i have to display 5 lines in top of list.
Please let me know how can this be achieved.
Thanks and Regards,
TaranamWow, that example did suck. Sorry for that. I have spent a little time revising the example program into such a form that you can easily see what you need to do. SO here it is, hope it helps. Pay close attention to the implementation of the on_top_of_page event handler method.
REPORT zsalv_demo_hierseq_form_events NO STANDARD PAGE HEADING.
TYPES: BEGIN OF g_type_s_master.
INCLUDE TYPE alv_chck.
TYPES: expand TYPE char01,
END OF g_type_s_master,
BEGIN OF g_type_s_slave.
INCLUDE TYPE alv_t_t2.
TYPES: END OF g_type_s_slave.
TYPES: BEGIN OF g_type_s_test,
amount TYPE i,
repid TYPE syrepid,
top_of_list TYPE i,
end_of_list TYPE i,
END OF g_type_s_test.
CONSTANTS: con_master TYPE lvc_fname VALUE 'ALV_CHCK',
con_slave TYPE lvc_fname VALUE 'ALV_T_T2'.
*... §5 Definition is later
CLASS lcl_handle_events_hierseq DEFINITION DEFERRED.
DATA: gs_test TYPE g_type_s_test.
DATA: gt_master TYPE STANDARD TABLE OF g_type_s_master,
gt_slave TYPE STANDARD TABLE OF alv_t_t2.
DATA: gr_hierseq TYPE REF TO cl_salv_hierseq_table.
*... §5 object for handling the events of cl_salv_table
DATA: gr_events_hierseq TYPE REF TO lcl_handle_events_hierseq.
* CLASS lcl_handle_events DEFINITION
CLASS lcl_handle_events_hierseq DEFINITION.
PUBLIC SECTION.
METHODS:
on_top_of_page FOR EVENT top_of_page OF cl_salv_events_hierseq
IMPORTING r_top_of_page page table_index.
ENDCLASS. "lcl_handle_events DEFINITION
* CLASS lcl_handle_events IMPLEMENTATION
CLASS lcl_handle_events_hierseq IMPLEMENTATION.
METHOD on_top_of_page.
DATA: lr_content TYPE REF TO cl_salv_form_element.
DATA: lr_grid TYPE REF TO cl_salv_form_layout_grid,
lr_grid_1 TYPE REF TO cl_salv_form_layout_grid,
lr_grid_2 TYPE REF TO cl_salv_form_layout_grid,
lr_label TYPE REF TO cl_salv_form_label,
lr_text TYPE REF TO cl_salv_form_text,
l_text TYPE string.
*... create a grid
CREATE OBJECT lr_grid.
*... in the cell [1,1] create header information
CONCATENATE 'TOP_OF_PAGE' text-h01 INTO l_text SEPARATED BY space.
lr_grid->create_header_information(
row = 1
column = 1
text = l_text
tooltip = l_text ).
*... add a row to the grid -> row 2
lr_grid->add_row( ).
*... in the cell [3,1] create a grid
lr_grid_1 = lr_grid->create_grid(
row = 3
column = 1 ).
*... in the cell [1,1] of the second grid create a label
lr_label = lr_grid_1->create_label(
row = 1
column = 1
text = 'Number of Records'
tooltip = 'Number of Records' ).
*... in the cell [1,2] of the second grid create a text
lr_text = lr_grid_1->create_text(
row = 1
column = 2
text = gs_test-amount
tooltip = gs_test-amount ).
lr_label->set_label_for( lr_text ).
*... in the cell [2,1] of the second grid create a label
lr_label = lr_grid_1->create_label(
row = 2
column = 1
text = 'Output Tool'
tooltip = 'Output Tool' ).
*... in the cell [2,2] of the second grid create a text
lr_text = lr_grid_1->create_text(
row = 2
column = 2
text = 'Seq List'
tooltip = 'Seq List').
lr_label->set_label_for( lr_text ).
*... in the cell [2,1] of the second grid create a label
lr_label = lr_grid_1->create_label(
row = 3
column = 1
text = 'Another Label'
tooltip = 'Another Label' ).
*... in the cell [2,2] of the second grid create a text
l_text = text-t15.
lr_text = lr_grid_1->create_text(
row = 3
column = 2
text = 'Another Text'
tooltip = 'Another Text').
lr_label->set_label_for( lr_text ).
*... content is the top grid
lr_content = lr_grid.
*... set the content
r_top_of_page->set_content( lr_content ).
ENDMETHOD. "on_top_of_page
ENDCLASS. "lcl_handle_events IMPLEMENTATION
* SELECTION-SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK gen WITH FRAME.
PARAMETERS:
p_amount TYPE i DEFAULT 30.
SELECTION-SCREEN END OF BLOCK gen.
* START-OF-SELECTION *
START-OF-SELECTION.
gs_test-amount = p_amount.
gs_test-repid = sy-repid.
*... §1 select data into global output table
PERFORM select_data.
* END-OF-SELECTION *
END-OF-SELECTION.
PERFORM display_hierseq.
*& Form select_data
* §1 select data into your global output table
FORM select_data.
FIELD-SYMBOLS: <ls_master> TYPE g_type_s_master.
DATA: lt_slave TYPE STANDARD TABLE OF g_type_s_slave.
SELECT * FROM (con_master)
INTO CORRESPONDING FIELDS OF TABLE gt_master
UP TO gs_test-amount ROWS. "#EC *
LOOP AT gt_master ASSIGNING <ls_master>.
SELECT * FROM (con_slave) INTO CORRESPONDING FIELDS
OF TABLE lt_slave
UP TO gs_test-amount ROWS
WHERE carrid EQ <ls_master>-carrid
AND connid EQ <ls_master>-connid. "#EC *
APPEND LINES OF lt_slave TO gt_slave.
ENDLOOP.
ENDFORM. " select_data
*& Form display_hierseq
* text
FORM display_hierseq.
DATA:lt_binding TYPE salv_t_hierseq_binding,
ls_binding TYPE salv_s_hierseq_binding.
DATA:lr_functions TYPE REF TO cl_salv_functions_list.
DATA:lr_columns TYPE REF TO cl_salv_columns_hierseq,
lr_column TYPE REF TO cl_salv_column_hierseq.
DATA:lr_level TYPE REF TO cl_salv_hierseq_level.
*... create the binding information between master and slave
ls_binding-master = 'MANDT'.
ls_binding-slave = 'MANDT'.
APPEND ls_binding TO lt_binding.
ls_binding-master = 'CARRID'.
ls_binding-slave = 'CARRID'.
APPEND ls_binding TO lt_binding.
ls_binding-master = 'CONNID'.
ls_binding-slave = 'CONNID'.
APPEND ls_binding TO lt_binding.
*... §2 create an ALV hierseq table
TRY.
cl_salv_hierseq_table=>factory(
EXPORTING
t_binding_level1_level2 = lt_binding
IMPORTING
r_hierseq = gr_hierseq
CHANGING
t_table_level1 = gt_master
t_table_level2 = gt_slave ).
CATCH cx_salv_data_error cx_salv_not_found.
ENDTRY.
*... Functions
*... activate ALV generic Functions
lr_functions = gr_hierseq->get_functions( ).
lr_functions->set_all( abap_true ).
*... *** MASTER Settings ***
TRY.
lr_columns = gr_hierseq->get_columns( 1 ).
CATCH cx_salv_not_found.
ENDTRY.
*... set the columns technical
TRY.
lr_column ?= lr_columns->get_column( 'MANDT' ).
lr_column->set_technical( if_salv_c_bool_sap=>true ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
*... set expand column
TRY.
lr_columns->set_expand_column( 'EXPAND' ).
CATCH cx_salv_data_error. "#EC NO_HANDLER
ENDTRY.
*... set items expanded
TRY.
lr_level = gr_hierseq->get_level( 1 ).
CATCH cx_salv_not_found.
ENDTRY.
lr_level->set_items_expanded( ).
*... *** GENERAL Settings ***
*... register to the events for top-of-page and end-of-page
DATA: lr_events TYPE REF TO cl_salv_events_hierseq.
lr_events = gr_hierseq->get_event( ).
CREATE OBJECT gr_events_hierseq.
SET HANDLER gr_events_hierseq->on_top_of_page FOR lr_events.
*... display the table
gr_hierseq->display( ).
ENDFORM. "display_hierseq
REgards,
RIch Heilman -
Non-standard aggregates in CL_SALV_TABLE
I'm working on a report, that has two levels - Room, Location. So I can have many rooms, each with a number of locations. Within each location I have a bunch of detail. So the report will look like:
Room Location data1 data2 somevalue....
1 A blah blah blah...
1 A blah blah blah...
1 B blah blah blah...
1 B blah blah blah...
1 C blah blah blah...
1 C blah blah blah...
2 X blah blah blah...
2 X blah blah blah...
2 Y blah blah blah...
So I'm happily using CL_SALV_TABLE and I come to the bit in the spec where it talks about aggregation. The requirement is: page break after each location, with min, max, total and average of somevalue. Fine.
Only they want standard deviation of somevalue , and the running total per room - so if the total for A is 20, B is 30 and C is 10, at the page break for A, they want 20, at the page break for B, they want 50 and at the page break of C, they want 60...
I'm guessing that I've got to ditch CL_SALV_TABLE, and go for a full CL_GUI_ALV_GRID implementation. Any advice? Ideas?
I can do it easily using list processing, but they want full ALV functionality...
thanks
mattYou may try with thee event END_OF_PAGE of the class CL_SALV_EVENTS_TABLE. Check the demo program SALV_DEMO_TABLE_FORM_EVENTS.
The perform CREATE_ALV_FROM_CONTENT_TOP might be helpful to you to read the content of the ALV.
Regards,
Naimesh Patel -
ALV OOPs: exception raised when SET_DATA method of CL_SALV_TABLE is used
Hi,
Scenario:
Result set is displayed in 2 ALV grids by using 2 different instances. I am using the methods of class CL_SALV_TABLE.
If the data is changed, I fetch the new data set and by using the method 'set_data'.
TRY.
instance_1->set_data(
CHANGING t_table = table1
instance_2->set_data(
CHANGING t_table = table2
CATCH cx_salv_no_new_data_allowed.
ENDTRY.
Issue:
The problem is that it raises the exception 'cx_salv_no_new_data_allowed' and thereby does not display the changed data.
I have tried to debug, and I found that in the 'set_data' method
if me->r_controller->is_new_data_allowed( ) eq if_salv_c_bool_sap=>false.
raise exception type cx_salv_no_new_data_allowed.
endif.
is executed and it returns the value 'false'.
This is because in the 'is_new_data_allowed', it checks
if r_adapter->function_call_active eq abap_true.
value = abap_false.
endif.
Can you please suggest how can i set the 'r_adapter->function_call_active' to abap_false .
Regards
s@kUnusually, CL_SALV_TABLE has quite good doco - in there the "set_data" method has the comments:
Caution:
You are not able to call these methods in an event handler. If you
do you will get an error.
Exceptions
o CX_SALV_NO_NEW_DATA_ALLOWED
You have called SET_DATA in an event handler.
I think you should be calling the "refresh" method instead - have a look at SAP's sample report SALV_DEMO_TABLE_REFRESH.
Jonathan -
CL_SALV_TABLE - refresh using a RTTS defined dynamic table
Hello,
I have defined a dynamic table using the RTTS method cl_abap_tabledescr=>create; the structure definition contains standard fields, custom fields and fields representing characteristics. The result a field symbol defined as standard table, <gt_data>. I'm using this table then to display a simple ALV list using cl_salv_table=>factory.
Problem: refreshing the data does not work. After the data has been changed (by jumping into the transaction and back to the ALV from a hotspot event), I re-read the data, CLEAR, UNASSIGN and ASSIGN the <gt_data> table again and call the cl_salv_table=>refresh method. The data in the <gt_data> table is being correctly set (verified via debugger), but the ALV does not update.
Any ideas?Hi Hans-Peter,
Not quite sure I understand the steps. I would expect that you have a global field symbol that represents your table. I'd expect that you'd construct this table once via RTTS functionality and then keep using that specific instance. The UNASSIGN/ASSIGN step sounds a bit suspicious to me, because it seems as if you're creating a new instance, whereas your ALV still points to the old instance you created. So then when calling the [refresh_table_display|http://help.sap.com/saphelp_erp2004/helpdata/en/0a/b5531ed30911d2b467006094192fe3/frameset.htm] method your updates might not take effect, because ALV still has the reference to the previous table you've constructed.
Cheers, harald -
Interactive event in SALV class
Hi Experts,
I have a requirement to develop an interactive report. I want use SALV class. Can any one explain me the event to handle double click/Hotspot click.
Thanks,
Suresh
Edited by: Suresh Nel on May 13, 2010 1:36 PM<h3> You will have to fetch the column first then use it to make the hotspot. then handle the event to do whatever you want. </h3>
eg-
data: lo_cols TYPE REF TO cl_salv_columns,
lo_column TYPE REF TO cl_salv_column_list,
**to display the salv
TRY.
CALL METHOD cl_salv_table=>factory
EXPORTING
list_display = IF_SALV_C_BOOL_SAP=>FALSE
r_container =
container_name =
IMPORTING
r_salv_table = i_salv_table
CHANGING
t_table = i_final
CATCH cx_salv_msg INTO lx_msg.
ENDTRY.
**to fetch all the column names into a single table
lo_cols = i_salv_table->get_columns( ).
**select the particular column
lo_column ?= lo_cols->get_column( 'COL_NAME' ).
**CHANGE THE CELL TYPE
CALL METHOD lo_column->set_cell_type
EXPORTING
value = IF_SALV_C_CELL_TYPE=>hotspot
DATA: lo_events TYPE REF TO cl_salv_events_table,
**local class to handle the events
lo_event_h TYPE REF TO lcl_event_handler.
event object
lo_events = i_salv_table->get_event( ).
event handler
CREATE OBJECT lo_event_h.
**method to handle the event
SEt HANDLER lo_event_h->on_click FOR lo_events. -
Hello!!
I have a problem because when I click on the button-luggweight. I can't see any message so my program can't detect any event.
I think that in my code I forget something but I don't know what. Anybody can help me, please?
ZBC405_INCLUDE_CLASS
CLASS LCL_HANDLER DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
ON_LINK_CLICK
FOR EVENT LINK_CLICK OF CL_SALV_EVENTS_TABLE
IMPORTING
ROW
COLUMN.
ENDCLASS.
CLASS LCL_HANDLER IMPLEMENTATION.
METHOD ON_LINK_CLICK.
CASE COLUMN.
WHEN 'LUGGWEIGHT'.
MESSAGE I041.
ENDCASE.
ENDMETHOD.
ENDCLASS.
ZBC405_05_COLUM_TOP
TABLES: SBOOK,SCARR,SFLIGHT.
TYPE-POOLS: COL,ICON.
TYPES: BEGIN OF ST_BOOK.
INCLUDE STRUCTURE SBOOK.
TYPES: IT_CELL_TYPES TYPE SALV_T_INT4_COLUMN,
IT_HYPERLINK TYPE SALV_T_INT4_COLUMN,
URL TYPE SERVICE_RL,
END OF ST_BOOK.
DATA: IT_BOOK TYPE TABLE OF ST_BOOK.
DATA: WA_BOOK LIKE LINE OF IT_BOOK,
WA_CELL_TYPES LIKE LINE OF WA_BOOK-IT_CELL_TYPES.
DATA: GR_ALV TYPE REF TO CL_SALV_TABLE,
LR_COLUMNS TYPE REF TO CL_SALV_COLUMNS_TABLE,
LR_COLUMN TYPE REF TO CL_SALV_COLUMN_TABLE.
ZBC405_05_COLUMN_PROGRAM
SELECT * FROM SBOOK INTO CORRESPONDING FIELDS OF WA_BOOK
WHERE CARRID = M_CARRID.
INSERT WA_BOOK INTO TABLE IT_BOOK.
ENDSELECT.
CALL METHOD CL_SALV_TABLE=>FACTORY
EXPORTING
LIST_DISPLAY = IF_SALV_C_BOOL_SAP=>FALSE
* R_CONTAINER =
* CONTAINER_NAME =
IMPORTING
R_SALV_TABLE = GR_ALV
CHANGING
T_TABLE = IT_BOOK.
PERFOM PESO.
FORM PESO.
LOOP AT IT_BOOK INTO WA_BOOK.
IF WA_BOOK-LUGGWEIGHT = 0
AND WA_BOOK-WUNIT = 'KG'
AND WA_BOOK-SMOKER = ' '.
CLEAR WA_CELL_TYPES.
WA_CELL_TYPES-COLUMNNAME = 'LUGGWEIGHT'.
WA_CELL_TYPES-VALUE = IF_SALV_C_CELL_TYPE=><b>BUTTON.</b>
APPEND WA_CELL_TYPES TO WA_BOOK-IT_CELL_TYPES.
ENDIF.
MODIFY IT_BOOK FROM WA_BOOK TRANSPORTING IT_CELL_TYPES.
ENDLOOP.
LR_COLUMNS = GR_ALV->GET_COLUMNS( ).
TRY.
LR_COLUMNS->SET_CELL_TYPE_COLUMN( VALUE = 'IT_CELL_TYPES' ).
CATCH CX_SALV_DATA_ERROR.
ENDTRY.
TRY.
CALL METHOD GR_ALV->GET_EVENT
RECEIVING
VALUE = LR_EVENT.
CATCH CX_SALV_DATA_ERROR.
ENDTRY.
SET HANDLER LCL_HANDLER=>ON_LINK_CLICK
FOR LR_EVENT.
ENDFORM. "PESO
thanks a lot.Hi Ana,
See the follow my example, it was based on 'SALV_DEMO_TABLE_EVENTS.
1 - It seems you forgetting to create a object of your class like
DATA: gr_events TYPE REF TO lcl_handle_events.
2 - You must instantiate this object like
CREATE OBJECT gr_events.
3 - You can set up your field as Hotspot with this statement
TRY.
lr_column ?= lr_columns->get_column( 'CARRID' ).
lr_column->set_cell_type( if_salv_c_cell_type=>hotspot ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
4 - You Must create and instantiate a object of class <b>cl_salv_events_table</b> responsible to get all events. You can do as follow
DATA: lr_events TYPE REF TO cl_salv_events_table.
lr_events = gr_table->get_event( ).
5 - You MUST active event handler for events that you want to work
SET HANDLER gr_events->on_link_click FOR lr_events.
<b>You can see it working running the code below. I hope I have helped you with this informations. Good Look !
Ps.: Don't forget to reward points for useful answers and close this thread when your question be answered !.
</b>
REPORT zsalv_event_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.
MESSAGE i000(0k) WITH 'You Clicked on Line'
row
'Of Column'
column.
ENDMETHOD. "on_single_click
ENDCLASS. "lcl_handle_events IMPLEMENTATION
DATA: gr_events TYPE REF TO lcl_handle_events.
DATA: gt_outtab TYPE STANDARD TABLE OF alv_tab.
DATA: gr_table TYPE REF TO cl_salv_table.
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 .
SELECT *
FROM alv_tab
INTO TABLE gt_outtab
UP TO p_amount ROWS.
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 ).
TRY.
lr_column ?= lr_columns->get_column( 'CARRID' ).
lr_column->set_cell_type( if_salv_c_cell_type=>hotspot ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
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
Regards.
Marcelo Ramos -
Hi All,
I am not trying to ask a interview question here.
I have come across many links ,many programs that talk about ALV display like REUSE_ALV_GRID_DISPLAY,CL_GUI_ALV_GRID,CL_SALV_TABLE but i am not able to clearly understand why is one more advantageous than another one and in what scenarios we need to use each one.
Can somebody help me /others who need similar clarification regarding these things
Thanks
Bala DuvvuriHi
1.REUSE_ALV_GRID_DISPLAY is used for displaying alv using functional module.It is more of a procedural approach.If you have used it in any of your programs that you would know that in order to do anythng in alv like displaying header or handling any event or anything else you have to make respective function(form) and internal tables and pass that function or internal table in the respective parameters of REUSE_ALV_GRID_DISPLAY.
2.CL_GUI_ALV_GRID is the oops approach for displaying alv.In this we don't use any functional modules.Instead of this we use the concept of classes and objects.
3.CL_SALV_TABLE is the also the oops approach but more efficient and advanced as compared to the above one.It is the main class used to create the simple 2D table it create a reference variable for this class.In this there is no need to create field catalog , table def. eveything can be handled dynamically....It is preferred to use this approach for alv.
Thanks
Maybe you are looking for
-
Need hard drive for docking station
I have the advanced docking station, and need to know which hard drives are compatible with the ultrabay. Also, do I need an adapter for the ultrabay?
-
Plant to plant stock transfer - CST
Hi Gurus, Our client has two plants in one company code but in different state.When stock transfer will happen from one plant to other plant can CST is applicable for the stock transfer????? If anybody knows the CIN process of STO between two plants,
-
How can I turn off the large blue location circle in apple maps?
How can I turn off the large blue location circle in apple maps, MacBook Pro 15 (2011)? It is to large. At times I need to zoom into my home location, but the large blue circle hides the location I need.
-
i downloaded a software known as driver booster to update my drivers, during the update the software closed and my pc shut down after then, my laptop had no sound and it din't come with a cd for re-installing drivers. plwase what do i do? My laptop i
-
How to make and Burn the project to DVD
Would you pleased advice me how to make and burn the Project to a DVD as I'm new user for the Adobe Premier Pro. Tks & B/regards, Handjojo