View previous topic :: View next topic
|
Author |
Message |
vab987
New User
Joined: 01 Dec 2006 Posts: 29 Location: S.A
|
|
|
|
Hi All,
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.
Regards,
Vab |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 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. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Vab,
Another thing to consider is the performance impact of OPENing the file before each READ.
I worked on correcting that type of coding and the job run time was reduced from over 3 hrs to 10 mins.
Where the OPEN creates an error condition, it may have an even bigger impact on performance. |
|
Back to top |
|
|
vab987
New User
Joined: 01 Dec 2006 Posts: 29 Location: S.A
|
|
|
|
Hi,
As stated by Robert and mmwife, the problem for " Invalid key err message " was opening the same file again and again without closing.
Thanks,
Vab |
|
Back to top |
|
|
|