Recently, I spent an hour or more debugging a new program that didn't have a bug. The program is a never-ending program that runs in a batch subsystem and spends most of its time waiting to read data from a data queue. When a user presses a certain function key, the interactive program writes information to the data queue with a call to QSNDDTAQ. The never-ending program then reads the data queue, performs some processing, and writes information to a file. During the unit-testing stage, I discovered that the program didn't appear to write to the file-or so I thought. After I ended the program, the records were there!
A colleague and I discovered that this strange behavior was due to the default value of the "Records to force a write" or FRCRATIO parameter of the Create Physical File (CRTPF) and Create Logical File (CRTLF) commands. The default is *NONE; when I changed it to 1, the program worked as I thought it should.
Here's why. When OS/400 writes records to DASD, it does not always write them immediately. Instead, the operating system writes the records to a buffer area in memory. Records are written to DASD when the buffer is full or when the file is closed. Assuming that the memory buffer is a fixed size, records for files with large record sizes will be written to DASD sooner than records for files with small record sizes.
When you set the FRCRATIO parameter to *NONE, you have no control over when the operating system writes the records to DASD. OS/400 determines when it is appropriate to write them. The AS/400 can operate more efficiently this way. If your program ends after writing to the file, then you should let this parameter default to *NONE because OS/400 writes the records then anyway. A program that writes several records before it closes the file will operate more efficiently if it can write all the records in one burst.
If you set this parameter to a number, you control when the records are written. The number represents how many records you want OS/400 to buffer before it will write them to DASD. In my situation, I wanted the record to be written immediately so I set FRCRATIO to 1.
Proper use of this parameter could save considerable time when you write or debug programs. It could also make your system more efficient once your program enters the production environment.
LATEST COMMENTS
MC Press Online