Re: REWRITE query
From: William M. Klein (wmklein_at_nospam.netcom.com)
Date: 01/20/04
- Next message: Peter E.C. Dashwood: "Re: Convert Cobol to language w/o goto (was: How many lines of Cobol running worldwide???)"
- Previous message: William M. Klein: "OT (was: Standards question on edited fields"
- In reply to: ritchie: "REWRITE query"
- Next in thread: Richard: "Re: REWRITE query"
- Reply: Richard: "Re: REWRITE query"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 20 Jan 2004 22:17:15 GMT
Your problem is:
move account-no-in to file1-key
read file1
invalid key
for a file in DYNAMIC access mode, a "read" with no KEY phrase is a SEQUENTIAL
read, so you are actually just doing a "read next". You can either use the
START statement to position your read or use the KEY phare on the READ.
-- Bill Klein wmklein <at> ix.netcom.com "ritchie" <ritchie_s01@yahoo.com> wrote in message news:3bee6ba6.0401201007.4dd29014@posting.google.com... > Hi, > > I am trying to amend a record already on file using rewrite. > This para first gets the account number to be amended, from the user. > Then reads 'file1' to see if this account exists. Then, if it does, > it reads 'file2' > for the first transaction corresponding to this account number, and > displays the amount. > I then try to do a rewrite of the amount but get a file status 23 even > though this > record is on file2. > > This file status of '23' (record not found) is after the rewrite. > When I read the file before-hand it displays the correct amount for > that specific > account, as it should, but then I try to rewrite with the new amount > and have this problem. > I have checked the file keys and they 'seem' to have the correct > values. > > This is the same file setup I use for adding to both 'file1' and > 'file2' and I have no > problems there. > > I'm not sure what's going wrong here. > Could the keys be defined incorrectly? I suspect that this could be > the case. > > Any help would be much aprechiated. > > Thanks in advance, > Ritchie > > P.S (using Fujitsu v3 compiler) > PLEASE forgive the formatting. > > ************* START CODE > ********************************************** > FILE-CONTROL. > select file1 assign "file1.dat" > ORGANIZATION IS Indexed > ACCESS MODE IS DYNAMIC > RECORD KEY IS Account-no > ALTERNATE RECORD KEY IS Account-name > WITH DUPLICATES > FILE STATUS IS file1-status. > select Transactions ASSIGN TO "file2.dat" > ORGANIZATION IS Indexed > ACCESS MODE IS DYNAMIC > RECORD KEY IS Transaction-no > ALTERNATE RECORD KEY IS Transaction-date > WITH DUPLICATES > FILE STATUS IS file2-status. > ... > FD Accounts. > 01 file1. > 03 Account-no PIC X(14). > 03 Account-lname PIC A(30). > .... > FD Transactions. > 01 file2. > 03 Transaction-no. > 05 Transaction-ac PIC X(14). > ... > 05 trans-amt PIC 9(5)v99. > ... > AMEND-TRANS > ***get account num from user > display "Enter account no > " > accept account-no-in > ***move value to file1 key > move account-no-in to file1-key > read file1 > invalid key > .. > not invalid key > if file-status-ok > display "Account found" > end-if > ***move file1 key to file2 key for read of file2 > move file1-key to file2-key > > set not-eof-file2 to true > ***start file2 at position of the account number found from file1 read > (ok up to here) > start file2 KEY >= account-no-in > > perform until eof-file2 or file1-key not = Transaction-ac > read file2 next record at end set eof-file2 to true > not at end > if file1-key = file2-key > set not-eof-file2 to true > ***display amount fr this account (still ok up to here) > display "Transaction old amount > " trans-amt > > display "Enter new amount" > accept new-amt > > move new-amt TO trans-amt > rewrite file2 > end-rewrite > ***ERROR - file status 23 here - but record is on file. > end-if > end-read > end-perform. > ***********************END CODE***************************************
- Next message: Peter E.C. Dashwood: "Re: Convert Cobol to language w/o goto (was: How many lines of Cobol running worldwide???)"
- Previous message: William M. Klein: "OT (was: Standards question on edited fields"
- In reply to: ritchie: "REWRITE query"
- Next in thread: Richard: "Re: REWRITE query"
- Reply: Richard: "Re: REWRITE query"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|