‎2008 Aug 14 9:27 AM
Hi,
I need to know wheter a variable has how many letters or composition of both letters and numbers.
Assume: var = '0200000010'.
Here the count is 10, I need to know this strings lenght, how can I do this?
Thanks.
‎2008 Aug 14 9:31 AM
data len type i
data str type string value '1210000000'.
len = strlen( str ).
write 😕 len.
if you want only numbers from STR you can copy the value in a type 'n' variable so it will have only the numeric characters
the you can compare the length and if they are not same, you can know that there is a combination of letters and numbers, the length of the type 'n' variable will give you the count of numeric characters, and the difference in lengths will give you the count of characters.
Edited by: Priyank Jain on Aug 14, 2008 4:32 AM
‎2008 Aug 14 9:31 AM
data len type i
data str type string value '1210000000'.
len = strlen( str ).
write 😕 len.
if you want only numbers from STR you can copy the value in a type 'n' variable so it will have only the numeric characters
the you can compare the length and if they are not same, you can know that there is a combination of letters and numbers, the length of the type 'n' variable will give you the count of numeric characters, and the difference in lengths will give you the count of characters.
Edited by: Priyank Jain on Aug 14, 2008 4:32 AM
‎2008 Aug 14 9:32 AM
Hi
DATA: var TYPE string.
var = '0200000010'.
DATA:length type i.
length = STRLEN( VAR ).
WRITE:/ 'length is', length.
‎2008 Aug 14 9:42 AM
Use FM
DATA : ABC type STRING
DATA : X type i.
ABC = '90ABDC0'.
CALL FUNCTION 'STRING_LENGTH'
IMPORTING
STRING = ABC
EXPORTING
LENGTH = X
.
WRTIE : X.
‎2008 Aug 14 9:50 AM
Hi Deniz,
data: len type i.
If var co '0123456789'. "Contains only numbers
len = strlen( var ).
else.
condense var. "Remove leading and trailing space characters
len = strlen( var ).
endif.
Hope this helps
David Cooper