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

Performance of below code

Former Member
0 Likes
546

Hi All ,

I have to modifying two tables ts_Z3rl_docket ,ts_z2rlbasedat .

table ts_z2rlbasedat has got multiple entries for one in ts_Z3rl_docket . These two tables are linked by another table ts_ Z3rl_docket_umi.

Please advice if trhere is better way than the below to do this for perfomrance.Thanks

loop at ts_docket_dates into wa_docket_dates.

read table ts_Z3rl_Docket into wa_Z3rl_docket with key Zudr = wa_docket_dates-Zudr .

if sy-subrc ne 0 .

perform append_error_table .

delete ts_docket_dates .

else.

perform Validate_dates .

if wa_error is initial.

Move :

wa_docket_dates-dod_move to wa_z3rl_docket-dod_move,

wa_docket_dates-dor_move to wa_Z3rl_docket-dor_move,

wa_docket_dates-Zeffdate to wa_Z3rl_docket-Zeffdate.

*

modify ts_Z3rl_docket from wa_Z3rl_docket index sy-tabix.

loop at Ts_z3rl_docket_umi into wa_Z3rl_docket_umi where Zudr = wa_Z3rl_docket-Zudr.

read table ts_z2rlbasedat into wa_z2rlbasedat with key ZZumicur = wa_Z3rl_docket_umi-ZZumicur.

move :wa_docket_dates-dod_move to wa_z2rlbasedat-dod_move,

wa_docket_dates-dod_move to wa_z2rlbasedat-dod_date,

wa_docket_dates-dor_move to wa_z2rlbasedat-dor_move,

wa_docket_dates-dor_move to wa_z2rlbasedat-dor_date.

modify ts_z2rlbasedat from wa_z2rlbasedat index sy-tabix.

endloop.

1 ACCEPTED SOLUTION
Read only

mvoros
Active Contributor
0 Likes
528

Hi,

you can improve performance of your read statements. You will have to sort table by key and then add key work BINARY SEARCH into your read statements.

Cheers

4 REPLIES 4
Read only

mvoros
Active Contributor
0 Likes
529

Hi,

you can improve performance of your read statements. You will have to sort table by key and then add key work BINARY SEARCH into your read statements.

Cheers

Read only

Former Member
0 Likes
528

Hello Vinay,

You can achieve a better performance using FIELD-SYMBOLS instead of DATA structures in the LOOP and READ statements:

FIELD-SYMBOLS: <fs_ts_docket_dates> like wa_docket_dates,
                            <fs_ts_Z3rl_Docket>   like wa_Z3rl_Docket.
...
...
loop at ts_docket_dates assigning <fs_ts_docket_dates>.
read table ts_Z3rl_Docket assigning <fs_ts_Z3rl_docket> with key Zudr = <fs_ts_docket_dates>-Zudr .
...
....
<fs_ts_docket_dates>-dod_move to <fs_ts_z3rl_docket>-dod_move,
<fs_ts_docket_dates>-dor_move to <fs_ts_Z3rl_docket>-dor_move,
<fs_ts_docket_dates>-Zeffdate to <fs_ts_Z3rl_docket>-Zeffdate.

* no Modify statement required

ENDLOOP.

* In the following statements the INTO can be replaced as well by ASSIGNING

loop at Ts_z3rl_docket_umi into wa_Z3rl_docket_umi where Zudr = wa_Z3rl_docket-Zudr.


read table ts_z2rlbasedat into wa_z2rlbasedat with key ZZumicur = wa_Z3rl_docket_umi-ZZumicur.
move :wa_docket_dates-dod_move to wa_z2rlbasedat-dod_move,
wa_docket_dates-dod_move to wa_z2rlbasedat-dod_date,
wa_docket_dates-dor_move to wa_z2rlbasedat-dor_move,
wa_docket_dates-dor_move to wa_z2rlbasedat-dor_date.
modify ts_z2rlbasedat from wa_z2rlbasedat index sy-tabix.


endloop.

Using the ASSIGNING clause saves you a lot of data transfer time.

Try it,

Heinz

Read only

Former Member
0 Likes
528

your coding does not only scale quadratically but cubicly i.e. ion order 3. That is slow.

Please use nested loops only if the inner tables are either sorted tables or standard tables which are sorted and binary search is used.

For details read here:

Measurements on internal tables: Reads and Loops:

/people/siegfried.boes/blog/2007/09/12/runtimes-of-reads-and-loops-on-internal-tables

Replace not ony the reads but also the loop at Ts_z3rl_docket_umi

Siegfried

Read only

Former Member
0 Likes
528

Thanks A lot . I have made the required as chnages suggested .