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: 

Creating Range of values

Former Member
0 Kudos

Hai,

I have a GL Account Range (that is 100000 to 120000) the one the user is entering in the Selection Screen.

I have a requirement to build a range table like the following

r_saknr-low = 100000. r_sign = 'I'. r_option = 'EQ'.

r_saknr-low = 100001. r_sign = 'I'. r_option = 'EQ'.

..

..

r_saknr-low = 120000. r_sign = 'I'. r_option = 'EQ'.

Curently i am populating this range using below logic.

v_saknr = v_skanr-low.

do n times (120000-100000) times.

r_saknr-low = v_saknr.

r_saknr-sign = 'i'.

r_skanr-option = 'eq'.

APPEND r_saknr.

clear r_skanr.

v_skanr = v_skanr + 1.

enddo.

It is working fine but slow. I would like to know Are they any standard function module which should take the from and To range and provides the ranges of values.

So that i can increase the performance.

Please suggest me.

Giri

7 REPLIES 7

Former Member
0 Kudos

Giri,

Could you not use the following for your range?

r_saknr-sign = 'I'.

r_saknr-option = 'BT'.

r_saknr-low = 100000.

r_saknr-high = 120000.

append r_saknr.

You could use the Between option for the range instead of setting each individual value as an Equal option...

Hope that helps...

0 Kudos

Hai Nicholas,

Sorry I have to build the range. The requirement is like that. I am looking for a standard sap function module which will make the code and time easier.

Giri

Former Member
0 Kudos

Okay... I don't know of any standard functions that will do that for you, but here is a way to streamline your current code...

v_saknr = 100000.

r_saknr-sign = 'I'. " Remove these from the do since

r_saknr-option = 'EQ'. " they are always the same...

n = 120000 - 100000. " Or hardcode in 20000 in place of n

do n times.

clear r_saknr-low.

r_saknr-low = v_saknr.

APPEND r_saknr.

v_saknr = v_saknr + 1.

enddo.

Nick

0 Kudos

Hai Nicholas,

Thanks for your reply.

If anyone knows " There is any function module which should take the range values and its parameters and gives the output as an internal table. "

Please help.

Giri

0 Kudos

Hi Giri,

I don't think there is a function module which would give you what you want in this case. So think of just trying to improve the logic. If somebody finds something then they shall let you know about it.

Regards,

Anand Mandalika.

Former Member
0 Kudos

Hello Giri,

I presume that you are using ordinary fields to get thhe Range on the Selection-Screen, instead of using a select-option.

Could you please elaborate what the requirement is and why you need all the single values instead of just using the BT operator?

Even if you had wanted all the individual values, I'm sure that you do not want to have the numbers which you are not going to find in the database.

I'm sure that there might be a few programmer who would not appreciate hitting the database for a task of this trivial a nature, but I would want you to try out something like this:

tables ska1.

ranges lt_saknr for ska1-saknr.
lt_saknr-sign = 'I'.
lt_saknr-option = 'EQ'.
select distinct saknr
  from ska1
  into lt_saknr-low 
 where saknr between <v_saknr_lower_limit> and <v_saknr_upper_limit>
.
  append lt_saknr.
endselect.

The above statement might work really work much faster than your application logic depending on the kind of data you have in your system and the selection values the user enters. Just run a few tests and see which works the best for your case.

Regards,

Anand Mandalika.

christian_wohlfahrt
Active Contributor
0 Kudos

Hi Giri,

to improve the coding a little bit:


r_saknr-sign   = 'I'.  
r_saknr-option = 'EQ'.  
r_saknr-low    = 100000.
n = 120000 - 100000 + 1.  "Check, if last value is OK!

do n times.
APPEND r_saknr.
r_saknr-low = r_saknr-low + 1.
enddo.

I can't imagine, that a select might be faster than a do-enddo loop. Creating this range-table will be (very) fast. (Just prove this in debugging: break-point in line before do and second one after enddo - you won't have to wait for second stop.)

But you can't use this in SELECT-statements. Normally size of where-clause has a KB-restriction, which results in practice in 5000 - 8000 entries of range lines.

If you plan to use this range in IF-statements, your performance will be really bad, because internally each line of this range has to be checked like a single IF-statement (from runtime point-of-view; logically OR / AND connection will be used).

So what the hell is the reason for such a range? (I'm really trying to avoid the word stupid...)

Regards,

Christian