Page 1 of 1
get the length of the numeric values, alphabets from the COBOL variable
Posted: Mon Jun 03, 2024 2:10 pm
by pinball
Hi,
I have variable like below
01 ws-a pic x(30) value 'abcd234567@#₹....'
I want to get the length of the numeric values, alphabets
Re: get the length of the numeric values, alphabets from the COBOL variable
Posted: Mon Jun 03, 2024 3:29 pm
by zum13
Hello.
There is a "LENGTH" function and the "LENGTH OF" keywords, but these only provide the length of the field and not the length of the data within. This came up fairly recently, so you'll hopefully find what you need in this thread:
viewtopic.php?p=36828#p36828
Re: get the length of the numeric values, alphabets from the COBOL variable
Posted: Tue Jun 11, 2024 8:39 pm
by pinball
Thanks again zum13, that thread is helpful. How can we know that the read character is numeral or alphabet, once the length is known?
Re: get the length of the numeric values, alphabets from the COBOL variable
Posted: Wed Jun 12, 2024 1:50 am
by zum13
An "IS NUMERIC" check will do the job, for example:
Code: Select all
IF WA-STRING(1:WA-LENGTH) IS NUMERIC
do stuff here
END-IF
Re: get the length of the numeric values, alphabets from the COBOL variable
Posted: Tue Jul 16, 2024 11:22 am
by pinball
Thanks zum13, this helps a lot.