Cl_salv_table
hi,
I am running sap 6.40 ....and i dont find any ref to cl_Salv_table....how we should use this..
hi
good
Methods
Function
Class
Method
Refresh ALV output without deleting filter and sort settings
CL_SALV_TABLE
CL_SALV_HIERSEQ_TABLE
REFRESH
(Parameter REFRESH_MODE: SOFT)
Refresh ALV output and delete filter and sort settings
REFRESH
(Parameter REFRESH_MODE: FULL)
go through this link
/people/sap.user72/blog/2005/09/14/a-new-approach-to-alv-programming
thanks
mrutyun^
Similar Messages
-
Header and footer in ALV using CL_SALV_TABLE
How to add header and footer for an ALV report using CL_SALV_TABLE. I know how to add header lr_table->set_top_of_list_print( lr_header )
but how do I make it aligned center.
Also how to add a footer
I want it to look like Current page of total pages
What is the system variable for total pages.Hi,
this should be the Method:
SET_END_OF_LIST_PRINT
Best Regards -
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 -
How to get custom PF status in ALV using cl_salv_table (Using a container)
I created a screen and inside that a container.I tried for an ALV display using CL_SALV_TABLE in the cvontainer. It's working. when I opted for default PF status.It's working. But when I tried for custom PF status using SET_SCREEN_STATUS method, it's throwing some exception. But it's working if I don't use a container .
In both the cases I copied PF status into my program from some standard program.Then added some functionality.I f you are using Screen and container use CLass:
CL_GUI_ALV_CONTAINER
CL_GUI_ALV_GRID
METHOD-->SET_TABLE_FOR_FIRST_DISPLAY " to display Alv.
Create PF-STATUS in PBO of screen.
[Change standard PF|https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/change%252balv%252bstandard%252btoolbar%252band%252brespond%252bit]
EXCLUDE Certain buttons on standard toolbar:
DATA: lt_exclude TYPE ui_functions,
ls_exclude TYPE ui_func.
ls_exclude = cl_gui_alv_grid=>mc_fc_sum.
APPEND ls_exclude TO lt_exclude.
CLEAR ls_exclude.
ls_exclude = cl_gui_alv_grid=>mc_mb_filter.
APPEND ls_exclude TO lt_exclude.
CLEAR ls_exclude.
ls_exclude = cl_gui_alv_grid=>mc_mb_sum.
APPEND ls_exclude TO lt_exclude.
pass lt_exclude to METHOD-->SET_TABLE_FOR_FIRST_DISPLAY
Regards,
Gurpreet -
How to print all pages using ALV from CL_SALV_TABLE?
Dear friends,
I have a report which displays a dynamic internal table using CL_SALV_TABLE. The display format is normal list.
And since this dynamic internal table is big, I have divided it into a sub internal table which displays 10 columns in one page at one time. And each page is displayed using a customized button that I set as MyFunction.
The problem is, when I click List->Print or Ctrl-P, the system will only send to spool the current page even though in the Print dialog box, I choose Print All option.
Is there a way to rectify this? Thanks.Hi,
Try this..code...the above FM expects purchasing organization..revised code below mentioned..
please try..
DATA: kdy_val(8) VALUE '/110'.
SET PARAMETER ID 'LIF' FIELD 'VENDOR'. " Pass the vendor
SET PARAMETER ID 'KDY' FIELD KDY_VAL.
CALL TRANSACTION 'XK03' AND SKIP FIRST SCREEN.
Thanks
Naren -
Refresh cl_salv_table= factory attached to a Docking Container
Hi Gurus!!
I have a issue with a cl_salv_table=>factory attached to a Docking Container.
Here is my code set up, which might be wrong actually:
I've created a simple report, with a TOP and some include for PBO, PAI and routines. In the Report, I call a Screen, here 2000.
The TOP contains
DATA: docking_container TYPE REF TO cl_gui_docking_container,
gc_table_alv TYPE REF TO cl_salv_table.
The Screen Flow is basic:
PROCESS BEFORE OUTPUT.
MODULE status_2000.
PROCESS AFTER INPUT.
MODULE user_command_2000.
With status_2000:
MODULE status_2000 OUTPUT.
SET PF-STATUS 'STATUS'.
* SET TITLEBAR 'xxx'.
* Initialization of docking container
IF docking_container IS INITIAL.
CREATE OBJECT docking_container
EXPORTING
side = cl_gui_docking_container=>dock_at_bottom
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0. MESSAGE a500. ENDIF.
CALL METHOD docking_container->set_height
EXPORTING
height = 170.
ENDIF.
ENDMODULE. " STATUS_2000 OUTPUT
Then the Screen PAI looks dumb, but in this example, I have drastically made the code simplerI think you are not releasing proxy object with method FREE of docking container.
Check the below code. It first displays SFLIGHT table, then after another dialog step is concluded, it shows SPFLI table.
DATA: r_dock_container TYPE REF TO cl_gui_docking_container,
r_salv_table TYPE REF TO cl_salv_table.
DATA: it_sflight TYPE sflight OCCURS 0,
it_spfli TYPE spfli OCCURS 0.
DATA: count TYPE i.
START-OF-SELECTION.
SELECT * FROM sflight INTO TABLE it_sflight UP TO 10 ROWS.
SELECT * FROM spfli INTO TABLE it_spfli UP TO 10 ROWS.
CALL SCREEN 0200.
MODULE pbo OUTPUT.
SET PF-STATUS space.
IF count IS INITIAL.
CREATE OBJECT r_dock_container
EXPORTING
side = cl_gui_docking_container=>dock_at_bottom
EXCEPTIONS
OTHERS = 1.
CALL METHOD r_dock_container->set_height
EXPORTING
height = 170.
CALL METHOD cl_salv_table=>factory
EXPORTING
r_container = r_dock_container
IMPORTING
r_salv_table = r_salv_table
CHANGING
t_table = it_sflight.
* ALV Display
r_salv_table->display( ).
ELSE.
r_dock_container->free( ). "this is crucial to release proxy object of docking container
CLEAR r_dock_container. "and clear a reference variable (with these two statements your control will disapear from screen)
"now you can create a new one and bound a new ALV to it
CREATE OBJECT r_dock_container
EXPORTING
side = cl_gui_docking_container=>dock_at_bottom
EXCEPTIONS
OTHERS = 1.
CALL METHOD r_dock_container->set_height
EXPORTING
height = 170.
CALL METHOD cl_salv_table=>factory
EXPORTING
r_container = r_dock_container
IMPORTING
r_salv_table = r_salv_table
CHANGING
t_table = it_spfli.
* ALV Display
r_salv_table->display( ).
ENDIF.
ADD 1 TO count .
ENDMODULE.
Of course you have to adjust it with your tables and data, but this works fine
Regards
Marcin
Edited by: Marcin Pciak on Jun 16, 2009 12:57 PM -
How to hide columns in ALV? (via cl_salv_table)
Dear forumers,
Is there a way for me to hide a few columns (or data fields) from being displayed in the ALV table, using the cl_salv_table method?
FORM display_data_alv .
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = o_table
CHANGING
t_table = i_ro_assets.
CATCH cx_salv_msg.
ENDTRY.
o_functions = o_table->get_functions( ).
o_functions->set_all( abap_true ).
o_columns = o_table->get_columns( ).
o_columns->set_optimize( abap_true ).
PERFORM set_columns.
o_events = o_table->get_event( ).
CREATE OBJECT o_handle_events.
SET HANDLER o_handle_events->on_double_click FOR o_events.
o_table->display( ).
ENDFORM. " DISPLAY_DATA_ALV
FORM set_columns .
TRY.
o_column ?= o_columns->get_column( 'BUKRS' ).
o_column->set_long_text( text-008 ).
CATCH cx_salv_not_found.
ENDTRY.
TRY.
o_column ?= o_columns->get_column( 'ANLN1' ).
o_column->set_long_text( text-009 ).
CATCH cx_salv_not_found.
ENDTRY.
ENDFORM. " SET_COLUMNS
I have also tried to exclude some columns from the subroutine SET_COLUMNS, but they are still showing in the resulting ALV table. What can I do here next?
Appreciate any help here.
Thanks very much.You can use the method SET_COLUMN_TECHNICAL of the class CL_SALV_COLUMN to hide the Column.
data:
ir_columns type ref to cl_salv_columns_table,
lr_column type ref to cl_salv_column.
try.
lr_column = ir_columns->get_column( 'MANDT' ).
lr_column->set_technical( if_salv_c_bool_sap=>true ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
Check the report SALV_DEMO_TABLE_COLUMNS to know more about the Column processing in SALV model.
Regards,
Naimesh Patel -
Subtotal in ALV using class cl_salv_table
Hello All,
I am displaying a LAV using the class 'cl_salv_table'. I want to do a sub total on a field and at the end of each plant data I want to display the custom text "Total for Plant 'P1' " in the subtotal line.
Please help me solve this.
Thanks,
AnjuHi,
Firstly , add TEXT field your internal table. Then, fill this field.
loop at itab.
at the end of plant.
itab-text = 'Sub total text'.
endat.
modify itab.
endloop.
Secondly,
In fieldcat:
loop at pt_fieldcat into ls_fcat .
case ls_fcat-fieldname .
when 'TEXT'.
ls_fcat-col_pos = '1'.
ls_fcat-tech = 'X'.
ls_fcat-no_out = 'X'.
modify pt_fieldcat from ls_fcat.
endcase.
Thirdly;
In Sort:
ls_sort-fieldname = 'TEXT' .
ls_sort-subtot = 'X'.
ls_sort-up = 'X'.
append ls_sort to pt_sort. -
How to enable the check box using cl_salv_table?
Hi Experts,
what code will change for to enable the check box in the following Report program?
REPORT ZMA_ALV_OOPS2.
TABLES:MARA.
TYPES:BEGIN OF T_MARA,
SEL TYPE C,
MATNR TYPE MARA-MATNR,
WERKS TYPE MARC-WERKS,
LGORT TYPE MARD-LGORT,
LABST TYPE MARD-LABST,
END OF T_MARA.
DATA:TB_MARA TYPE STANDARD TABLE OF T_MARA,
WA_MARA TYPE T_MARA.
DATA: GR_TABLE TYPE REF TO CL_SALV_TABLE.
DATA: GR_FUNCTIONS TYPE REF TO CL_SALV_FUNCTIONS.
DATA: GR_DISPLAY TYPE REF TO CL_SALV_DISPLAY_SETTINGS.
DATA: GR_COLUMNS TYPE REF TO CL_SALV_COLUMNS_TABLE.
DATA: GR_COLUMN TYPE REF TO CL_SALV_COLUMN_TABLE.
DATA: GR_SORTS TYPE REF TO CL_SALV_SORTS.
DATA: GR_AGG TYPE REF TO CL_SALV_AGGREGATIONS.
DATA: GR_FILTER TYPE REF TO CL_SALV_FILTERS.
DATA: GR_LAYOUT TYPE REF TO CL_SALV_LAYOUT.
DATA: GR_PRINT TYPE REF TO CL_SALV_PRINT.
DATA: GR_SELE TYPE REF TO CL_SALV_SELECTIONS.
DATA: GC_TRUE TYPE SAP_BOOL VALUE 'X'.
DATA: GR_ITEM TYPE REF TO CL_SALV_ITEM.
DATA: COLUMNNAME TYPE REF TO LVC_FNAME.
top of list for CCL
DATA: GR_CONTENT_CCL TYPE REF TO CL_SALV_FORM_ELEMENT.
DATA: GR_COL TYPE REF TO CL_SALV_COLUMN.
DATA: LT_SORT TYPE SALV_T_SORT_REF,
LS_SORT TYPE SALV_S_SORT_REF,
L_SEQUENCE TYPE SALV_DE_SORT_SEQUENCE,
T_SORT TYPE REF TO SALV_T_SORT_REF.
DATA: KEY TYPE SALV_S_LAYOUT_KEY.
DATA: COLOR TYPE LVC_S_COLO.
DATA: GR_EVENTS TYPE REF TO CL_SALV_EVENTS_TABLE.
DATA: GR_SELECTIONS TYPE REF TO CL_SALV_SELECTIONS.
**--Selection screen
SELECT-OPTIONS:S_MATNR FOR MARA-MATNR.
SELECT MATNR WERKS LGORT LABST
FROM MARD
INTO CORRESPONDING FIELDS OF TABLE TB_MARA
WHERE MATNR IN S_MATNR.
TRY.
CALL METHOD CL_SALV_TABLE=>FACTORY
IMPORTING
R_SALV_TABLE = GR_TABLE
CHANGING
T_TABLE = TB_MARA.
CATCH CX_SALV_MSG.
ENDTRY.
GR_TABLE->SET_SCREEN_STATUS(
PFSTATUS = 'SALV_TABLE_STANDARD'
REPORT = SY-REPID
SET_FUNCTIONS = GR_TABLE->C_FUNCTIONS_ALL ).
GR_FUNCTIONS = GR_TABLE->GET_FUNCTIONS( ).
GR_FUNCTIONS->SET_ALL( ABAP_TRUE ).
GR_DISPLAY = GR_TABLE->GET_DISPLAY_SETTINGS( ).
GR_SELE = GR_TABLE->GET_SELECTIONS( ).
GR_SELE->SET_SELECTION_MODE( ).
GR_TABLE->SET_TOP_OF_LIST( GR_CONTENT_CCL ).
*--- To change the column headings
GR_COLUMNS = GR_TABLE->GET_COLUMNS( ).
GR_COLUMNS->SET_OPTIMIZE( GC_TRUE ).
GR_SORTS = GR_TABLE->GET_SORTS( ).
TRY.
GR_COLUMN ?= GR_COLUMNS->GET_COLUMN( 'SEL' ) .
GR_COLUMN->SET_CELL_TYPE( IF_SALV_C_CELL_TYPE=>CHECKBOX ).
GR_COLUMN->SET_LONG_TEXT( 'CHECKBOX' ).
CATCH CX_SALV_NOT_FOUND.
ENDTRY.
GR_COLUMN->SET_CELL_TYPE( 6 ).
GR_COLUMN->SET_SHORT_TEXT( 'Check Box' ).
GR_COLUMN->SET_LONG_TEXT( 'Check Box' ).
******Check box edit
TRY.
GR_SORTS->ADD_SORT( COLUMNNAME = 'MATNR' SEQUENCE =
IF_SALV_C_SORT=>SORT_UP ).
CATCH CX_SALV_DATA_ERROR
CX_SALV_NOT_FOUND
CX_SALV_EXISTING.
ENDTRY.
GR_LAYOUT = GR_TABLE->GET_LAYOUT( ).
KEY-REPORT = SY-REPID.
GR_LAYOUT->SET_KEY( KEY ).
GR_LAYOUT->SET_SAVE_RESTRICTION( CL_SALV_LAYOUT=>RESTRICT_NONE ).
TRY.
GR_COLUMN ?= GR_COLUMNS->GET_COLUMN( 'MATNR' ).
CATCH CX_SALV_NOT_FOUND.
ENDTRY.
COLOR-COL = '8'.
COLOR-INT = '0'.
COLOR-INV = '1'.
GR_COLUMN->SET_COLOR( COLOR ).
GR_TABLE->DISPLAY( ).
Thanks,
Mahesh.Hi,
You can use the method set_selection_mode to automatically show the checkbox for each row..and use the method get_selected_rows to get the rows selected..
Check this sample report..
TYPES: BEGIN OF type_output,
matnr TYPE matnr,
END OF type_output.
DATA:lt_output TYPE STANDARD TABLE OF type_output,
lwa_rows TYPE int4,
lwa_output TYPE type_output,
lt_rows TYPE salv_t_row.
* Local declarations.
DATA: lr_table TYPE REF TO cl_salv_table,
lr_selections TYPE REF TO cl_salv_selections.
DATA: lr_columns TYPE REF TO cl_salv_columns_table.
START-OF-SELECTION.
* Prepare data.
lwa_output-matnr = 'TEST1'.APPEND lwa_output TO lt_output.
lwa_output-matnr = 'TEST2'.APPEND lwa_output TO lt_output.
lwa_output-matnr = 'TEST3'.APPEND lwa_output TO lt_output.
* Call the factory method
TRY.
cl_salv_table=>factory(
EXPORTING
list_display = 'X'
IMPORTING
r_salv_table = lr_table
CHANGING
t_table = lt_output ).
CATCH cx_salv_msg. "#EC NO_HANDLER
ENDTRY.
* Column selection
lr_selections = lr_table->get_selections( ).
lr_selections->set_selection_mode( if_salv_c_selection_mode=>row_column ).
lr_columns = lr_table->get_columns( ).
lr_columns->set_optimize( abap_true ).
* Display
lr_table->display( ).
* Get the selected rows.
lt_rows = lr_selections->get_selected_rows( ).
* Display the selected rows.
LOOP AT lt_rows INTO lwa_rows.
READ TABLE lt_output INTO lwa_output INDEX lwa_rows.
WRITE: / lwa_output-matnr.
ENDLOOP.
Thanks
Naren -
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 -
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 -
Anybody got an idea how to add EDIT to cl_salv_table class
I like the simplicity of the new CL_SALV_TABLE class - however as most of us realize it DOES lack edit capability.
What makes it really nice of course is that it at the basic level doesn't need any screens or even a field catalog to be defined / programmed by the user.
The cl_gui_alv_grid has all this functionality of course but is much more complex to use (judging by the number of posts we get on this Forum still using the old SLIS function module non OO version of ALV GRID reporting).
I was just wondering how difficult it would be to either add EDIT capability (user defined Z-class inheriting the cl_salv_table class) or have some simple link to CL_GUI_ALV_GRID from CL_SALV_TABLE.
Any ideas here would be great.
I really can't understand why SAP didn't build this in -- loads of processing today does actuallly require some type of user interaction -- pure display stuff is a very 1980's type idea - especially when typical work stations (and servers) had minimal power compared to todays systems.
Cheers
jimboI've had a quick look, and I think this would be a non-trivial task! We're blocked from inheritance, (the class is final - grrr - ), so we're left with composition or flow-through.
The problem with either of these techniques is that we've only got access to public attributes and methods.
A place to start would be to identify the relationship between cl_salv_table and CL_GUI_ALV_GRID. I've not found it yet...
matt -
How to disable generic alv buttons in CL_SALV_TABLE?
I am needing to disable individually the generic alv buttons in CL_SALV_TABLE.
I see how to disable buttons by group. eg-
lr_functions->set_group_export( abap_false ).
lr_functions->set_group_filter( abap_false ).
lr_functions->set_group_sort( abap_false ).
etc....
However, I cannot find source codes to disable individual buttons. Is it possible to do this?... and if so would appreciate an example coding.
Best Regards,
Dean Atteberry.There are method available in the class CL_SALV_FUNCTIONS_LIST which can be helpful to active / deactive certain button.
Like: To remove the SORT Ascending button:
data: lr_functions type ref to cl_salv_functions_list.
lr_functions = gr_table->get_functions( ).
lr_functions->SET_SORT_ASC( ).
Regards,
Naimesh Patel -
Changing Column header text ol ALV: Object ref cl_salv_table
Hi Friends,
my code:
TRY.
CALL METHOD cl_salv_table=>factory(
EXPORTING
r_container = gv_custom_container
container_name = 'CUSTOM_300'
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = gt_itab_email ).
CATCH cx_salv_msg. "#EC NO_HANDLER
CLEANUP.
ENDTRY.
activate ALV generic Functions
DATA: lr_functions TYPE REF TO cl_salv_functions_list.
TRY.
lr_functions = gr_table->get_functions( ).
lr_functions->set_default( abap_true ).
gr_columns = gr_table->get_columns( ).
PERFORM change_columns_text USING gr_columns.
gr_columns->set_exception_column( value = 'LIGHTS' ).
CATCH cx_salv_data_error.
CLEANUP.
ENDTRY.
CALL METHOD gr_table->display.
Problem:
Can someone give me tips on how to change the Column text of the return table gr_table in my code.
I would like to change the text before CALL METHOD gr_table->display.
Thanks
BlackyYou need to get the perticular column object from the COLUMNS object
Like:
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( ).
try.
lr_column ?= lr_columns->get_column( 'FIELD1' ).
lr_column->set_short_text( 'Custom Text' ).
lr_column->set_medium_text( 'Custom Text' ).
lr_column->set_long_text( 'Custom Text' ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
Check report: SALV_DEMO_TABLE_COLUMNS
Regards,
Naimesh Patel -
How to have header for CL_SALV_TABLE displayed in custom container?
Hello ABAP Objects Community, I am trying to write report using CL_SALV_TABLE and using a screen created in SE51 with a custom container control in which to put ALV grid. However, when I try to put a header on the table, it does not display.
In reading the SAP help for "Display List Header and Footer", there is a grid that shows under what conditions the SET_TOP_OF_LIST can be used. eg- Classic ABAP List, FullScreen, InTheContainer. And for InTheContainer it is showing "No".
I found the demo program SALV_DEMO_TABLE_SELECTIONS. Look at form d0100_pbo. This is what I am trying to do, except that I want it to have headers/footers.
If it is not possible to have headers/footers when using CL_SALV_TABLE in a container, what would be the coding technique for achieving this?
Best Regards,
Dean Atteberry.
Edited by: Dean Atteberry on Jul 27, 2009 11:01 PM
Edited by: Dean Atteberry on Jul 27, 2009 11:03 PM
Edited by: Dean Atteberry on Jul 27, 2009 11:03 PMThank you, Marcin, for your reply.
I implemented Namish Patel's code for exercises #1 (basic program) and #5 (header/footer) in abap and ran same. It created alv grid with headers/footers. However, upon looking at his factory statement, it is using the (default) "fullscreen" display type. I am needing to put the alv grid in a container created on a screen in SE51, so am having to use the EXPORTING statement with parameters r_container (points to container object instance) and container_name (literal string name of component).
I found a description of how to use the ABAP control framework in ERPGenie that shows how to do what I was needing.
[http://www.erpgenie.com/sap-technical/abap/abap-control-framework]
Thank you again for responding to my question.
Dean Atteberry.
Edited by: Dean Atteberry on Jul 28, 2009 10:09 PM
Maybe you are looking for
-
How to change header status of a sales order
Hi people, can anybody suggest me a FM for changing sales order header status (say from partailly complete to completed). Regards, Sandy
-
Can't download Firefox on my mac-get "Safari error/domain error 2"
I mac-OS x Wont download Firefox/ need it to support Auctiva website. Have tried a few times/ keep getting "the operation couldn't be completed" Safari error.
-
Can sombody tell me how the RAC instance will start. I know like CSS is the first process to start and then what happens how everything comes up. Thanks
-
Hello, I heard of a new kind of layout by Sun which is easier than using GridBagLayout. Did anybody know something about it? If yes, why do i have to use this kind of layout instaed of GridBagLayout? Is JBuilder the best tool to create Java GUI ? Che
-
Infoset vs Indexed nested loop
Hello all, i have an requirement in which i need to fetch data from several tables almost 6-8 tables (eventually to IT). right now i am fetching data using Select stmt using For all entries addition. So my requirement is to combine them into a big