cancel
Showing results for 
Search instead for 
Did you mean: 

Convert selection option to Internal table

0 Kudos

I have declared s_field as selection -option.

I need to convert s_field to internal table.

For Example.

If I passed the values to s_field as 1 to 5(low =1 high =5)

Then internal table should contains 1 2 3 4 5

Can anyone please suggest how I can change the selection-option to internal table in abap 7.40?

Sandra_Rossi
Active Contributor

What if the select-option is empty, should it return the infinite list of all integers?

Or if it's "not equal 3", should it return the infinite list of integers except 3?

former_member1716
Active Contributor

muthupandi.m,

Can you justify the need for an internal table?

With the values in Select option you can directly use them in a select Query, why do you need the internal table to explain the select Option? Any Business reason behind it?

Regards!

michael_piesche
Active Contributor
0 Kudos

muthupandi.m, please follow up on your open question.

  • comment answers or your question if there are still open issues.
  • otherwise mark an answer as accepted if it helped you solve your problem
  • or post an answer of yourself and accept it if you found another useful solution yourself
  • or redirect your question to another question that is related and was useful to solve your problem
  • in the end, close your question

Accepted Solutions (1)

Accepted Solutions (1)

michael_piesche
Active Contributor
0 Kudos

Since you are not totally clear on your requirement, I have to do some assumptions based on the description and the example:

  • I am assuming your select-option S_FIELD is of type integer
  • I am assuming your set of possible integer values is limited by FROM and TO
    FROM most likely being 1 and TO possible being 10 (or 100, or ....)
    FROM and TO are integers, can be negative or positive and FROM is smaller/equal than TO
  • Therefore, the resulting internal table is also of type integer

The following code will give you a list of integers in the internal table INT_TAB from INT_FROM to INT_TO, only including those, that are defined by the select-option S_FIELD:

REPORT ZSELECTOPT2INTEGERTAB.

DATA intval TYPE i.
SELECT-OPTIONS s_field FOR intval.
SELECTION-SCREEN SKIP 1.
PARAMETERS int_from    TYPE i DEFAULT 1.
PARAMETERS int_to      TYPE i DEFAULT 10.

DATA int_range   TYPE i.
DATA int_current TYPE i.
DATA int_tab     TYPE SORTED TABLE OF i WITH UNIQUE KEY table_line.

CHECK int_from <= int_to.
int_range = int_to - int_from + 1.
int_current = int_from.

DO int_range TIMES.
  IF int_current IN s_field.
    INSERT int_current INTO TABLE int_tab.
  ENDIF.
  ADD 1 TO int_current.
ENDDO.

DATA(out) = cl_demo_output=>new( ).
out->write( s_field[] ).
out->write( int_tab ).
out->display( )

Maybe, after seeing this 'solution', you can be more specific about your requirement, in case it doesnt already solve your problem, which I kind of doubt it will already.

Answers (2)

Answers (2)

BiberM
Active Participant

As far as I know there is no general solution.

In most cases the range has a datatype / domain that has fixed values or a customizing table containing valid values. You select these using your range. By doing so you get a simple list of all EXISTING values fitting your range.

A general solution would have to fit not only to integer values but also to every kind of data types. Additionally a range can contain more than single values or upper and lower limits but also including and excluding rules, patterns and so forth. In most cases the select I tried to describe above solved those problems for me.

venkateswaran_k
Active Contributor

You can use the following - Converting Select option to range

APPEND LINES OF : s_field to r_field

where s_field is your select option - r_field is your range.