Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Program using class "cl_salv_table"

Former Member
0 Likes
967

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.

1 REPLY 1
Read only

Former Member
0 Likes
479

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