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 split Char and digits in a string??

Former Member
0 Kudos
1,228

Dear All,

Pl tell me how to slit Char and Digits in a String???

e.g 00123abcd

00123 and abcd

Regards,

Rushikesh

5 REPLIES 5

0 Kudos
284

Hi,

This is possible if there is any delimiter, using SPLIT command.

Regards,

Sesh

Former Member
0 Kudos
284

Hi,

DATA: int_char(10) type c value '0123456789',

var type char 20 value '1234abmd',

ws_char type char20,

ws_dig type char20.

if var CO sy-abcde.

  • only alphabets

clear var.

elseif var CO int_char.

  • only numberics

clear var.

else.

Special cases.

endif.

<b>SORRY..</b> this code will only checks for numeric or non meric characters....No of ur use...

Hope this helps.

Manish

Message was edited by:

Manish Kumar

Message was edited by:

Manish Kumar

Former Member
0 Kudos
284

DATA : POS TYPE I.

DATA : VAR TYPE STRING VALUE '00123ABCD'.

LOOP.

IF VAR+0(SY-INDEX) BETWEEN 0 AND 9.

CONTINUE.

ELSE

POS = SY-INDEX.

EXIT.

ENDIF.

ENDLOOP.

VAR1 = VAR+0(SY-INDEX).

VAR2 = VAR+SY-INDEX(LENGTH OF THE STRING).

Regards,

Ravi

Note :Please makr all the helpful ansewrs

Former Member
0 Kudos
284

Hi

Try this sample:

PARAMETERS _STRING(100).

DATA: NUMBER(100),
          DIGIT(100).

DATA: LEN    TYPE I,
           POS   TYPE I,
           POSN TYPE I,
           POSD TYPE I.


LEN = STRLEN(  _STRING ).

DO LEN TIMES.
  _CHAR = _STRING+POS(1).
  IF _CHAR CO '0123456789'.
    MOVE _CHAR TO NUMBER+POSN.
    POSN = POSN + 1.
  ELSE.
    MOVE _CHAR TO DIGIT+POSD.
    POSD = POSD + 1.
  ENDIF.
  POS = POS + 1.
ENDDO.
WRITE: _STRING,
            / NUMBER,
            / DIGIT.

Max

Former Member
0 Kudos
284

hi,

Pass it on to a character variable and use offset .


data : v_char(10),v_char1(40),
          v_string type string  .

      v_char = v_string.

      v_char1 = v_char + 0(4). 

Regards,

Santosh