cancel
Showing results for 
Search instead for 
Did you mean: 

How to write multiple select statements while performing lookup from One lookup table

former_member202517
Participant
0 Kudos
95

Hi All,

We have scenario where we need to perform the lookup from a DSO to another DSO by using Multiple conditions for different fields from but from the same lookup DSO.

example

condition 1:

select /bic/YMAT_2 /bic/YMAT_D5 from /bic/AYDSO_900 into corresponding fields of table it_tab1 for all entries in result_package where

/bic/YMAT_2 = result_package-/bic/YMAT_2.


Condition 2


select /bic/YMAT_2 /bic/YMAT_D10 from /bic/AYDSO_900 into corresponding fields of table it_tab1 for all entries in result_package where

/bic/YMAT_2 = result_package-/bic/YMAT_2 and /bic/YMAT_5 = result_package-/bic/YMAT_5.



Kindly suggest the end routine code how can we achieve this with performance. As of now we are using 2 internal tables and WA to achieve this.


Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Jagadeep,

In order to simplfy you only need to mantain the second read since in both selects you use YMAT_2 as a key.

****** select /bic/YMAT_2 /bic/YMAT_D10

   from /bic/AYDSO_900

into corresponding fields of table it_tab1

  for all entries in result_package

   where /bic/YMAT_2 = result_package-/bic/YMAT_2

    and /bic/YMAT_5 = result_package-/bic/YMAT_5.   (maybe,delete this AND)

I would think you only need to change the first line:


****** select /bic/YMAT_2 /bic/YMAT_D5 /bic/YMAT_D10

If you need both conditions and they have different values, then DO just one read to the /bic/AYDSO_900

and read all chars you may need, save it in an internal table and then use your internal table to read both conditions.

Regards.

former_member202517
Participant
0 Kudos

Hi Fernandez,

Thank you for your reply.

So in this case the code would be some thing like below?

select /bic/YMAT_2 /bic/YMAT_D5 /bic/YMAT_D10 from /bic/AYDSO_900 into corresponding fields of table it_tab1.


1st condition.


read table it_tab1 into wa_tab1 with key

  /bic/YMAT_2 = <result_fields>-/bic/YMAT_2 binary search.

clear WA_tab1.

2nd condition:

read table it_tab1 into wa_tab1 with key

/bic/YMAT_2 = <result_fields>-/bic/YMAT_2 and /bic/YMAT_5 = <result_fields>-/bic/YMAT_5.

Former Member
0 Kudos

Hi

You can use 1 internal table to fetch everything from Look up DSO and while populating the fields do multiple Reads depending on you condition for different fields.

Thanks

former_member202517
Participant
0 Kudos

if possible could you please provide sample code