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: 

how to determine range of letters/characters

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

6 REPLIES 6

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

Dennis,

It might be straight forward in case of single characters like the way you have taken the example, but imagine the permutations ancd combinations it can generate with a string of characters or numbers where the interval could get into decimals etc etc.

So, there is no other way than just comparing the end values and go with it.

Regards,

Ravi

Note : Please close the thread, if the question is answered

0 Kudos

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

Former Member
0 Kudos

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