Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Looping string characters?

Tags:

string

abap

How can I read each character in a String? For example, I want to read each character in String "a7m4d0". After that I want to verify that each character is a character or a number. Any tips or ideas?

like image 644
ayahya82 Avatar asked Sep 16 '26 02:09

ayahya82


1 Answers

DATA: smth TYPE string VALUE `qwert1yua22sd123bnm,`,
      index TYPE i,
      length TYPE i,
      char  TYPE c,
      num   TYPE i.

length = STRLEN( smth ).

WHILE index < length.
  char = smth+index(1).
  TRY .
      num = char.
      WRITE: / num,'was a number'.
    CATCH cx_sy_conversion_no_number.
      WRITE: / char,'was no number'.
  ENDTRY.
  ADD 1 TO index.
ENDWHILE.

Here's your problem solved :P

like image 71
vlad-ardelean Avatar answered Sep 20 '26 01:09

vlad-ardelean



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!