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 few fields into table

Former Member
0 Likes
1,382

I have a ztable with 15 fields and i declared the itab and work area same as ztable.

Now i want to fetch only 5 fields which are not in sequence into itab.As the structure is same can i use into table rather than corresponding fields? Is any problem in this.

select fiel2 field5 field6 field7 field9 from ztable into table itab where field = p_field.

8 REPLIES 8
Read only

Former Member
0 Likes
1,203

Hi,

No you can not.

But i am strage that you are asking these type of questiones. Because if you read any basic ABAP Book there it self you can find all the answers of these type of questions.

Regards,

Raj Gupta

Edited by: RajGupta on Aug 20, 2009 4:31 PM

Read only

Former Member
0 Likes
1,203

Yes, there is a problem with this. however, it's easily fixable.

As you are already reserving the memory space for the full table in your itab and workarea (it's declared as the ztable) then you could just select * into it and the only use the five fieds you need in your program. This will be faster than using into corresponding fields of.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,203

Have you tried it? I think you would get a dump. I'm pretty sure that if you use INTO TABLE, then the field list must contain the same fields, in the same order, as the internal table. You should use INTO CORRESPONDING FIELD OF in this case.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,203

Hi,

The easiest way to answer this question will be for you to try it, it will be pretty obvious if it works or not.

However, my feeling is it will not work, it will put all of the fields at the beginning of itab.

Regards,

Nick

Read only

Former Member
0 Likes
1,203

Hi,

Arrange your itab in the order of your ztable fields and then use select ....into table

else you need to use move-correspong

Regards,

Satish

Read only

Former Member
0 Likes
1,203

Hi ,

You can use the select staement .You can also use select.. corresponding Fields also

else you can also use

SELECT s1 ... sn  FROM dbtab  dbtab APPENDING CORRESPONDING FIELDS OF TABLE itab

from performance point of view create internal table with rows that you need to manipulate

because select..corresponding takes a time and is not suggested.

Thanks and Regards

Aditi Wason

Read only

0 Likes
1,203

Hi,

Do you really need a sturcture which is defined in the data dictionary?

An complete different aproach would be to build a dynamical itab.

What I mean? You declare the structure of your internal table within the coding of your program.

One way to do this would be with a statment like this (just to give a hint):

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = t_fcat

IMPORTING

ep_table = ref_t_data.

This would allow you to do anything you like, because you even can built a select statement on runtime.

So far I didn't observe any "new" performance problem when doing so.

Kind regards

Herbert

Read only

Former Member
0 Likes
1,203

thank you experts.

I tried and I got dump .

I thought some new way of doing will be there for this rather than using into corresponding fields.

Thank you once again for the responses