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

Syntax error in WHERE clause

Former Member
0 Likes
1,506

Hi all,

see the code.

data: itab type cdhdr occurs 0,

wa type cdhdr.

data: begin of itab1 occurs 0,

lifnr like lfa1-lifnr,

ktokk like lfa1-ktokk,

end of itab1.

select * from cdhdr into table itab.

select lifnr ktokk from lfa1 into table itab1

for all entries in itab

where lifnr = itab-objectid.

when i go for Syntax check i am getting Error like " when using the addition for all entries in itab " the fields LIFNR and ITAB-OBJECTID must have the same type and lengh.

so, i have done the following correction in WHERE clause.

select lifnr ktokk from lfa1 into table itab1

for all entries in itab

where lifnr = itab-objectid(10).

But this time i am geting warning in German language.

my correction is correct or not ?

Pls guide me ..

Thanks

Krupali.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,312

hi,

for all entries, comparision fields (lifnr and itab-OBJECTID) should be the same type and length. other wise, system will give you syntax error.

better to define types (structure (program) with the structure CDHDR.

types: begin of type_CDHDR,

OBJECTID type LIFNR,

....

end of type_cdhdr.

data: table_cdhdr type standard table of type_cdhdr.

it should work fine now

I had the same problem erlier, and solved with this solution.

10 REPLIES 10
Read only

Former Member
0 Likes
1,312

HI,

The simplest way is to create a itab explicitly . i.e.

types : BEGIN OF t_cdpos,

objectclas TYPE cdpos-objectclas,

objectid(10) TYPE c,

changenr TYPE cdpos-changenr,

fname TYPE cdpos-fname,

value_new TYPE cdpos-value_new,

END OF t_cdpos.

data : itab type table of t_cdpos,

wa like line of itab.

Now use this in your select query.

Read only

Former Member
0 Likes
1,312

Hi,

I think you better go on and check the content of both of your internal tables. If they are okey, then you may ignore the warning message.

Regards,

Anirban

Read only

anversha_s
Active Contributor
0 Likes
1,312

Hi,

CDHDR-OBJECTID is of length 90.

You can move above value to a char10 field and compare the same.

Regards,

Anversha

Read only

Former Member
0 Likes
1,312
select lifnr ktokk from lfa1 into table itab1
for all entries in itab
where lifnr = itab-objectid(10).

But this time i am geting warning in German language.

my correction is correct or not ?

Answer is your correction is not correct.

we cannot use offset with for all entries.

you can do this way first take the itab-objectid(10) in some other field like temp than fire for all entries on temp.

like below.

select lifnr ktokk from lfa1 into table itab1
for all entries in itab
where lifnr = itab-temp."<-- see here

Amit.

Edited by: Amit Gujargoud on Aug 26, 2008 8:00 AM

Read only

Former Member
0 Likes
1,312

Hi,

Take some common key in both the internal tables and then put for all entries.

lifnr u got from lfai table and objectid field from cdhdr table, both are having different data elements assigned to them.

What u wrote is wrong.

Try to find out some common key betwwen those two table, if u don't find u can not use for all entries statement.

Regards,

Kusuma.

Read only

Former Member
0 Likes
1,312

Hi,

Take some common key in both the internal tables and then put for all entries.

lifnr u got from lfai table and objectid field from cdhdr table, both are having different data elements assigned to them.

What u wrote is wrong.

Try to find out some common key betwwen those two table, if u don't find u can not use for all entries statement.

Regards,

Kusuma.

Read only

Former Member
0 Likes
1,312

Hi KR,

Declare internal table with CDHDR table fields but instead of OBJECTID this declare with char10 as like lifnr.

or

Ignore warining message your query should work.

Regards

Jana

Read only

Former Member
0 Likes
1,313

hi,

for all entries, comparision fields (lifnr and itab-OBJECTID) should be the same type and length. other wise, system will give you syntax error.

better to define types (structure (program) with the structure CDHDR.

types: begin of type_CDHDR,

OBJECTID type LIFNR,

....

end of type_cdhdr.

data: table_cdhdr type standard table of type_cdhdr.

it should work fine now

I had the same problem erlier, and solved with this solution.

Read only

Former Member
0 Likes
1,312

Hello

Try this code:


data: itab type cdhdr occurs 0,
wa type cdhdr.
data: begin of itab2 occurs 0,
objectid like lfa1-lifnr,
end of itab2.

data: begin of itab1 occurs 0,
lifnr like lfa1-lifnr,
ktokk like lfa1-ktokk,
end of itab1.

data: begin of itab2 occurs 0,
objectid like lfa1-lifnr,
end of itab2.

select * from cdhdr into table itab.

loop at itab.
  itab2-objectid = itab-objectid(10).
  append itab2.
endloop.

select lifnr ktokk from lfa1 into table itab1
for all entries in itab2
where lifnr = itab2-objectid.

Read only

Former Member
0 Likes
1,312

Hi KR,

DATA: ITAB TYPE CDHDR OCCURS 0,
WA TYPE CDHDR.

DATA: BEGIN OF ITAB1 OCCURS 0,
LIFNR LIKE LFA1-LIFNR,
KTOKK LIKE LFA1-KTOKK,
END OF ITAB1.

SELECT * FROM CDHDR INTO TABLE ITAB.

SELECT LIFNR KTOKK FROM LFA1 INTO TABLE ITAB1
FOR ALL ENTRIES IN ITAB
WHERE LIFNR = ITAB-OBJECTID+0(10).

 IF SY-SUBRC = 0.
   WRITE :  'dATA fOUND'.
 ENDIF.

Try above code it's working fine... Change the where condition as above and ignore the warnings...

Hope it will solve your problem..

Thanks & Regards

ilesh 24x7