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

Runtime error for SELECT statement

Former Member
0 Likes
1,051

Hi All,

I have written a SELECT statement as follows in my code.

select budat pernr aufnr vornr from AFRU

into corresponding fields of table it_vornr

for all entries in it_cats_tmp

where budat = it_cats_tmp-workdate

and pernr = it_cats_tmp-pernr

and aufnr = it_cats_tmp-rnplnr.

The table IT-CATS_TMP is having around 3000+ lines.

When control moves to this statement, the system is throwing Runtime error or its taking around 30 minutes time to execute.

If i query the same table (AFRU) in SE11 for the same set of conditions, the table displays relevent data immediately.

What might be the reason for this delay/Runtime Error?

Shall i need to change the syntax for better performance?

Your guidelines are highly appreciated......

Regards

Pavan

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
948

what is the Dump says. show the message and error analysis.

8 REPLIES 8
Read only

Former Member
0 Likes
949

what is the Dump says. show the message and error analysis.

Read only

Former Member
0 Likes
948

Hi

Don't use into corresponding fields .

insted of this define ITAB having only fields ur have written in select statement. and keep sequence in ITAB and SELECT similar.

like as u have now : budat pernr aufnr vornr

Regards

Sachin

Read only

0 Likes
948

what is the order of your fields in the internal table it_vornr

just show the definition of the it_vornr.

Read only

Former Member
0 Likes
948

Always avoid using 'into corresponding fields' instead declare a internal table as your requirment including only the field in the table that you want as also said by others:

select budat pernr aufnr vornr from AFRU
into table it_vornr
for all entries in it_cats_tmp
where budat = it_cats_tmp-workdate
and pernr = it_cats_tmp-pernr
and aufnr = it_cats_tmp-rnplnr.

With luck,

Pritam.

Read only

asik_shameem
Active Contributor
0 Likes
948

Hi

1. Try to put WHERE conditions for KEY FIELDS.

Solution: Create a RANGE for the key fields & put that in SELECT Query.

DATA: gr_rueck TYPE RANGES OF afru-rueck.
SELECT .. WHERE rueck IN gr_rueck.

2. Avoid using CORRESPONDING FIELDS OF TABLE in SELECT.

Solution: Change internal table fields ORDER.

TYPES: 
BEGIN OF TY_VORNR,
  budat TYPE ..
  pernr TYPE ..
  aufnr TYPE ..
  vornr TYPE ..
  ... " Other fields
END OF TY_VORNR.

SELECT .. INTO TABLE IT_VORNR ...

Read only

Former Member
0 Likes
948

Hi pavan,

Do not use "INTO CORRESPONDING FIELDS".Instead use the following code ;-

select budat pernr aufnr vornr from AFRU
into table it_vornr
for all entries in it_cats_tmp
where budat = it_cats_tmp-workdate
and pernr = it_cats_tmp-pernr
and aufnr = it_cats_tmp-rnplnr.

-Goodluck,

Bhumika

Read only

Former Member
0 Likes
948

Thanks

Read only

Former Member
0 Likes
948

hi ,

chek ur internal table it_vornr . Should not be empty .

regards

Neetesh