# Rows missing from work file on NAT1507

**URL:** <https://techcommunity.softwareag.com/t/rows-missing-from-work-file-on-nat1507/192658>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [January 13, 2017, 10:48am UTC](https://techcommunity.softwareag.com/t/rows-missing-from-work-file-on-nat1507/192658 "2017-01-13T10:48:18Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kannan\_Raveendran\_Nair](https://avatars.discourse-cdn.com/v4/letter/k/e9a140/32.png) [@Kannan\_Raveendran\_Nair](https://techcommunity.softwareag.com/u/Kannan_Raveendran_Nair)\
**Post date:** [January 13, 2017, 10:48am UTC](https://techcommunity.softwareag.com/t/rows-missing-from-work-file-on-nat1507/192658/1 "2017-01-13T10:48:18Z")

</div>

Hi All,

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?

```auto

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.

Thanks,  
Kannan

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [January 13, 2017, 2:41pm UTC](https://techcommunity.softwareag.com/t/rows-missing-from-work-file-on-nat1507/192658/2 "2017-01-13T14:41:58Z")

</div>

Can you show the full DCB you are using for Workfile 1, please ?

---

<div class="post-metadata">

**Author:** ![Nikolay\_Kuhta](https://avatars.discourse-cdn.com/v4/letter/n/35a633/32.png) [@Nikolay\_Kuhta](https://techcommunity.softwareag.com/u/Nikolay_Kuhta)\
**Post date:** [January 13, 2017, 3:11pm UTC](https://techcommunity.softwareag.com/t/rows-missing-from-work-file-on-nat1507/192658/3 "2017-01-13T15:11:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Nikolay\_Kuhta](https://avatars.discourse-cdn.com/v4/letter/n/35a633/32.png) [@Nikolay\_Kuhta](https://techcommunity.softwareag.com/u/Nikolay_Kuhta)\
**Post date:** [January 13, 2017, 3:47pm UTC](https://techcommunity.softwareag.com/t/rows-missing-from-work-file-on-nat1507/192658/4 "2017-01-13T15:47:28Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![Kannan\_Raveendran\_Nair](https://avatars.discourse-cdn.com/v4/letter/k/e9a140/32.png) [@Kannan\_Raveendran\_Nair](https://techcommunity.softwareag.com/u/Kannan_Raveendran_Nair)\
**Post date:** [January 16, 2017, 6:07am UTC](https://techcommunity.softwareag.com/t/rows-missing-from-work-file-on-nat1507/192658/5 "2017-01-16T06:07:15Z")

</div>

> [@Wolfgang Winter](#):
>
> Can you show the full DCB you are using for Workfile 1, please ?

I have used the following DCB parms  
DCB=(LRECL=10,RECFM=FB)

---

<div class="post-metadata">

**Author:** ![Kannan\_Raveendran\_Nair](https://avatars.discourse-cdn.com/v4/letter/k/e9a140/32.png) [@Kannan\_Raveendran\_Nair](https://techcommunity.softwareag.com/u/Kannan_Raveendran_Nair)\
**Post date:** [January 16, 2017, 6:30am UTC](https://techcommunity.softwareag.com/t/rows-missing-from-work-file-on-nat1507/192658/6 "2017-01-16T06:30:36Z")

</div>

> [@Nikolay Kuhta](#):
>
> 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

```auto

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           
```

And the jcl looks like

```auto

//CMPRINT DD SYSOUT=R                   
//CMPRT01 DD SYSOUT=R                   
//CMWKF01 DD DSN=SAMPLE.TEST.FILE1,  
// DISP=(NEW,CATLG,CATLG),        
// SPACE=(TRK,(1,1),RLSE),        
// DCB=(LRECL=10,RECFM=FB)        
//CMWKF02 DD DSN=SAMPLE.TEST.FILE2,  
// DISP=(NEW,CATLG,CATLG),        
// SPACE=(TRK,(2,5),RLSE),        
// DCB=(LRECL=10,RECFM=FB)        
//SYSIN DD *                          
LOGON DEVLIB                            
SAMPLE                                   
FIN                                        
/*                                         
```

And the results are  
CMPRINT  
30789  
SAMPLE 0120 NAT1507 The WORK file 1 is full.  
NEXT FIN  
NAT9978 Error occurred during execution/compilation.

WORK FILE 1  
0000016793

WORK FILE 2  
0000030788

Can this be due to some NATURAL settings specific to my shop?

---

<div class="post-metadata">

**Author:** ![Kannan\_Raveendran\_Nair](https://avatars.discourse-cdn.com/v4/letter/k/e9a140/32.png) [@Kannan\_Raveendran\_Nair](https://techcommunity.softwareag.com/u/Kannan_Raveendran_Nair)\
**Post date:** [January 16, 2017, 6:44am UTC](https://techcommunity.softwareag.com/t/rows-missing-from-work-file-on-nat1507/192658/7 "2017-01-16T06:44:42Z")

</div>

> [@Nikolay Kuhta](#):
>
> 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.

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.

---

<div class="post-metadata">

**Author:** ![Nikolay\_Kuhta](https://avatars.discourse-cdn.com/v4/letter/n/35a633/32.png) [@Nikolay\_Kuhta](https://techcommunity.softwareag.com/u/Nikolay_Kuhta)\
**Post date:** [January 16, 2017, 2:48pm UTC](https://techcommunity.softwareag.com/t/rows-missing-from-work-file-on-nat1507/192658/8 "2017-01-16T14:48:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Douglas\_Kelly](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/douglas_kelly/32/102_2.png) [@Douglas\_Kelly](https://techcommunity.softwareag.com/u/Douglas_Kelly)\
**Post date:** [January 17, 2017, 1:50am UTC](https://techcommunity.softwareag.com/t/rows-missing-from-work-file-on-nat1507/192658/9 "2017-01-17T01:50:58Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![Kannan\_Raveendran\_Nair](https://avatars.discourse-cdn.com/v4/letter/k/e9a140/32.png) [@Kannan\_Raveendran\_Nair](https://techcommunity.softwareag.com/u/Kannan_Raveendran_Nair)\
**Post date:** [January 17, 2017, 7:07am UTC](https://techcommunity.softwareag.com/t/rows-missing-from-work-file-on-nat1507/192658/10 "2017-01-17T07:07:50Z")

</div>

Thanks Douglas. That explains the data loss.  
Thanks for your thoughts and time Nikolay.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:37pm UTC](https://techcommunity.softwareag.com/t/rows-missing-from-work-file-on-nat1507/192658/11 "2021-04-02T15:37:44Z")

</div>


