‎2008 Jul 23 5:29 PM
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
‎2008 Jul 23 5:41 PM
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.
‎2008 Jul 23 5:43 PM
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