Skip to Content
author's profile photo Former Member
Former Member

Creating Range of values

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Feb 11, 2005 at 01:01 AM

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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 11, 2005 at 01:13 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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.

  • author's profile photo Former Member
    Former Member
    Posted on Feb 11, 2005 at 05:15 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 11, 2005 at 08:55 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.