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

FM to get values from RANGE

Former Member
0 Likes
4,374

Hi everybody,

Someone knows some function module that let me get all possible values from a range?

I've a range and need to get all values of it for consistences.

E.G.:


RANGE
I - EQ - FROM 100 - TO 104

RETURN of wanted FM:
100
101
102
103
104

Thanks in advance.

Regards,

Charles

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,069

A simple Open SQL SELECT will do that nicely...Seriously, how could a function module return all the possible variations on the hundreds of thousands of possibilities in SAP?

Hi everybody,

Someone knows some function module that let me get all possible values from a range?

I've a range and need to get all values of it for consistences.

E.G.:


RANGE
I - EQ - FROM 100 - TO 104

RETURN of wanted FM:
100
101
102
103
104

Thanks in advance.

Regards,

Charles

11 REPLIES 11
Read only

Former Member
0 Likes
3,070

A simple Open SQL SELECT will do that nicely...Seriously, how could a function module return all the possible variations on the hundreds of thousands of possibilities in SAP?

Read only

0 Likes
3,069

Hi "BreakPoint",

I think you didn't get my point. I do not want to use the range to get data from the database. Obviously it's simple to do that using the range in the WHERE clause from Open SQL.

It's not hard to do. I only was wanting to reuse a standard FM.

Thank you for your time anyway.

Best regards,

Charles

Read only

former_member214857
Contributor
0 Likes
3,069

Hi Charles

To do so you need to perform an Open SQL statement. Like

SELECT key_field FROM my_table WHERE my_field IN my_range.

Kind regards

Carlos Machado

Read only

0 Likes
3,069

Hi Carlos,

Please refer to my reply to "BreakPoint" (above).

I'm not looking for consistence against database values. The values of the range will be passed on as parameter to a web service.

Thank you anyway.

Regards,

Charles

Read only

Former Member
0 Likes
3,069

Hi Charles,

The two Experts suggest great solution.

But according to you, i think it would be very hard to get range base on your condition. YOu have to do it manually if you don't want to check consistency from database.

Thanks,

Thien

Read only

0 Likes
3,069

Thank you Thien, maybe I'll have to do it manually.

An ABAPER here at work says there's a METHOD to do this in a SAP solution. He guess it's in SAP GRE NFE but is not sure.

Read only

Former Member
0 Likes
3,069

Hi,

You can write the following code .

data : v_i  type  i.

ranges  : s_i for v_i.

data : begin of it_itab occurs 0,
         val type i,
       end of it_itab.

s_i-sign = 'I'.
s_i-option = 'BT'.
s_i-low = '100'.
s_i-high = '104'.
append s_i.

loop at s_i.

  while s_i-low < s_i-high.
    it_itab-val  = s_i-low.
    append it_itab.
    s_i-low = s_i-low + 1.
  endwhile.

  it_itab-val  = s_i-high.
  append it_itab.

endloop.

Regards,

Srini.

Edited by: Thomas Zloch on Oct 5, 2010 6:10 PM - please use code tags!

Read only

0 Likes
3,069

Hi Srini, thank you for try help.

Your code consider only the inc. intervals. I need to consider all values for sign and option. But don't worry! As I wrote, I do know how to code my own solution. I was only looking for a "standard way" of do it.

Read only

0 Likes
3,069

Sounds not so feasible to me. What is the possible overall value range? Do you have only integer value, or mixed in alphanumerics (code page, unicode problems...)? Where do they start and stop? What would be the expected result for I/LT/20 for example, or I/GT/150?

Thomas

Read only

0 Likes
3,069

Hi Thomas,

I've a big background in programming and although it's not so feasible it's very doable. Obviously it's hard work to cover all possibilities.

The solution that I developed is very specific to my client. There is only 2 types of values: numeric-character and date. For the NUMC value the client defined the interval from 1 to 999999 and I consider all type of ranges. For the DATE value only I/EQ and I/BT will be considered.

A generic solution is another thing... I don't need it anymore. But again, it's doable.

Kind regards,

Charles

Read only

Former Member
0 Likes
3,069

I developed my own code. I'll not share it here because I didn't take the time to make a generic or reusable solution.

Thank you all.

Regards,

Charles