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 query error.

Former Member
0 Kudos

Hello All,

I get this error:

"Program ZTEST

Field "HRP1000-OBJID" unknown."

when I run this query:

REPORT ZTEST.

data: end_date type sy-datum,

pos(40) type C,

user(12) type C.

select single stext from hrp1000 into pos

where hrp1000-objid = hrp9007-objid

and plvar eq '01'

and istat eq '1'

and begda le sy-datum

and endda ge sy-datum

and reqnr eq '297006'

and status eq '99'.

write pos.

Can anyone tell me whats the syntax in complex queries.

Regards.

Srinivas

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

First you need to select from that table before you can use it in another SELECT statement.



REPORT ZTEST.
data: end_date type sy-datum,
pos(40) type C,
user(12) type C.
data: wa_hrp9007 type hrp9007


select Single * from hrp2007 into wa_hrp9007
         where .........    "<- Here you need to put the WHERE clause.

check sy-subrc  = 0.

select single stext from hrp1000 into pos
where hrp1000-objid = wa_hrp9007-objid    " Now you can use it here
and plvar eq '01'
and istat eq '1'
and begda le sy-datum
and endda ge sy-datum
and reqnr eq '297006'
and status eq '99'.


write pos.


Regards,

RIch Heilman

6 REPLIES 6

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

First you need to select from that table before you can use it in another SELECT statement.



REPORT ZTEST.
data: end_date type sy-datum,
pos(40) type C,
user(12) type C.
data: wa_hrp9007 type hrp9007


select Single * from hrp2007 into wa_hrp9007
         where .........    "<- Here you need to put the WHERE clause.

check sy-subrc  = 0.

select single stext from hrp1000 into pos
where hrp1000-objid = wa_hrp9007-objid    " Now you can use it here
and plvar eq '01'
and istat eq '1'
and begda le sy-datum
and endda ge sy-datum
and reqnr eq '297006'
and status eq '99'.


write pos.


Regards,

RIch Heilman

0 Kudos

Could you also tell the reason Rich.

And both the where cluses need to match I guess ?

Thanks and regards.

Srinivas

0 Kudos

REPORT ZTEST.

data: end_date type sy-datum,

pos(40) type C,

user(12) type C,

p_objid type hrp1000-objid value '1234'

select single stext from hrp1000 into pos

where objid = p_objid

and plvar eq '01'

and istat eq '1'

and begda le sy-datum

and endda ge sy-datum

and reqnr eq '297006'

and status eq '99'.

write pos.

Just change the value of p_objid with the value you want.

Hope this helps,

'Sudhi

0 Kudos

Hi,

It is a complex query,

I need to pull the stext from hrp1000 table, using "reqnr"(which is a field in hrp9007). So I will be first pulling the record first from hrp9007 based on reqnr and then pulling the stext from hrp1000 using objid from already pulled row(using reqnr).

Thanks all for your replies.

Can anyone give an idea how to write the query.

Regards

Srinivas

Former Member
0 Kudos

Hi,

The field hrp9007-objid is not declared in the program..

Declare the field and check the syntax again..

Thanks,

Naren

Former Member
0 Kudos

Thanks All!