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 in program

Former Member
0 Likes
773

Hi,

please help me regarding ranges for an internal table

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
706

Hi,

Please check this sample code.


TABLES:  LFB1.

RANGES: R_BUKRS FOR LFB1-BUKRS

R_BUKRS-SIGN = 'I' 
R_BUKRS-OPTION = 'EQ'
R_BUKRS-LOW =  '0001'
APPEND R_BUKRS.

R_BUKRS-SIGN = 'I' 
R_BUKRS-OPTION = 'EQ'
R_BUKRS-LOW =  '0002'
APPEND R_BUKRS.

R_BUKRS-SIGN = 'I' 
R_BUKRS-OPTION = 'EQ'
R_BUKRS-LOW =  '0003'
APPEND R_BUKRS.

LOOP AT ITAB WHERE BUKRS IN R_BUKRS.
   ....
ENDLOOP.

Regards,

Ferry Lianto

6 REPLIES 6
Read only

Former Member
0 Likes
706

Please explain further what your question is.

A "range" is an internal table - does that help?

Read only

0 Likes
706

Hi John,

in my program i need to build ranges for an field company code and we have to retrive data regarding the range.

so to build range for that field i need help.

is it clear or need more?

Read only

0 Likes
706

Try this....

select-options s_ktokk for lfa1-ktokk.

s_ktokk-low    = '1000'.
  s_ktokk-option = 'EQ'.
  s_ktokk-sign   = 'I'.
  append s_ktokk.

s_ktokk-low    = '2000'.
  s_ktokk-option = 'EQ'.
  s_ktokk-sign   = 'I'.
  append s_ktokk.

Read only

0 Likes
706

Hi,

Try this.

*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
*--- MACRO - Fill Company Code
DEFINE fill_bukrs.
  r_bukrs-sign     = 'I'.
  r_bukrs-low      =  &1.
  r_bukrs-option  = 'EQ'.
  append r_bukrs.
END-OF-DEFINITION.

TABLES: t001.

DATA: lit_bkpf LIKE STANDARD TABLE OF bkpf.

RANGES: r_bukrs FOR t001-bukrs.

fill_bukrs '0001'.
fill_bukrs '0100'.
fill_bukrs '1000'.
fill_bukrs '1001'.

* here DBTAB = database table
* & INTAB = internal table
SELECT *
        FROM <DBTAB>
        INTO TABLE <INTAB>
        WHERE bukrs IN r_bukrs.
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*

Let me know if you need any other information.

Regards,

RS

Read only

Former Member
0 Likes
706

Ranges Accepts a range of values. but it doesn't get selection screen like that of select options.

you have to maintain internal table explicitly.....means specify data explicitly.

RANGES <rangetab>FOR <f>

it shud be like

DATA: BEGIN OF <rangetab> OCCURS 0,

SIGN(1),

OPTION(2)

LOW LIKE<f>,

HIGH LIKE<F>,

END OF<rangetab>.

u shud note that the tables created with RANGES have the same structur as selection tables,but they do not have the same functionality.

I hope you find it useful

Read only

Former Member
0 Likes
707

Hi,

Please check this sample code.


TABLES:  LFB1.

RANGES: R_BUKRS FOR LFB1-BUKRS

R_BUKRS-SIGN = 'I' 
R_BUKRS-OPTION = 'EQ'
R_BUKRS-LOW =  '0001'
APPEND R_BUKRS.

R_BUKRS-SIGN = 'I' 
R_BUKRS-OPTION = 'EQ'
R_BUKRS-LOW =  '0002'
APPEND R_BUKRS.

R_BUKRS-SIGN = 'I' 
R_BUKRS-OPTION = 'EQ'
R_BUKRS-LOW =  '0003'
APPEND R_BUKRS.

LOOP AT ITAB WHERE BUKRS IN R_BUKRS.
   ....
ENDLOOP.

Regards,

Ferry Lianto