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

function module: Select...into

Former Member
0 Likes
1,677

Hi together,

I´ve got a strange problem concering a 'select...into itab...' in a function module.

Although the dbtab contains data, the 'select...' is not successful:

--> select x y from dbtab into itab where...

Are there any restrictions or special requirements?

Thanks for any help

1 ACCEPTED SOLUTION
Read only

former_member186491
Contributor
0 Likes
1,607

Hi,

May be, your error would be coming like --

"You can not use work-area as internal table"

If so, you need to to put TABLE after INTO like --


select x y from dbtab into TABLE itab where...

And otherwise, above suggestion is there - "INTO CORRESPONDING FIELDS OF TABLE" - , what you need to follow, if you are not declaring your structure according to the position of those in the table.

Thanks.

Kumar Saurav.

14 REPLIES 14
Read only

Former Member
0 Likes
1,607

try select x y from dbtab into corresponding fields of table itab.

make sure the structure of your internal table is the same as the table your getting values from.

Read only

former_member186491
Contributor
0 Likes
1,608

Hi,

May be, your error would be coming like --

"You can not use work-area as internal table"

If so, you need to to put TABLE after INTO like --


select x y from dbtab into TABLE itab where...

And otherwise, above suggestion is there - "INTO CORRESPONDING FIELDS OF TABLE" - , what you need to follow, if you are not declaring your structure according to the position of those in the table.

Thanks.

Kumar Saurav.

Read only

0 Likes
1,607

Hi,

It still doesn´t work.

Here is the entire coding:

DATA:

it_bsid TYPE TABLE OF ZGMATG_OBI_002,

wa_bsid type ZGMATG_OBI_002.

*Structure zgmatg_obi_002 only contains fields XBLNR and XREF1. (in exactly this order)

SELECT xblnr xref1 FROM bsid

INTO corresponding fields of TABLE it_bsid

where ( blart = 'RV' OR blart = 'DA' )

AND xref1 IN r_datum

AND xref3 IN r_datum.

Read only

0 Likes
1,607

HI,

What is your sy-subrc value after the Select statement?

Regards,

Suzie

Read only

0 Likes
1,607

Hi,

The SELECT ...provides sy-subrc = 4.

When I´m doing the same thing within a 'conventional' ABAP the sy-subrc = 0.

Read only

0 Likes
1,607

try reducing or removing your WHERE conditions first, just to check if your select statement can fetch something from the table. Also, try something like SELECT bsidxblnr bsidxref1FROM bsid . . .

might help.

Read only

0 Likes
1,607

What is r_datum? What value does it have? If it is a range object, what values does

r_datum[]

have? Check in the debugger to find the exact values.

Without this information any answers posted here are just guesses. There is nothing strange - the simple fact is that your where clause, somehow, isn't matching what's in the table.

matt

Read only

0 Likes
1,607

Hi,

The sy-subrc = 4 indicates that the DB table does not have any records matching your given criteria.

Check if the values are getting populated properly in R_datum[] if it is the date try passing the dates in YYYYMMDD format into r_datum [].

Regards,

Suzie

Read only

0 Likes
1,607

The problem must be in your range tables - they are not getting populated with the correct values

Read only

Former Member
0 Likes
1,607

Hi,

If you confirm the structures and fields are same in the table & DBTAB then verify the WHERE coondition of the SELECT statement where there may be any field with the DATE format or field with the Conversion Exit.

Regards,

SRinivas

Read only

Former Member
0 Likes
1,607

This message was moderated.

Read only

Former Member
0 Likes
1,607

Hi,

make sure ur itab structure and selection fields must be in same order.

for ex:

ur itab structure contains

y type mara-matnr

x type mara-pstat

then ur select query should be in the same order as

select y

x

from dbtab

into table itab

where....

Thanks,

Rakesh.V

Read only

Former Member
0 Likes
1,607

This message was moderated.

Read only

Former Member
0 Likes
1,607

hi,

i think 1 point i want to add is in where condition key fields is a must.otherwise u will get performance issue somethings it goes to dump.

regards,

Sri