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
get the length of the numeric values, alphabets from the COBOL variable
Re: get the length of the numeric values, alphabets from the COBOL variable
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
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
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
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
Thanks zum13, this helps a lot.
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute