I happened to notice that when a natural program terminates with NAT1507, not all rows written to work file are reflected there. Can anyone help me understand this please?
Natural Code
DEFINE DATA
LOCAL
1 #I (N10)
END-DEFINE
REPEAT
WRITE #I
WRITE WORK FILE 1 #I
#I := #I + 1
WHILE TRUE
END-REPEAT
END
I had allocated SPACE=(TRK,(1,1),RLSE) for Work File 1 to force abend.
Last record in Work file 1 : 0000089567
Last record in CMPRINT
103563
SAMPLE 0070 NAT1507 The WORK file 1 is full.
Well, in my opinion (just my 2 cents SYSOUT and work file handled differently by OS (and perhaps by NATURAL as well).
The job itself must be finished CORRECTLY (without any ABEND); then, one might really talk about comparing numbers on SYSOUT and WORK FILE.
Meanwhile :-), I have done some tests which confirm - as I think - my first statement.
First, I slightly changed the program by adding 2 CLOSEs:
ON ERROR
CLOSE WORK FILE 1
CLOSE PRINTER (1)
END-ERROR
Then, for the “same DCBs” and SPACE(?)
DCB=(RECFM=F,LRECL=80,BLKSIZE=80,DSORG=PS),SPACE=(TRK,(1,0))
I got the following:
a) on the PRINT (the program does write (1)
RECORD PRINTED 77 - the last record,
on the work file 1 (write work file 1) - EMPTY (no data at all).
However, after changing the SPACE (with same DCB) as follows:
SPACE=(TRK,(1,1)) I got the following:
RECORD PRINTED 1247 (on sysout) - the last one
RECORD WRITTEN 001247 (on work file 1); SYSOUT = WORK FILE 1
Well, I’m waiting for your comments
Thanks for your effort
I tried your suggestion and a bit further hoping for some adventure. Below is the modified code I have run
DEFINE DATA
LOCAL
1 #I (N10)
END-DEFINE
ON ERROR
CLOSE WORK FILE 1
CLOSE WORK FILE 2
CLOSE PRINTER (1)
END-ERROR
REPEAT
WRITE #I
WRITE WORK FILE 1 #I
WRITE WORK FILE 2 #I
#I := #I + 1
WHILE TRUE
END-REPEAT
END
I agree to your point on jobs finishing without ABEND for comparing SYSOUT & WORKFILE contents.
With this program I hope to gain some insight on the working of NATURAL engine, OS and how they handle ERRORs in consensus in case of an ABEND.
By the way, I missed to point out that the program don’t ABEND in my case, they end with RC=04.
Well, I think it is rather a question of terminology: ABEND or not ABEND.
I`m sure if you take a look at the SYSTEM (JES) messages regarding your own job, you would find something like:
IEC030I B37-04,IFG0554A,…
B37-04 - is is NOT the sign of NORMAL ending; NATURAL simply intercepted this kind of ERROR (ABEND from the OS point of view) and displayed RC=4 just to catch your own attention in terms of “ERROR should be corrected”. And when there`s an ERROR present, it MUST be corrected first
As Natural writes the records out, the system buffers them and writes them to disk when a block is full. At the time the block is written out, the system detects that the number of extents has been exceeded and abends (which is captured by Natural and reported as a NAT1507).
Thus, the writes with SPACE=(TRK,(1,1)) to work file 1 and SPACE=(TRK,(2,5)) to work file 2 just means that WORK FILE 2 has no errors and, at the time of ABEND, all the data in the buffers for WORK FILE 2 can be successfully written out. The amount of data written out on the file that ABENDs will vary somewhat, depending on what the buffers (BUFNO) are set to - with a higher BUFNO, the number of blocks buffered will be higher and more data will be lost when those buffers are actually flushed to disk and the maximum extents error is triggered.
If you require higher reliability on the data being written to disk, you can try BUFNO=0 and set your blocksize to the record length (RECFM=F,LRECL=10,BLKSIZE=10). Other variables that will impact the amount of data that actually gets written to disk will include the underlying disk types and buffering that provides. You could allocate the work files with DISP=(MOD,CATLG,CATLG) and do a CLOSE WORK FILE after every write - then only the last write should ever be lost (but performance will suffer greatly - CPU consumption will rise and disk write speed will drop).