Application Development 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: 

make it as one select statement!

naveen_inuganti2
Active Contributor
0 Kudos

Hi..,

See my coding..,

data: customer like kna1-kunnr,
        name like kna1-name1.

parameter: p_filed1 like ztable-filed1

select single kunnr from ztable into customer where filed1 = p_filed1.
 if sy-subrc = 0.
  select single name1 from kna1 into name where kunnr = custmer.
 endif.

So I can pass this name into other parameter(function modules) with out READ and LOOP statements as you know..

Now my question is how can modify above coding with one select statement.

I want name entry in variable only...

Thanks,

Naveen.I

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Try to change the piece of code as follows:

select single kna1~name1

into name

from kna1 inner join ztable

on kna1kunnr = ztablekunnr

where ztable~filed1 = p_filed1.

Thanks & Regards,

Navneeth K.

4 REPLIES 4

Former Member
0 Kudos

hi..

U can use joins by linking kunnr in name1 field.

0 Kudos

Hi..,

Yes, I can join.

But how i can pass name1 into single variable, please get back with sample code..,

Thanks,

Naveen.i

Former Member
0 Kudos

Hi,

You did not mention all the fields of the ztable.

So if you have common key fields in both ztable and kna1 then you can Join both the table in single select statement.

Former Member
0 Kudos

Hi,

Try to change the piece of code as follows:

select single kna1~name1

into name

from kna1 inner join ztable

on kna1kunnr = ztablekunnr

where ztable~filed1 = p_filed1.

Thanks & Regards,

Navneeth K.