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

Function to get a value interval

andy_dingfelder3
Participant
0 Likes
1,209

Hi all,

anybody knows a functions which return a value interval. F.e I´ve a MinValue and a MaxValue. During runtime the MinValue could be 0 and the MaxValue 5. Now i´m lookiing for a method or a function module returning me an internal table with the rows:

0

1

2

3

4

5

The same requirement i`ve for alphanumeric values. E.g. MinValue = A, MaxValue = E.:

A

B

C

D

E

Thx, in advance for your tips...

Andy

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,032

I'm not sure there is an answer to your question except for integers range.

- for integer range, fill the table with a DO/ENDDo

- for char type, the order of values depends on the la,guage and char set, try to analyze your question in a Unicode system....

So you need an integer range to perform a DO loop or an internal or database table where the order of char is significant to perform a LOOP/SELECT WHERE statement.

Regards,

Raymond

7 REPLIES 7
Read only

Former Member
0 Likes
1,032

HI,

I hope by operation on internal table you will get these minimum and maximum value.

Sort your internal table by that perticular field once as ascending and again descending.

hope this will solve your problem.

Regards,

Vijay

Read only

0 Likes
1,032

> HI,

>

> I hope by operation on internal table you will get these minimum and maximum value.

> Sort your internal table by that perticular field once as ascending and again descending.

>

> hope this will solve your problem.

>

> Regards,

> Vijay

Hi Vijay,

thanks for your reply.

But I think you misunderstood my a little bit. I´ve no internal table to be sorted. I´m searching a function module or a mehtod which returns me an internal table with these values based on the parameters MinValue and MaxValue.

Andy

Read only

0 Likes
1,032

Hi Andy again,

I have no idea about FM you are searching for.

But in this case if you have parameters and based on it you need to fix maximum and minimum value then you can build range at event AT Seletion-screen output and make internal table and then do the operation on that table .

Feel free to ask if you have any query.

Regards,

Vijay

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,033

I'm not sure there is an answer to your question except for integers range.

- for integer range, fill the table with a DO/ENDDo

- for char type, the order of values depends on the la,guage and char set, try to analyze your question in a Unicode system....

So you need an integer range to perform a DO loop or an internal or database table where the order of char is significant to perform a LOOP/SELECT WHERE statement.

Regards,

Raymond

Read only

Former Member
0 Likes
1,032

You can use this logic in your custom FM. String of values is used because character variable cannot be incremented just like integers. So you need to have a lookup table or string to store the list.


DATA list TYPE string VALUE 'abcdefghijklmnopqrstuvwxyz'.

DATA: itab TYPE TABLE OF c.

DATA low TYPE c VALUE 'd'.
DATA high TYPE c VALUE 'j'.
DATA temp TYPE string.

DATA num_low TYPE i.
DATA num_high TYPE i.

FIND low IN list MATCH OFFSET num_low.
FIND high IN list MATCH OFFSET num_high.

WHILE num_low LE num_high.
  WRITE:/ list+num_low(1).
  APPEND list+num_low(1) TO itab.

  num_low = num_low + 1.
ENDWHILE.

Edited by: Manish Kumar on Jun 24, 2009 11:54 AM

Read only

Former Member
0 Likes
1,032

Hi,

PARAMETERS: p_min TYPE i OBLIGATORY,

p_max TYPE i OBLIGATORY.

DATA: BEGIN OF itab1 OCCURS 0,

num TYPE i,

END OF itab1.

data: v_min type i,

v_max type i.

AT SELECTION-SCREEN.

v_min = p_min.

v_max = p_max.

IF NOT v_max LT v_min.

DO.

IF v_min GT v_max.

EXIT.

ELSE.

itab1-num = v_min.

APPEND itab1.

ENDIF.

v_min = v_min + 1.

ENDDO.

ENDIF.

START-OF-SELECTION.

LOOP AT itab1.

WRITE:/ itab1-num.

ENDLOOP.

Regards,

Kumar Bandanadham

Read only

andy_dingfelder3
Participant
0 Likes
1,032

Hi all,

thanks all for the replies. As I see I´ve do write my own method.....

Bye,

Andy