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
373

hii all,

my requirement is:

select MAX( chgnr ) from jcds into corresponding fields of table it_chgnr

where objnr = it_vbak-objnr

and stat = it_estat-estat.

NOW in WHERE clause

both fields which i am not selecting from JCDS can i go like:

select objnr stat MAX( chgnr ) from jcds into corresponding fields of table it_chgnr

where objnr = it_vbak-objnr

and stat = it_estat-estat.

if not please provide me the correct code for above

my requirement is:

select MAX( chgnr ) from jcds into corresponding fields of table it_chgnr

where objnr = it_vbak-objnr

and stat = it_estat-estat.

thanks

rahul

2 REPLIES 2
Read only

vinod_vemuru2
Active Contributor
0 Likes
297

HI,

Check below code.

DATA: L-maxchgnr TYPE jcds-chgnr.

select MAX( chgnr ) from jcds into l_maxchgnr

where objnr = it_vbak-objnr

and stat = it_estat-estat.

Make sure that the fields it_vbak-objnr, it_estat-estat. have values.

I think u r using this select inside loop.

Try to avoid select in loop.

Thanks,

Vinod.

Read only

Former Member
0 Likes
297

Hi,

check if the it_vbak and it_eset tables are not initial.

we need to use the for all entires for those tables or try to loop it_vbak and read the it_estat to get the Objnr value aand stat values respctively into other variables then apply these avariables in select statemt

loop at it_vbak

loop at t_estat.

endloop.

endloop.

declare the variable w_chgnr.

Or

loop at it_vbak

read table it_estat.

select max(chgnr) from jscds into w_chgnr where

objnr = it_vbak-objnr and stat = it_estat-stat.

endloop

This SELECT statement will return only one record that has maximum value

Or

try to read the tables with those values with key fields into some other vairbles then use these variables in your SELECT statemnet

.

Regards

Chandralekha