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

ranges

Former Member
0 Likes
3,008

what is use of rages statement.

ranges :r1_bwart for mseg-bwart, " For Accepted Qty

r2_bwart for mseg-bwart. " For Issued Qty

.

.

.

r2_bwart-sign = 'I'.

r2_bwart-option = 'EQ'.

r2_bwart-low = '261'.

*r2_bwart-high

append r2_bwart.

r2_bwart-sign = 'I'.

r2_bwart-option = 'EQ'.

r2_bwart-low = '102'.

*r2_bwart-high

append r2_bwart.

what it means. plz help me out.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,111

Hi VARUN RAJULE,

Ranges are similar to select options you can use that ranges variable while fetching the data and like that.

see the following example code.

select * 
  from mseg 
  into table it_itab 
 where bwart in r2_bwart.

I am providing the F1 help of SAP

*Syntax *

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 which is also not allowed in classes:

DATA: BEGIN OF rtab OCCURS {10|n}, 
        sign   TYPE c LENGTH 1, 
        option TYPE c LENGTH 2, 
        low    LIKE dobj, 
        high   LIKE dobj, 
      END OF rtab.

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).

Regards,

Mahi.

12 REPLIES 12
Read only

GauthamV
Active Contributor
0 Likes
2,111

hi,

ranges are almost similar to select options which r used in older versions.

Read only

Former Member
0 Likes
2,112

Hi VARUN RAJULE,

Ranges are similar to select options you can use that ranges variable while fetching the data and like that.

see the following example code.

select * 
  from mseg 
  into table it_itab 
 where bwart in r2_bwart.

I am providing the F1 help of SAP

*Syntax *

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 which is also not allowed in classes:

DATA: BEGIN OF rtab OCCURS {10|n}, 
        sign   TYPE c LENGTH 1, 
        option TYPE c LENGTH 2, 
        low    LIKE dobj, 
        high   LIKE dobj, 
      END OF rtab.

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).

Regards,

Mahi.

Read only

Former Member
0 Likes
2,111

hi,

It is nothing but, same as Select-option in older version

thnks & rgds,

raghul

Read only

bpawanchand
Active Contributor
Read only

Former Member
0 Likes
2,111

Hi,

Ranges are like Select-options , it is used to store range value.

It Declare an internal table whose line type are SIGN, OPTION, LOW and HIGH.

Check the details here-

http://help.sap.com/saphelp_webas620/helpdata/en/9f/dba71f35c111d1829f0000e829fbfe/content.htm

Read only

Former Member
Read only

Former Member
0 Likes
2,111

Hi Varun,

Here both SELECT-OPTIONS & RANGES works for the same purpose.

They both are used for the range selection from selection screen.

The main diff. between them is, while we use SELECT-OPTIONS system implicitly creates the select options internal table which contains the fields of SIGN,OPTION,LOW & HIGH. But in case of RANGES, this internal table should be defined explicitly.

DATA:

lfs_kschl LIKE LINE OF r_kschl.

lfs_kschl-low = c_kschl_zf11.

lfs_kschl-option = 'EQ'.

lfs_kschl-sign = 'I'.

APPEND lfs_kschl TO r_kschl.

lfs_kschl-low = c_kschl_zf12.

lfs_kschl-option = 'EQ'.

lfs_kschl-sign = 'I'.

APPEND lfs_kschl TO r_kschl.

lfs_kschl-low = c_kschl_zf13.

lfs_kschl-option = 'EQ'.

lfs_kschl-sign = 'I'.

APPEND lfs_kschl TO r_kschl.

lfs_kschl-low = c_kschl_zf14.

lfs_kschl-option = 'EQ'.

lfs_kschl-sign = 'I'.

APPEND lfs_kschl TO r_kschl.

Regards.

Eshwar.

Read only

Former Member
0 Likes
2,111

Ranges and select-options are the same both are used for range selection, only difference is the internal table of select-options that is SIGN, OPTION, LOW & HIGH is created implicitly while for ranges you have to defined it explicitly.

With luck,

Pritam.

Read only

Former Member
0 Likes
2,111

Varun,

As Select-option creats internal table self but case of RANGES, this internal table should be defined explicitly.

Like as you did in your piece of code.that is the difference.and also we can not use ranges for the selection screen purpose as in case of select-options.

also:

Refer

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/ranges.htm

Amit.

Read only

Former Member
0 Likes
2,111

Hi,

1. SELECT-OPTIONS: To declare an internal table that is also linked to input fields on a

selection screen

2. RANGES: To declare an internal table with the same structure as in SELECT-OPTIONS, but without linking it to a selection screen.

So, RANGES statement to create internal tables that have the structure of selection tables.

Internal tables created with RANGES have the same structure as selection tables, but they do not have the same functionality. Selection tables created with RANGES are not components of the selection screen. As a result, no relevant input fields are generated. Also, you cannot use a RANGES table as a data interface in program called by the following statement:

SUBMIT prog WITH rangetab IN table.

However, you can use RANGES to create the table <table> in the calling program. The main function of RANGES tables is to pass data to the actual selection tables without displaying the

selection screen when executable programs are called.

Although you can use RANGES tables like actual selection tables in the WHERE clause of Open SQL statements and in combination with the IN operator in logical expressions, they are not linked to a database table.

select * 
  from mara 
  into table itab 
  where matnr IN r_matnr

.

Hope this clarifies the doubt.

thanx,

dhanashri.

Edited by: Dhanashri Pawar on Aug 5, 2008 8:39 AM

Read only

Former Member
0 Likes
2,111

hi.

ranges is same as select-option. But it is not visible in selection screen. think a scenario like if u want to fetch matnr between 100 to 200 and u dont want to display it in selection screen than u need to go for range. as in ur code

r2_bwart-sign = 'I'.

r2_bwart-option = 'EQ'.

r2_bwart-low = '261'.

*r2_bwart-high

append r2_bwart.

r2_bwart-sign = 'I'.

r2_bwart-option = 'EQ'.

r2_bwart-low = '102'.

*r2_bwart-high

append r2_bwart.

your selection for bwart field is for value 102 to 261 only. This will not come in ur selection-screen.

hope this will help u.

Read only

Former Member
0 Likes
2,111

Both range and select options are same except that ranges are not visible to accept input data from user. We need to input data at run time. Both create internal table of the same type.

Select-options is a advanced version of ranges where we have selection screen for multiple data selection.

rgds

rajesh