Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Easytrieve Question on VSAM Files 1

Status
Not open for further replies.

jjc3397

Programmer
Dec 21, 2003
55
US
I have an Easytrieve question using a VSAM File and an OutPUT File called Newfil2. I need to link these two files together. I can't seem to link them without getting a error message Invalid File Reference A010 for FileA. Please see formats and code below.
File FileA VS
K-code-num 89 3 P 0
K-code-prefix 92 1 A
Pack 93 2 P
BTL-RET 95 3 P 2
BTL-CST 98 3 P 2
KEYX W 4 A
Key1 KeyX 3 P
Key2 KeyX +1 1 A
File FileO
Ostore 1 3 N
Onumber 4 4 N
OAlpha 8 1 A
O-Litters 9 11 N 4
OBotsold 20 6 N
OLocation 26 18 A
Tot-Bottles W 6 P 0
Tot-Litters W 7 P 3
Total-Litters W 6 N
Job Input FileO
Read FileA Key KeyX Status
Key1 = K-code-num
Key2 = K-code-prefix
If Filea: File-status NE 0
Goto Job
Else
If Obotsold = 0
GoTo Job
end-if
Cost-sales = BTL-CSt * Obotsold
Bot-Retail-Cost = BTL-Ret * Obotsold
Total-Litters = o-Litters + o-Litters
Lit-sales = o-litters + Obotsold
End-if


I can't link FileO and the VSam File FileA
I have the wrong code somewhere.

Anybody out there, please help.

Thanks


jjc3397
 
Invalid file reference is usually caused by referring to a field in the file definition before a successful read has been done. I notice in your code you refer to KEY1 and KEY2 prior to checking the status of the file read, if the read was not successful, I believe you would get the error message there. I would suggest moving the status check to right after the read. Hope this helps.
 
Of course it's not lining up. Your code is in the wrong sequence.

Job Input FileO
Read FileA Key KeyX Status
Key1 = K-code-num
Key2 = K-code-prefix

First you read FILEO. At that moment, you've got NOTHING in your W field. Then you tried to read FILEA using the empty W field (so it doesn't find anything). Then you copied data over to the W field and Go to job. The next time through, there is something in the W field, so the READ finally works, but it's the data for the PREVIOUS record.

Move the Key, then READ.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top