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: 

Select statement

Former Member
0 Kudos

Hi Gurus,

I have a condition :

I need to go to knvh and collect planning group from knvh-kunnr where knvh-hityp = "D" and knvh-hkunnr = cid, after that go to knvh and collect sold to party from knvh-kunnr where knvh-hityp = "D" and knvh-hkunnr = planning group

so far I have written this thing

select kunnr into table it_knvh

from knvh

for all entries in it_header

where hkunnr = it_header-cid

and hityp = 'D'.

Can you please twll me what should be the further process to accomplish the desired result.

Thanks

Rajeev Gupta

2 REPLIES 2

Former Member
0 Kudos

Hi Rajeev,

the code below will solve your problem,

data: begin of it_knvh_temp occurs 0,

kunnr like knvh-kunnr,

hkunnr like knvh-hkunnr,

end of it_knvh_temp.

data: begin of it_knvh occurs 0,

kunnr like knvh-kunnr,

hkunnr like knvh-hkunnr,

end of it_knvh.

select kunnr

hkunnr

from knvh

into table it_knvh_temp

where hityp = 'D'

and hkunnr = 'cid'.

if sy-subrc <> 0.

  • throw error message

endif.

if it_knvh_temp[] is not initial.

select kunnr

from knvh

into table it_knvh

for all entries in it_knvh_temp

where hityp = 'D'

and hkunnr = it_knvh_temp-hkunnr.

if sy-subrc <> 0.

  • throw error message

endif.

Endif.

Thanks,

Samantak.

<b>Rewards points for useful answers.</b>

Former Member
0 Kudos

First u will get the details with the condition where knvh-hityp = "D" and knvh-hkunnr = cid..Store this in internal table..

Then u can use the for all entries concept and combine a database table with a internal table...with the second condtion

REWARD IF USEFUL