Skip to Content
avatar image
Former Member

how to determine range of letters/characters

Hello,

In abap, if you know the first letter of a range, and the last letter of a range, how do you determine the letters in between? (or better yet, character values instead of letters of the alphabet).

For example, the first letter is A, the last letter is D. How do you determine that the range of letters is A B C D?

Thanks,

Dennis

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Apr 21, 2006 at 06:24 PM

    Sorry if the question was a little vague.

    Here's a potentially clearer example. The user will enter 2 parameters:

    1. beginning of range... A

    2. ending of range... D

    The program will generate the following list:

    A

    B

    C

    D

    I could maintain an internal table of the letters of the alphabet, and loop and compare, but I was hoping there was a better method.

    Thanks again,

    -Dennis

    Add comment
    10|10000 characters needed characters exceeded

    • Hi,

      You can use this code..

      report  zrange                                  .
      data:w_pos type i,
           w_pos1 type i,
           w_pos2 type i.
      data: begin of t_char occurs 0,
             field,
            end of t_char.
      parameters: p_1,p_2.
      search sy-abcde for p_1 and mark.
      w_pos1 = sy-fdpos.
      search sy-abcde for p_2 and mark.
      w_pos2 = sy-fdpos.
      w_pos = w_pos1.
      while w_pos le w_pos2.
        t_char-field = sy-abcde+w_pos(1).
        append t_char.
        w_pos = w_pos + 1.
      endwhile.
      loop at t_char.
        write:/ t_char-field.
      endloop.

      Regards,

      Suresh Datti

  • avatar image
    Former Member
    Apr 21, 2006 at 06:17 PM

    Dennis,

    I am not sure I completely understand your question.

    Usually RANGES are used to see if a DATA is existing between a specified range, now what is the interval between the individual values of these ranges, we usually don't care as long as the selected values are with in the range.

    For example if you specify a range for documents they are usually incrementd by 1, where as line items are incremented by 10. So, it is not possible to generalise and tell how many values are there with in that range.

    can you explain in detail about the requirement?

    Regards,

    Ravi

    Note : please mark the helpful answers

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 21, 2006 at 06:17 PM

    This is the default dehaviour of SAP.

    SAP will automatically take care of it. You have to use In operator.

    Selection-options : s_char for bapiflag-bapiflag.

    and if you mention A in the S_CHAR-low and D in S_CHAR-HIGH value.

    and if i use this in the select statment like

    Select * form table name where

    variable name in S_CHAR.

    this statement will fetch all values from table where ariable name contains A B C or D.

    Regards

    Aman

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 21, 2006 at 08:06 PM

    Thank you Suresh! This is the kind of solution I was looking for. SY-ABCDE -- I didn't know this existed. Brilliant!

    Add comment
    10|10000 characters needed characters exceeded