2010 Sep 04 10:25 AM
Hi Master's,
Can any one please guide me?
How to optimize the following code,
v_cond = 'MWST'.
perform seg_value using v_cond.
v_cond = 'ZAO1'.
perform seg_value using v_cond.
v_cond = 'ZAO2'.
perform seg_value using v_cond.
v_cond = 'ZAD3'.
perform seg_value using v_cond.
v_cond = 'ZADD'.
perform seg_value using v_cond.
.
.
. It goes like this....
Form seg_value using v_cond_type.
CLEAR: v_frt,int_edidd, int_z1eds02.
LOOP AT i_cond WHERE kschl = v_cond_type.
v_frt = v_frt + i_cond-kwert.
ENDLOOP.
CASE l_tcurx.
WHEN 0.
int_z1eds02-summe = v_frt * 100.
WHEN 1.
int_z1eds02-summe = v_frt * 10.
WHEN 2.
int_z1eds02-summe = v_frt.
WHEN 3.
int_z1eds02-summe = v_frt / 10.
WHEN 4.
int_z1eds02-summe = v_frt / 100.
WHEN 5.
int_z1eds02-summe = v_frt / 1000.
ENDCASE.
SELECT SINGLE * FROM t685t WHERE spras = 'E' AND kschl = v_cond_type.
int_z1eds02-kotxt = t685t-vtext.
CONDENSE int_z1eds02-summe NO-GAPS.
int_z1eds02-sumid = v_cond_type.
int_edidd-segnam = 'Z1EDS02'.
int_edidd-sdata = int_z1eds02.
IF v_frt <> 0.
APPEND int_edidd.
ENDIF.
endform.Edited by: sai.bala on Sep 4, 2010 2:56 PM
Edited by: sai.bala on Sep 4, 2010 2:58 PM
Edited by: sai.bala on Sep 4, 2010 2:58 PM
Edited by: Thomas Zloch on Sep 4, 2010 9:53 PM
@Ravishankar,
please ask before you recommend something which might be wrong!!!
LOOP AT i_cond
i_cond is probably very small, no optimization necessary
t685t is a buffered table, there is no hashed table copy necessary, the SELOECT SINGLE is fine !!!
I would that there is not performance problem at all, the code was only found be some useless code inspection!
So please analyse before you want to change
Siegfried
2010 Sep 04 8:55 PM
Optimize in what respect, apart from adding code tags (now done)?
Thomas
2010 Sep 06 11:39 AM
2010 Sep 07 7:30 AM
Hi,
LOOP AT i_cond WHERE kschl = v_cond_type.
v_frt = v_frt + i_cond-kwert.
ENDLOOP.
Define i_cond table as sorted table with non-unique key kschl.
SELECT SINGLE * FROM t685t WHERE spras = 'E' AND kschl = v_cond_type.
int_z1eds02-kotxt = t685t-vtext.
You can make changes as follows
Define it_t685t as hashed table with unique key kschl.
clear wa_int_t685t.
Read table it_t685t into wa_t685t with table key kschl = v_cond_type.
if sy-subrc ne 0.
SELECT SINGLE kschl vtext into wa_t685t
FROM t685t WHERE spras = 'E' AND kschl = v_cond_type.
insert wa_t685t into table it_t685t.
endif
int_z1eds02-kotxt = t685t-vtext
2010 Sep 07 12:00 PM
@Ravishankar,
please ask before you recommend something which might be wrong!!!
LOOP AT i_cond
i_cond is probably very small, no optimization necessary
t685t is a buffered table, there is no hashed table copy necessary, the SELOECT SINGLE is fine !!!
I would that there is not performance problem at all, the code was only found be some useless code inspection!
So please analyse before you want to change
Siegfried
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |