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: 

oposite number range

Former Member
0 Kudos
151

i have range

158-156

i want

156-158

i tried string_reverse not work,any idea.

i get this in line with 151,152,158-156,160....

8 REPLIES 8

Former Member
0 Kudos
115

Hi

Check the Number range related Tcodes

<b>SNRO and SNUM</b> and the fun module

NUMBER_GET_NEXT

<b><REMOVED BY MODERATOR></b>

regards

Anji

Message was edited by:

Alvaro Tejada Galindo

0 Kudos
115

friend i will clear myself

i have this line

151,152,158-156,160 in 1 parameter.

<b>

151,152,156-158,160</b> i want to get this.

0 Kudos
115

again

temp = 151,152,158-156,160

after change

temp = 151,152,156-158,160

0 Kudos
115

Oh my god... You'll have to create a DO loop. And split at the comma first into two variables.

Then try to split the first var again at '-'. If succesfull (the string is a range), check if the first var is greater. If so concatenate again but then in the opposirte order.

Do this until the complete string is processed.

Not nice, but anyway.

0 Kudos
115

hi

i think better to divide 151 is a

152 is b

158-156 is d

then u will split it that num and

concatnate the total a b d in g.

ok

regards

kk

Former Member
0 Kudos
115

Assuming that 158-156 is a string and not a range:

Use SPLIT AT '-' to split the original_string into two help-variables (type N).

If the first is higher, concatenate <string2> '-' <string1> into the original_string, if not use the original_string...

JozsefSzikszai
Active Contributor
0 Kudos
115

hi richi,

IF range-low GT range-high.

value = range-low.

range-low = range-high.

range-high = value.

ENDIF.

of course value has to have the same type like range low (or range-high).

hope this help, come back if it does not

ec

Former Member
0 Kudos
115

The code below works, although it's not nice...

REPORT zbc_temp.

DATA: tp_in  TYPE line VALUE '151,152,158-156,160'.
DATA: tp_out TYPE line.
DATA: var1 TYPE line.  "Left:  Split at comma
DATA: var2 TYPE line.  "Right: Split at comma
DATA: var3 TYPE numc4. "Left:  Split at dash
DATA: var4 TYPE numc4. "Right: Split at dash

WRITE: tp_in.

DO.
  SPLIT tp_in AT ',' INTO var1 tp_in.
  IF var1 <> ''.
    IF var1 CS '-'.
      SPLIT var1 AT '-' INTO var3 var4.
      IF var3 > var4.
        CONCATENATE var4 '-' var3 INTO var1.
      ENDIF.
    ENDIF.
    CONCATENATE tp_out ',' var1 INTO tp_out.
  ELSE.
    SHIFT tp_out LEFT DELETING LEADING ','.
    EXIT.
  ENDIF.
ENDDO.

WRITE: tp_out.