ImDaEggman
Programmer
Hello friends,
After some unhappy googling, i was not able to find references on how to use an alternate key. Here is my dilemma:
I declared the file using the alternate key - File is opening and starting without troubles.
The problem is while reading, i'm making a random access on the file, moving an account number to be found so i can obbtain its status, and it does not return the correct status, it is as if the account number is always zero.
Ex: account 010
status R
account 000
status L
(It always returns L)
Here is what i'm doing to read:
MOVE WS-ACCOUNT TO BOOK04ACC.
READ FILE4
INVALID KEY
DISPLAY 'DOES NOT EXIST'
AT LINE 25 COL 5
DISPLAY WS-ACCOUNT BOOK04ACC
AT LINE 26 COL 5
ACCEPT KEY-W.
Also it always gives INVALID KEY.
I use the file in the program more than once and i'm initializing like this:
MOVE ZEROS TO FILEAKEY.
START FILE4 KEY IS GREATER THAN BOOK04KEY
END-START.
File declaration:
SELECT FILE4 ASSIGN TO "FIL4"
ORGANIZATION INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS BOOK04KEY WITH DUPLICATES
ALTERNATE KEY IS BOOK04STATUS WITH DUPLICATES
ALTERNATE KEY IS BOOK04CRE WITH DUPLICATES
FILE STATUS IS FS-BOOK04S.
The file has 2 alternate keys... i would like to, in the future, read the account in one and, if not found ,read on the other... but that's for later...
Am i doing this right? What i would have to do to obtain the correct status? I am missing something regarding the use of alternate keys?
Any help would be aprecciated!
After some unhappy googling, i was not able to find references on how to use an alternate key. Here is my dilemma:
I declared the file using the alternate key - File is opening and starting without troubles.
The problem is while reading, i'm making a random access on the file, moving an account number to be found so i can obbtain its status, and it does not return the correct status, it is as if the account number is always zero.
Ex: account 010
status R
account 000
status L
(It always returns L)
Here is what i'm doing to read:
MOVE WS-ACCOUNT TO BOOK04ACC.
READ FILE4
INVALID KEY
DISPLAY 'DOES NOT EXIST'
AT LINE 25 COL 5
DISPLAY WS-ACCOUNT BOOK04ACC
AT LINE 26 COL 5
ACCEPT KEY-W.
Also it always gives INVALID KEY.
I use the file in the program more than once and i'm initializing like this:
MOVE ZEROS TO FILEAKEY.
START FILE4 KEY IS GREATER THAN BOOK04KEY
END-START.
File declaration:
SELECT FILE4 ASSIGN TO "FIL4"
ORGANIZATION INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS BOOK04KEY WITH DUPLICATES
ALTERNATE KEY IS BOOK04STATUS WITH DUPLICATES
ALTERNATE KEY IS BOOK04CRE WITH DUPLICATES
FILE STATUS IS FS-BOOK04S.
The file has 2 alternate keys... i would like to, in the future, read the account in one and, if not found ,read on the other... but that's for later...
Am i doing this right? What i would have to do to obtain the correct status? I am missing something regarding the use of alternate keys?
Any help would be aprecciated!