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 problem

Former Member
0 Likes
546

Hi friends ,

Below is the one of the perform in my program which is taking more time .. Can you please suggest me to find a solution to take less time for execution.

Thanks in Adv .

Varma ..

DATA: l_count TYPE i.

SELECT m~customer

m~name

m~payer

t~txtmd

INTO TABLE gt_cust2

FROM /bi0/pcustomer AS m

JOIN /bi0/tcustomer AS t

ON mcustomer EQ tcustomer

WHERE m~objvers EQ 'A'

AND m~accnt_grp NE space.

SORT gt_cust2 BY customer.

SELECT m~customer

m~name

m~payer

t~txtmd

INTO TABLE gt_cust

FROM /bi0/pcustomer AS m

JOIN /bi0/tcustomer AS t

ON mcustomer EQ tcustomer

WHERE m~objvers EQ 'A'

AND m~accnt_grp IN s_ktokd

AND m~payer NE space.

IF sy-subrc = 0.

SORT gt_cust BY customer.

LOOP AT gt_cust.

CLEAR l_count.

LOOP AT gt_cust2 WHERE payer = gt_cust-payer.

ADD 1 TO l_count.

IF l_count > 1.

EXIT.

ENDIF.

ENDLOOP.

gt_soldto-customer = gt_cust-customer.

gt_soldto-payer = gt_payer-payer = gt_cust-payer.

IF l_count > 1.

  • Payer found

CLEAR gt_cust2.

READ TABLE gt_cust2 WITH KEY customer = gt_cust-payer

BINARY SEARCH.

IF NOT gt_cust2-name IS INITIAL.

gt_payer-name = gt_cust2-name.

ELSE.

gt_payer-name = gt_cust2-txtmd.

ENDIF.

ELSE.

  • Stand alone customer

gt_soldto-payer = gt_payer-payer = p_nonpyr.

gt_payer-name = p_nonpnm.

ENDIF.

COLLECT: gt_soldto,

gt_payer.

ENDLOOP.

SORT: gt_soldto,

gt_payer.

ENDIF.

4 REPLIES 4
Read only

Former Member
0 Likes
523

ok what i would do is not to do 2 of such big selects.

your first select and your second select are almost identical.

Only yout got one more condition in your second select.

this again means your recordset you gain from your second select is just a subset of the reocrdset you gain with your first select.

This again means you dont need to go down to the DB another time, since all the data you need is already in your internal table you fill with your first select.

So in your first select you need to add the fields for which in your second select conditions exist.

Then you can do your second select not on the DB-table but on your internal table.

Statement for this is "READ TABLE" instead of SELECT.

Read only

0 Likes
523

Are there any other ways ... Please suggest ..

Thanks ,

Varma

Read only

dev_parbutteea
Active Contributor
0 Likes
523

HI,

LOOP AT gt_cust.<b>use loop assigning field symbol</b>

CLEAR l_count.

<b>LOOP AT gt_cust2 WHERE payer = gt_cust-payer.

ADD 1 TO l_count.

IF l_count > 1.

EXIT.

ENDIF.

ENDLOOP.</b>

just do a read gt_cust2 into Wa_cust2 where payer = gt_cust-payer

Read only

Former Member
0 Likes
523

hi varma,

use for all entries instead of innerjoin and try to avoid nested loops.

regards,

seshu.