Skip to Content
0
Former Member
Nov 28, 2006 at 04:42 AM

String manipulation

2418 Views

I’m bit new to ABAP and need help on this.

I'm getting a string value from a form field and want to make sure user enters the right value.

User allowed to enter values with or without 2 dashes.

The expected string could be: 9 numbers (‘123-456-789’ or ‘123456789’ ) or 8 numbers (’12-345-678’ or ‘12345678’). No alpha is allowed apart from dash.

If user enters 9 digits with 2 dashes (‘123-456-789’ which is 11 character) or with out 2 dashes (‘123456789’ which is 9 character); I need to strip out the dashes ‘-‘ (if there is any) and then assign each of the numbers to variables e.g. n1 = 1, n2 = 2, n3 = 3, n4 = 4, n5 = 5, n6 = 6, n7 = 7, n8 = 8, n9 = 9 to do some calculations.

If user enters 8 digits with 2 dashes (’12-345-678’ which is 10 character) or with out 2 dashes (‘12345678’ which is 8 character long); I need to strip out the dashes ‘-‘ (if there is any) and then add a leading ‘0’ to make 9 digit and then assign each of the numbers to variables e.g. n1 = 0, n2 = 1, n3 = 2, n4 = 3, n5 = 4, n6 = 5, n7 = 6, n8 = 7, n9 = 8 to do some calculations.

Please help me out.

Kind regards.