Skip to Content

Get All numbers between from and to numbers

All,

I have a few from and to numbers in an internal table, I needs all the numbers between the each from and to numbers in that internal table ..

say for example

FROMNO        TONO
10            100
111           200
201           210

I want the output as number

NUMBER
10
11
12
13
..
..
210

I am looking for some function modules and pass the internal in one attempt and get all numbers as output.

PS: Please donot suggest loop at itab and generate numbers

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Jul 08, 2010 at 05:42 AM

    Hi,

    PS: Please donot suggest loop at itab and generate numbers

    I doubt that you will find a FM for your requirement. Anyway I have a question for you. Even if there was a function module for you requirement what do you think how it would be implemented? If you want to generate a list of number then you have to have a loop in your code (tail recursion is basically same as loop). Why can't you just develop your own function module?

    Cheers

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi,

      Use function module 'SYS_COUNTER_CREATE', 'SYS_COUNTER_ADD' and 'SYS_COUNTER_READ' .

      'SYS_COUNTER_CREATE' - used to create counter, pass new counter name and counter value.

      'SYS_COUNTER_ADD' - pass the same counter name and the counter value to be added (by default its 1),

      'SYS_COUNTER_READ' - to read the counter value, pass the counter name.

      Regards,

      Nayeem

  • Posted on Jul 08, 2010 at 08:55 AM

    Hi ,

    This can be done via logic instead of Fm's.

    I remember Amit G asking you a question.

    Is your user id and password Hacked ?

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 08, 2010 at 10:49 AM

    May be there is no standard function module available but if at all you would implement the custom function module:

    1) create a custom table with one field say counter and maintain field values say from 1 to 100.

    2) in you function module code put select query and fetch the range of values by putting counter >= 1 and counter <=50

    3) this would populate the list of 1, 2 , 4 .....50

    This way you avoid LOOP.

    If you have some master table for you fiels say SKA1 then probably you dont need to create custom table you can say saknr >=1 and like wise get the value list.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 08, 2010 at 12:03 PM

    hey a®s ,

    are these from and to values some kind of select options? Do you have a database table on which this bases?

    if so you could use a simple

    Select NUMBER

    from table

    into table lt_numbers

    where number in YOUR_SELECT OPTION.

    well it is no SAP standard FM, but simple SAP STANDARD SELECT. maybe this helps, tho considering your reputation here i dont really think you are not aware of this solution. But since you never know i added my answer.

    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.