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

Select Query optimisation

Former Member
0 Likes
728

Hi.

Is there any way to optimise the below code. or can i write a join query for this if yes then how.

SELECT land1

zone1

FROM tzone

INTO CORRESPONDING FIELDS OF TABLE t_land

FOR ALL ENTRIES IN int_delivery

WHERE zone1 = int_delivery-zone1.

IF sy-subrc = 0.

SELECT land1

landx

FROM t005t

INTO CORRESPONDING FIELDS OF TABLE t_landx

FOR ALL ENTRIES IN t_land

WHERE land1 = t_land-land1.

ENDIF.

Thanks

Any help will not go unappreciated..

1 ACCEPTED SOLUTION
Read only

anversha_s
Active Contributor
0 Likes
699

hi,

<i>how to optimize ?</i>

1. Avoid

INTO CORRESPONDING

, create an internal table with required fields only.

2.

select tzone~land1 tzone~zone1 t005~landx
from tzone 
join t005t
on tzone~land1 = t005t~land1
into table t_landx
for all entries in int_delivery
where
tzone~zone1 = int_delivery-zone1
AND spras = sy-langu.

Regards

Anver

5 REPLIES 5
Read only

Clemenss
Active Contributor
0 Likes
699

Hi,


  SELECT DISTINCT t005t~land1 landx
  FROM t005t
  JOIN tzone ON tzone~land1 = t005t~land1
  INTO CORRESPONDING FIELDS OF TABLE t_landx
  FOR ALL ENTRIES IN int_delivery
  WHERE zone1 = int_delivery-zone1
    AND spras = sy-langu.
  SORT t_landx.
  DELETE ADJACENT DUPLICATES FROM t_landx.

Note: t005t is language-dependent tect table for T005, If you don't want the country names in all languages maintained in your system, add spras = sy-langu to your WHERE condition. If a country is not maintained in logon language in T005T, nothing is retrieved.

Regards,

Clemens

Read only

anversha_s
Active Contributor
0 Likes
700

hi,

<i>how to optimize ?</i>

1. Avoid

INTO CORRESPONDING

, create an internal table with required fields only.

2.

select tzone~land1 tzone~zone1 t005~landx
from tzone 
join t005t
on tzone~land1 = t005t~land1
into table t_landx
for all entries in int_delivery
where
tzone~zone1 = int_delivery-zone1
AND spras = sy-langu.

Regards

Anver

Read only

Former Member
0 Likes
699

T005T is a small table. If TZONE is also small in your system, you might try reading all entries (for your language in T005T) from both tables into an internal table and then doing a binary search to get entries when you need them. This also assumes that INT_DELIVERY is relatively large.

Rob

Read only

Former Member
0 Likes
699

Hi friends

As suggested by Mr Burbank, i could go for his suggestion

however just to kill my curiosity which is more better way for optimising in

the current situation.

in this case I have to write two select queries and as suggested by anver there is only one select but the join is there.

So which one is more efficient.

Anver : any suggestions.

Thanks & regards

Mohiuddin

Read only

0 Likes
699

It depends on the number of entries in the tables - I still like mine. Why don't you try them all out and let us know?

Rob