Joined: 22 Aug 2005 Posts: 582 Location: Colarado, US
For eg: like if a variable is defined as 01 N1 PIC X(20). and a value is moved into it, MOVE 'ASDAS' TO N1. then how to retrieve the length of the N1 variable which is 5? the LENGTH OF gives a result of 20.
*************************************************************
Finding the length of a string using the REVERSE function of LE Cobol
*************************************************************
INSPECT FUNCTION REVERSE(TEXT1) TALLYING L FOR LEADING SPACES
COMPUTE L = LENGTH OF TEXT1 - L
where: L is actual length of text in TEXT1. Note!!! TEXT1 remains unchanged after the operation (i.e. it isn't reversed).