parsingsyntax-errorfieldcobol

Moving LENGTH OF to a COMP field fails parse


I receive a PARSE ERROR on the MOVE statement below indicated by the comment. I have tried a variety of changes, but I cannot discern what is wrong. I am new to COBOL. Sorry for the horrible formatting of the code. Using RainCode COBOL compiler. Thank you in advance for any help.

LOCAL-STORAGE SECTION

01  CUSTOMER-RECORD.

     05 CUST-FIRST-NAME          PIC X(26).
     05 CUST-LAST-NAME           PIC X(26).
01 MYLENGTH PIC 9(3) COMP VALUE ZEROES.

DISPLAY-CUSTOMER-RECORD SECTION.
      
INSPECT CUST-FIRST-NAME TALLYING TRAILING-BLANKS FOR 
      TRAILING SPACES.
      MOVE ZEROES TO MYLENGTH.
      MOVE LENGTH OF (CUST-FIRST-NAME) TO MYLENGTH.  *> Receives PARSE ERROR

Solution

  • LENGTH OF is not a function, it is a special register. Try leaving out the parentheses around CUST-FIRST-NAME.