My Batch program has to read a file(CUSTACFL) for which a key (ACNT-SRC-CUST-KEY) is used.
At very first run the program reads the file correctly but after that for all the subsequent reads it gives the invalid key and hence error code of 23.
I am initializing the key before the next read.
One more question :- My program opens the file(CUSTACFL) each time it has to read even if it is opened . I know this is not right but can this be the cause of the invalid key ?
Please help to know what could be the probable reason for the "invalid key" error.
I have a code pasted below :
OPEN INPUT CUSTACFL.
INITIALIZE W01-COMPST-KEY.
INITIALIZE ACNT-SRC-CUST-KEY.
MOVE CACI-ACNT-N TO W01-ACNT-NUM.
MOVE CACI-SOURC-SYSTM-N TO W01-SRC-SYS.
MOVE CACI-CUST-N TO W01-CUST-NUM.
MOVE W01-COMPST-KEY TO ACNT-SRC-CUST-KEY.
READ CUSTACFL KEY IS ACNT-SRC-CUST-KEY
INVALID KEY
MOVE 'N' TO W01-CACICURS-FOUND
END-READ.
EVALUATE W01-CUSTAC-FL-STAT
WHEN 0
MOVE 'Y' TO W01-CACICURS-FOUND
WHEN 23
MOVE 'N' TO W01-CACICURS-FOUND
END-EVALUATE.
Joined: 06 Jun 2008 Posts: 8280 Location: Dubuque, Iowa, USA
Quote:
One more question :- My program opens the file(CUSTACFL) each time it has to read even if it is opened . I know this is not right but can this be the cause of the invalid key ?
Fix this and then try again. Most likely the invalid key is due to opening a file already open and then trying to read from it.