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: 

Create internal table like a SELECT-OPTIONS parameter

Former Member
0 Kudos

Hi all,

Does anybody now how I can create an internal table for selecting a range but I don't want to put a SELECT-OPTIONS parameter on the selection-screen. To give an example: the user can enter via a parameter an article '10021234' and I want to give a range to the select statement. Let's say it_range-low = '10001234001' and it_range-high = '10001234999'. Does anybody has a clue how I can manage this?

Thx in advance!

Cheers

1 ACCEPTED SOLUTION

Former Member
0 Kudos
Hi Carl,

try this...

data: v_char(11).
parameters : p_art(8).

ranges : r_art for v_char.

INITIALIZATION.

r_art-sign = 'I'.
r_art-option = 'BT'.
concatenate p_art '001' into r_art-low.
concatenate p_art '999' into r_art-high.
APPEND r_art.
clear r_art.

START-OF-SELECTION.

select ...

WHERE field IN <b>R_ART.</b>

Message was edited by:

Chandrasekhar Jagarlamudi

10 REPLIES 10

former_member386202
Active Contributor
0 Kudos

Hi,

put on selection screen

select-options : s_matnr for mara-matnr no-display.

otherwise

ranges : s_matnr for mara-matnr.

it will not display the select option on selectionnscreen but create internal tabel

Reagards,

Prashant

Former Member
0 Kudos

Hi Carl,

By using RANGES you can achive this....

Thanks...

Former Member
0 Kudos

Hi ,

Use Ranges Keyword.

regards,

Santosh Thorat

Former Member
0 Kudos

Selection table

A global internal table with a header line, the columns SIGN, OPTION, LOW and HIGH and the name of a selection criterion. It is used for the internal storage of selection conditions. Declared with the statement SELECT-OPTIONS; it can be evaluated in logical expressions using the language element IN.

log_exp - IN

Syntax

... [operand [NOT] IN] seltab ...

Effect

In a logical expression with language element IN, the conditions of a selection table are checked.

The logical expression checks whether an operand operand meets the conditions of a selection table or, with addition NOT (as of release 6.10), does not meet them.

For operand, you can use data objects, predefined functions (as of release 6.10) and functional methods. As a selection table seltab, you can specify any internal table whose row type matches that of a selection table, or a functional method with the respective type of return value. This especially includes ranges tables. As of release 6.10, the selection table can be of any kind. Before release 6.10, only standard tables were allowed.

For the structure of a selection table, refer to section SELECT-OPTIONS. The evaluation of a selection table requires the table to contain the valid values specified in that section in the columns sign and option. If the selection table contains invalid values, an untreatable exception occurs. If the selection table is initial, the logical expression is always true.

Every row of the selection table represents a logical expression. Depending on the operator in column option, it is either a comparison or an interval selection.

The comparison is structured as follows:

... operand {EQ|NE|GE|GT|LE|LT|CP|NP} seltab-low ...

The relational operator corresponds to the content of column seltab-option und as the right operand, the content of column seltab-low is used.

The interval selection is structured as follows:

... operand [NOT] BETWEEN seltab-low AND seltab-high ...

The comparison is executed without addition NOT, if the content of column seltab-option is "BT", and with NOT, if it is "NB". For the interval boundaries, the content of the columns seltab-low and seltab-high is used.

The result of the entire logical expression is determined by the following interlinkage of the individual rows (for the link rules see hier):

The results of all rows that contain "I" in the sign column, are linked with OR.If there are no rows containing "E" in the sign column, this is the result of the logical expression.

The results of all rows that contain "E in the sign column, are linked with OR and then negated with NOT. If there are no rows containing "I" in column sign, this is the result of the logical expression.

If in column sign both "I" and "E" are contained, the result of step 1 is related to the result of step 2 using AND.

Note

These rules can be interpreted in such a way that the rows containing "I" or "E" in the sign column, describe two value sets. The set for "I" is the inclusive set, the set for "E" is the exclusive set. By substracting the exclusive set from the inclusive set, a result set is calculated that contains all values for which the logical expression is true.

Short Form

If operand is the data object for which the selection table seltab is defined with

SELECT-OPTIONS seltab FOR operand.

then you can omit operand IN and the logical expression has the following short form:

... seltab ...

This short form is possible only for selection tables declared with SELECT-OPTIONS and with static reference to the data object operand.

Example

Filling a selection table s_number and evaluating it in a logical expression. The logical expression is the short form of number IN s_number. The numbers 5, 7, and 9 are output.

DATA number TYPE i.

SELECT-OPTIONS s_number FOR number NO-DISPLAY.

s_number-sign = 'I'.

s_number-option = 'EQ'.

s_number-low = 9.

APPEND s_number TO s_number.

s_number-sign = 'I'.

s_number-option = 'BT'.

s_number-low = 3.

s_number-high = 7.

APPEND s_number TO s_number.

s_number-sign = 'E'.

s_number-option = 'EQ'.

s_number-low = 6.

APPEND s_number TO s_number.

s_number-sign = 'E'.

s_number-option = 'BT'.

s_number-low = 1.

s_number-high = 4.

APPEND s_number TO s_number.

DO 10 TIMES.

number = sy-index.

IF s_number.

WRITE / sy-index.

ENDIF.

ENDDO.

Former Member
0 Kudos

HI,

see this example.

ranges:r_matnr for mara-matnr.

INITIALIZATION.

r_matnr-low = '1'.

r_matnr-high = '1000'.

r_matnr-sign = 'I'.

r_matnr-option = 'BT'.

append r_matnr.

START-OF-SELECTION.

SELECT * from mara where matnr in r_matnr.

write:/ mara-matnr.

endselect.

instead of declaring like this below

DATA: BEGIN OF r_matnr OCCURS 0,

sign TYPE c LENGTH 1,

option TYPE c LENGTH 2,

low LIKE mara-matnr,

high LIKE mara-matnr,

END OF r_matnr.

simply u can declare as

RANGES r_matnr FOR mara-matnr occurs 0.

rgds,

bharat.

former_member387317
Active Contributor
0 Kudos

if you don't wanna use SELECT-OPTION

then

u can use two parameters

one for low value

and other for High value

PARAMETERS : lowval type I . "

PARAMETERS : highval type I ."

use the values of it in where condition of ur select statement..

or

=====================================

parameters : p_val(8) like c.

<b>ranges:</b> r_val for mara-matnr.

data : lowval(11) type c.

data : highval(11) type c.

INITIALIZATION.

p_val = '10021234'

concatenate p_val '001' into lowval.

concatenate p_val '999' into highval.

r_matnr-low = lowval.

r_matnr-high = highval.

r_matnr-sign = 'I'.

r_matnr-option = 'BT'.

append r_matnr.

Hope it will solve ur problem

<b>Reward points if useful</b>

Thanks & regards

ilesh 24x7

hymavathi_oruganti
Active Contributor
0 Kudos

RANGES , stetement will help you.

RANGES rtab FOR dobj [OCCURS n].

Effect

Obsolete declaration of a Ranges-table. This statement (not allowed in classes) is a short form of the following statement sequence:

DATA: BEGIN OF rtab OCCURS {10|n},

sign(1) TYPE c,

option(2) TYPE c,

low LIKE dobj,

high LIKE dobj,

END OF sel.

An internal table rtab with the structure of a selection table and a header line is declared. Without the addition OCCURS, the initial memory requirement (see DATA - ranges-tables) of the ranges-table is set to ten rows. With the addition OCCURS, you can specify a numeric literal or a numeric constant n to determine a different initial memory requirement.

Note

It is not allowed to declare internal tables with header lines. Due to this, the statement RANGES is not allowed in header lines. To declare a ranges-table in classes, you can use the addition TYPE|LIKE RANGE OF (see TYPES - ranges-table type and DATA - ranges-tables).

Former Member
0 Kudos
Hi Carl,

try this...

data: v_char(11).
parameters : p_art(8).

ranges : r_art for v_char.

INITIALIZATION.

r_art-sign = 'I'.
r_art-option = 'BT'.
concatenate p_art '001' into r_art-low.
concatenate p_art '999' into r_art-high.
APPEND r_art.
clear r_art.

START-OF-SELECTION.

select ...

WHERE field IN <b>R_ART.</b>

Message was edited by:

Chandrasekhar Jagarlamudi

Former Member
0 Kudos

HI

YOU CAN USE RANGES

<b>RANGES</b>

RANGES rtab FOR dobj [OCCURS n].

Obsolete declaration of a Ranges-table. This statement (not allowed in classes) is a short form of the following statement sequence:

DATA: BEGIN OF rtab OCCURS {10|n},

sign(1) TYPE c,

option(2) TYPE c,

low LIKE dobj,

high LIKE dobj,

END OF sel.

An internal table rtab with the structure of a selection table and a header line is declared. Without the addition OCCURS, the initial memory requirement (see DATA - ranges-tables) of the ranges-table is set to ten rows. With the addition OCCURS, you can specify a numeric literal or a numeric constant n to determine a different initial memory requirement.

It is not allowed to declare internal tables with header lines. Due to this, the statement RANGES is not allowed in header lines. To declare a ranges-table in classes, you can use the addition TYPE|LIKE RANGE OF (see TYPES - ranges-table type and DATA - ranges-tables).

<b>Reward if usefull</b>

Former Member
0 Kudos

Thanks guys for all your good answers. I've rewarded with points ;o)