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
732

hello friends,

I have to extrace data from a Data Base table depending on somw where sonditions.

I have an internal table it_bsid and it_knvp. it_bsid already has data and it has a fiels vbeln and it_bsid-vbeln is some times empty.

If it_bsid-vbeln is empty i have to get data into it_knvp.

below is the code but i am getting syntax errors.

SELECT kunnr

parvw

kunn2

INTO TABLE it_knvp

FROM knvp

FOR ALL ENTRIES IN it_bsid

WHERE it_bsid-vbeln is null and

kunnr EQ it_bsid-kunnr and

( parvw EQ 'AG' OR parvw EQ 'RE').

Any Advice.

Shejal Shetty.

1 ACCEPTED SOLUTION
Read only

AFork
Product and Topic Expert
Product and Topic Expert
0 Likes
679

Hey,

try to change "into table it_knvp" to

"appending corresponding field of table it_knvp".

Hope this helps.

Greetings,

Achim

Message was edited by: Achim Fork

5 REPLIES 5
Read only

AFork
Product and Topic Expert
Product and Topic Expert
0 Likes
680

Hey,

try to change "into table it_knvp" to

"appending corresponding field of table it_knvp".

Hope this helps.

Greetings,

Achim

Message was edited by: Achim Fork

Read only

Former Member
0 Likes
679

Hi,

the table that is used in 'FOR ALL ENTRIES' in your case <b>it_bsid</b> cannot not have any where condition on it.

This means that in where condition you cannot place any selection criteria on the table

<b>it_bsid-vbeln is null</b> <-- this is wrong

Regards

Nishant

I guess it would be better if you filter out the internal table and store some data in where vbeln is blank in another internal table and have nonblank entries in this table and then fire seperate select queries for both.

Message was edited by: Nishant Rustagi

Read only

Former Member
0 Likes
679

SELECT kunnr

parvw

kunn2

INTO TABLE it_knvp

FROM knvp

FOR ALL ENTRIES IN it_bsid

WHERE <u>it_bsid-vbeln is null</u> and

kunnr EQ it_bsid-kunnr and

( parvw EQ 'AG' OR parvw EQ 'RE').

U cannot have the above condition in the select. If you take that out it would work fine...sure you would have more data than required in it_knvp table. Other wise you can do the below.

itab[] = it_bsid[].

delete itab where itab-vbeln is not null.

sort itab by kunnr.

delete adjacent duplicate comparing kunnr.

SELECT kunnr

parvw

kunn2

INTO TABLE it_knvp

FROM knvp

FOR ALL ENTRIES IN itab

WHERE kunnr EQ itab-kunnr and

( parvw EQ 'AG' OR parvw EQ 'RE').

Read only

0 Likes
679

Tnamks Guys,

I will try and let see what the results are.

Shejal.

Read only

0 Likes
679

Hi Shejal,

Here is another way:

tables: knvp. "(include knvp in the tables statement)

sort it_bsid by vbeln.

loop at it_bsid where vbeln is initial.

select single kunnr parvw kunn2

from knvp where kunnr eq it_bsid-kunnr

and ( parvw EQ 'AG' OR parvw EQ 'RE' ).

move knvp-kunnr to it_knvp-kunnr.

move knvp-parvw to it_knvp-parvw.

move knvp-kunn2 to it_knvp-kunn2.

append it_knvp.

clear it_knvp.

endloop.

Performance wise, this might take more time.

Regards,

Vivek