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

Build a select option based on values from internal table

Former Member
0 Likes
2,064

Hello ,

Is there a way, I can dynamically populate the select option, with values from an internal table ? I guess there must be a function module available for this.

For eg, say I have t_kna1 table with values like,

1,2,3,4,5,6,10,15,18,19,20,21,22,23 and 30.

Once I pass this internal table, it should populate the select options with low, high values as below.

Sign Option Low HIGH

-


I BT 1 --- 6

I EQ 10

I EQ 15

I BT 18 --- 23

I EQ 30

any guidance appreciated.

Thanks much

Hello ,

Is there a way, I can dynamically populate the select option, with values from an internal table ? I guess there must be a function module available for this.

For eg, say I have t_kna1 table with values like,

1,2,3,4,5,6,10,15,18,19,20,21,22,23 and 30.

Once I pass this internal table, it should populate the select options with low, high values as below.

Sign Option Low HIGH

-


I BT 1 --- 6

I EQ 10

I EQ 15

I BT 18 --- 23

I EQ 30

any guidance appreciated.

Thanks much

3 REPLIES 3
Read only

Former Member
0 Likes
831

Hey,

You could define a variable using RANGES.

For e.g. RANGES: s_kunnr FOR kna1-kunnr.

S_KUNNR will be a table with fields sign, option, low and high.

YOu could populate S_KUNNR in your program with the values in the internal table.

-Kiran

*Please mark useful answers

Read only

Former Member
0 Likes
831

Kiran,

My requirement is to dynamically/automatically populate the select option/range with those values.

In the solution you suggested, we have to sort the internal table, loop on it, then read the values, make necessary checks to see if the values are consecutive, if yes --> then append it as a range (using BT) , else, append it as a single entry (using EQ) etc.

Instead of all this coding, I would like to know, whether there is any standard functionality (obviously a function module) which do this. We have to just pass the internal table to the function module, it will output the select option/range populated, after doing all the above mentioned checks .

Anyways, thanks for your reply

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
831

I've never seen a function module to do this for you. Usually you need to fill the select-option in your code.

For example.




report zrich_0001.


data: ikna1 type table of kna1 with header line.


select-options: s_kunnr for ikna1-kunnr.

initialization.

  select * into table ikna1 from kna1
             up to 100 rows.

  s_kunnr-sign = 'I'.
  s_kunnr-option = 'EQ'.
  loop at ikna1.
    s_kunnr-low    = ikna1-kunnr.
    append s_kunnr.
  endloop.

Regards,

Rich Heilman