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....

anupam_srivastava2
Participant
0 Likes
720

Hi All

I have one simple requirement, hope you guys able to help me..

I have got two tables..

table A      kna1(table B)

kunnr        kunnr

x              ktokd

y              x

z              y

table A and table B are linked with kunnr.

Now my requirement is I have to select all kunnr from table A, where ktokd(account group) in KNA1 is having values (a,b,c,d).

Can you please suggest me how can I write my select query.

Regards

Anup

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
690

Hi Anupam,

You can try like this.

TYPES: BEGIN OF t_cust,

        kunnr TYPE kunnr,

        END OF t_cust.

DATA: i_cust TYPE STANDARD TABLE OF t_cust,

       i_knvv TYPE TABLE OF knvv,

       i_kna1 TYPE TABLE OF kna1.

Select kna1~kunnr

into table i_cust

from kna1

inner join knvv

on kna1~kunnr = knvv~kunnr

   WHERE KTOKD eq 'A'

      OR KTOKD eq 'B'

      OR KTOKD eq 'C'

      OR KTOKD eq 'D'.


Thanks,

Shreekant

5 REPLIES 5
Read only

kjetil_sandvik2
Participant
0 Likes
690

Hi,

try this:

SELECT

T0.kunnr

FROM TABLEA T0

INNER JOIN TABLEB T1 ON T0.kunnr = T1.kunnr

WHERE T1.kunnr in(a,b,c,d)

BR

Kjetil Sandvk

Read only

0 Likes
690

Sorry, you will have to use in('a','b','c','d')

Read only

0 Likes
690

and the column was different:

...

WHERE T1.ktokd in('a','b','c','d')

...


Read only

Former Member
0 Likes
690

Hi,

Select kunnr x y z into table it_table A.

Select Kunnr ktokd x y into table it_tableB for all entries in it_table A where kunnr = it_table A-kunnr.

by using above select query you get necessary data,

after that you can perform any operation on your tables.

Read only

Former Member
0 Likes
691

Hi Anupam,

You can try like this.

TYPES: BEGIN OF t_cust,

        kunnr TYPE kunnr,

        END OF t_cust.

DATA: i_cust TYPE STANDARD TABLE OF t_cust,

       i_knvv TYPE TABLE OF knvv,

       i_kna1 TYPE TABLE OF kna1.

Select kna1~kunnr

into table i_cust

from kna1

inner join knvv

on kna1~kunnr = knvv~kunnr

   WHERE KTOKD eq 'A'

      OR KTOKD eq 'B'

      OR KTOKD eq 'C'

      OR KTOKD eq 'D'.


Thanks,

Shreekant