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: 

Error in SELECT : unknown field

Former Member
0 Kudos

Hi,

I'm getting strange compiler error by a simple SQL-Statement:

select * from KNVP into table CST_KNVP
  where KUNNR <> KUNN2.

Compiler complains that the Field KUNN2 is unknown.

If I write

where KUNN2 <> KUNNR.

it complains about KUNNR.

Strange, because both fields ARE in the KNVP table.

Do You have some advice how to deal with it?

Thanks in Advance

Daniel

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hello Daniel,

U can't give the selection condition like this.

Change the code like this.


select * from KNVP into table CST_KNVP
  where KUNNR IN SO_KUNNR.     " From selection screen
loop at cst_KNVP.
if cst_KNVP-kunnr = cst_KNVP-kunn2.
delete cst_KNVP.
endif.
endloop.

Hope it helps you.

Regards,

Vasanth

7 REPLIES 7

Former Member
0 Kudos

Hi,

i must declare KUNN2 in your program.

Regards,

Former Member
0 Kudos

Hello Daniel,

U can't give the selection condition like this.

Change the code like this.


select * from KNVP into table CST_KNVP
  where KUNNR IN SO_KUNNR.     " From selection screen
loop at cst_KNVP.
if cst_KNVP-kunnr = cst_KNVP-kunn2.
delete cst_KNVP.
endif.
endloop.

Hope it helps you.

Regards,

Vasanth

Former Member
0 Kudos

Hi,

In the select statements, all the fields mentioned on teh left handside of the where condition are known to the select statement, but the fields mentioned on the right hand side are unknown to the select statement.

That is why you are getting error.

You have use some selection screen field or some field which is already defined in the right hand side of the where condition.

Regards,

Anji

Former Member
0 Kudos

use FM conversion_exit_alpha_input

cause 0001230133 = 1230133 ( wrong )

0001230133 = 0001230133 ( correct )

This check has to be carried out .

before the select convert the rhs value of Kunnr to compatible of lhs of where clause .

regards,

vijay

Former Member
0 Kudos

Try this...

Report ytest.

parameters : p_kunnr for knvp-kunnr default '1000000'.

data : begin of CST_KNVP occurs 0.
           include structure knvp.
data : end of CST_KNVP.

select * from KNVP into table CST_KNVP
  where KUNNR <> p_kunnr..

Former Member
0 Kudos

but it is not giving me error

data kunn2 like knvp-kunn2 value '123'.

select * from KNVP into table CST_KNVP

where KUNNR <> KUNN2.

regards

shiba dutta

Former Member
0 Kudos

Daniel,

your query is wrong.Syntaxt problem

select * from KNVP into table CST_KNVP

where KUNNR <> KUNN2.

How KUNN2 will availble to select statement?

You have to pass this value.

ex : you can use various ways

1.

loop at itab.

select * from KNVP into table CST_KNVP

where KUNNR <> itab-KUNN2.

endloop.

2. select * from KNVP into table CST_KNVP

for all entries in itab

where KUNNR <> itab-KUNN2.

pls. reward if useful