Application Development 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: 

Getting the data from select-options

Former Member
0 Kudos

hi,

I have a select-options field say,

data: ABC for f.

where ABC is an internal table.

let us say i have entered some set of 10 numbers and i want to move all these 10 numbers into another internal table. How can i move them into anther internal table.

If i enter some range of numbers like 1 to 50 then how should i retrieve all those numbers from 1 to 50 into another internal table.

Thanks in advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

You have not mentioned why you want to do that. It is helpful to know the reason becuase to meet your requirement we may not have to do this.

As far as I know, there's no function module which does this directly. You will have to write the logic for this yourself. For example, let us say that you have the select-options for <b>kunnr</b>.

You can code something like this -

select-options s_kunnr for kna1-kunnr.

data it_kunnr type kunnr occurs 0 with header line.

do 10000 times. 
  add 1 to it_kunnr.
  check it_kunnr in s_kunnr.
  append it_kunnr.
enddo.

The above method has certain limitations -

1. It works only when the field is to contain only the numeric values. Since kunnr is a character field, in some cases it can also contain character values.

2. There's an upper limit that has been placed for the loop termination. for example, here it is 10000. Otherwise the program will run for ever.

The best approach is to do a select from the database table directly -

SELECT KUNNR 
  FROM KNA1 
  INTO TABLE IT_KUNNR 
 WHERE KUNNR IN S_KUNNR.

Regards,

Anand Mandalika.

2 REPLIES 2

Former Member
0 Kudos

ranges: new for f.

new[] = abc[].

Rob

Former Member
0 Kudos

Hi,

You have not mentioned why you want to do that. It is helpful to know the reason becuase to meet your requirement we may not have to do this.

As far as I know, there's no function module which does this directly. You will have to write the logic for this yourself. For example, let us say that you have the select-options for <b>kunnr</b>.

You can code something like this -

select-options s_kunnr for kna1-kunnr.

data it_kunnr type kunnr occurs 0 with header line.

do 10000 times. 
  add 1 to it_kunnr.
  check it_kunnr in s_kunnr.
  append it_kunnr.
enddo.

The above method has certain limitations -

1. It works only when the field is to contain only the numeric values. Since kunnr is a character field, in some cases it can also contain character values.

2. There's an upper limit that has been placed for the loop termination. for example, here it is 10000. Otherwise the program will run for ever.

The best approach is to do a select from the database table directly -

SELECT KUNNR 
  FROM KNA1 
  INTO TABLE IT_KUNNR 
 WHERE KUNNR IN S_KUNNR.

Regards,

Anand Mandalika.