‎2009 Feb 23 10:25 AM
Hi all,
I have to fetch the same record comparing the records from two data base table for which i m using
select * from dbtab1 into table itab1 package size n
select * from dbtab2 into itab2
where field = itab1-field.
endselect.
the loop of select is executed once for second time its givin dump.
please help.
regards,
Gayatri
‎2009 Feb 23 10:32 AM
Hi Gayatri,
I didnt understand y u r looping the select staments.
select * from dbtab1 into table itab1 package size n
select * from dbtab2 into itab2
where field = itab1-field.
endselect.
endselect.
instead of this you can use for all entries.
select * from dbtab1 into table itab1 package size n.
if not itab1 intial.
select * from dbtab2 into table itab2 for all entries in itab1
where field = itab1-field.
endif.
endselect.
revrt back if any issue.
regards,
Naveen
‎2009 Feb 23 10:27 AM
Hi:
Do like this
select * from dbtab1 into table itab1 package size n
select * from dbtab2 into itab2
for all entries of itab1
where field = itab1-field.
Regards
Shashi
‎2009 Feb 23 10:32 AM
Hi Gayatri,
I didnt understand y u r looping the select staments.
select * from dbtab1 into table itab1 package size n
select * from dbtab2 into itab2
where field = itab1-field.
endselect.
endselect.
instead of this you can use for all entries.
select * from dbtab1 into table itab1 package size n.
if not itab1 intial.
select * from dbtab2 into table itab2 for all entries in itab1
where field = itab1-field.
endif.
endselect.
revrt back if any issue.
regards,
Naveen
‎2009 Feb 23 10:35 AM
hi naveen,
i have done coding as u written except for 'if not itab1 intial'.
u can check
‎2009 Feb 23 10:37 AM
Hi Gayatri,
Iam using for all entries as well along with 'if not itab1 intial'., can you check with my code. is it still going to dump.
Regards,
Naveen
‎2009 Feb 23 10:48 AM
‎2009 Feb 23 10:38 AM
For all entries is miising in ur statements
select * from dbtab1 into table itab1 package size n
select * from dbtab2 appending table itab2 for all entries in itab1 where
field = itab1-field.
refresh itab1.
endselect.
‎2009 Feb 23 10:40 AM
Ur query
select * from dbtab1 into table itab1 package size n
select * from dbtab2 into itab2 where field = itab1-field. <---Here u move it to a work area..chck that
endselect.
change it as
select * from dbtab1 into table itab1 package size n
check itab1[] is not initial.
select * from dbtab2 appending table itab2[] where field = itab1-field.
endselect.
‎2009 Feb 23 10:44 AM
Hi Gayatri,
You can try following code:
DATA: l_itab1 LIKE itab1 OCCURS 0 WITH HEADER LINE.
Select first data for first select statement. Then select data for second select statement outside the ***** first select statement.
SELECT *
FROM dbtab1
INTO TABLE itab1
PACKAGE SIZE n
ENDSELECT.
IF NOT itab1[] IS INITIAL.
SORT itab1 by field.
l_itab1[] = itab1[].
SELECT *
FOR ALL ENTRIES IN l_itab1
FROM dbtab2
INTO itab2
WHERE field = l_itab1-field.
ENDIF.
Hope this help you.
Regards,
Anil
Edited by: Anil Salekar on Feb 23, 2009 11:45 AM