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 statement

Former Member
0 Likes
796

Hello friends,

I have to select data from data base based on a where condition from an internal table.

In It_BSID the field Vbeln is sometimes blank. So i have to select data into IT_KNVP where IT_BSID-vbeln is blank.

Below is the code that i ahve used and has errors.

SELECT kunnr

parvw

kunn2

INTO TABLE it_knvp

FROM knvp

FOR ALL ENTRIES IN it_bsid

WHERE it_bsid-vbeln is initial

and kunn2 EQ it_bsid-kunnr

and parvw EQ 'RE'.

Any suggestions.

Shejal Shetty.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
767

Hi

What do you need to extract?

You can't use FOR ALL ENTRIES option in this situation

You have to split the record with VBELN and without VBELN

LOOP AT IT_BSID WHERE VBELN = ' '.

APPEND IT_BSID TO IT_BSID_2.

ENDLOOP.

SELECT kunnr

parvw

kunn2

INTO TABLE it_knvp

FROM knvp

FOR ALL ENTRIES IN it_bsid_2

WHERE kunn2 EQ it_bsid-kunnr

and parvw EQ 'RE'.

Max

7 REPLIES 7
Read only

Former Member
0 Likes
768

Hi

What do you need to extract?

You can't use FOR ALL ENTRIES option in this situation

You have to split the record with VBELN and without VBELN

LOOP AT IT_BSID WHERE VBELN = ' '.

APPEND IT_BSID TO IT_BSID_2.

ENDLOOP.

SELECT kunnr

parvw

kunn2

INTO TABLE it_knvp

FROM knvp

FOR ALL ENTRIES IN it_bsid_2

WHERE kunn2 EQ it_bsid-kunnr

and parvw EQ 'RE'.

Max

Read only

0 Likes
767

Thanks MAX,

So I have to use another Internal table. IS there no way that i can do this without using another internal table.

However i dont want to loop it_bsid.

Shejal.

Read only

0 Likes
767

Can i do it in this way,

LOOP AT IT_BSID WHERE VBELN = ' '.

SELECT kunnr

parvw

kunn2

INTO it_knvp

FROM knvp

WHERE kunn2 EQ it_bsid-kunnr

and parvw EQ 'RE'.

endselect.

endloop.

Shejal Shetty.

Read only

0 Likes
767

Max is right.. you don't have an option but loop at it_bsid once & use another itab with the FOR ALL ENTRIES option..

or

delete it_bsid where vbeln is initial

and parvw EQ 'RE'.

and then use yor select

~Suresh

Read only

0 Likes
767

Hi

Yes of course, but in this way u don't use FOR ALL ENTRIES option:

LOOP AT IT_BSID WHERE VBELN = ' '.

SELECT kunnr

parvw

kunn2

INTO it_knvp

FROM knvp

WHERE kunn2 EQ it_bsid-kunnr

and parvw EQ 'RE'.

<b>APPEND IT_KNVP.</b>

endselect.

endloop.

or

LOOP AT IT_BSID WHERE VBELN = ' '.

SELECT kunnr

parvw

kunn2

<b>APPENDING TABLE IT_KNVP</b>

FROM knvp

WHERE kunn2 EQ it_bsid-kunnr

and parvw EQ 'RE'.

endloop.

Max

Read only

0 Likes
767

Hi,

writing a select statement in a loop will cause a performance issue.

You can use the code suggested by MAX.

Regards,

Azaz Ali.

Read only

0 Likes
767

Thanks for all youe help guys,

Shejal Shetty...