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 command using package size

Former Member
0 Likes
1,219

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
862

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

8 REPLIES 8
Read only

Former Member
0 Likes
862

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

Read only

Former Member
0 Likes
863

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

Read only

0 Likes
862

hi naveen,

i have done coding as u written except for 'if not itab1 intial'.

u can check

Read only

0 Likes
862

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

Read only

0 Likes
862

thanks Naveen its working fine now.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
862

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.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
862


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.

Read only

Former Member
0 Likes
862

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