We are writing the header only once in separate para but I could able to see some part of header also getting displayed after every 1000 records in the output file. TCE-CLASS is a part of header which get overwritten after every 1000 records. Could you please help me out here?

In the above record R, AA-FLAG, AAAA-FLAG is actually header details which is written into the output file only once using separate para. But after every 1000 records in the output file I could able to see some part of the header also present along with the details. We are suing same record to write header and data. We are initializing it after every write.

The default for QSAM buffering is 5 buffers. It sounds like there's something going on in your program in that your header is not cleared from the buffer and hence recurs every time that buffer comes up for reuse.

Very definnitely a programming problem -- you need to start analyzing the code to determine why this is happening.

In the above record R, AA-FLAG, AAAA-FLAG is actually header details [...]

I know you are going to tell me that it is due to you re-typing, but aaa-FLAG is not the same as AA-FLAG etc. The data that is allegedly from the header does not even line up with the fields on the detail records. When you post some data from your screen, paste it, don't re-type it. We don't want to spend time on yout typos.

If parts of the data on some of your records happen to coincide with parts of the data you have written as a header there is very close to zero chance of it being other than an error in your program, or JCL, or something you have done.

Start by considering what you have been asked already. What happens in your program at "1000"? How about showing the code which is creating the detail record, not showing us the code creating the header (which you have not claimed is a problem)?

Why are you using STRING? Are you using STRING also for the detail records? Are all the fields fixed-length and undelimited? They look so from what you have shown.

This info was a real help. It is the problem with default beffer size.
128000byte = 25600*5
5 is the default buffer number of QSAM. It mean to me like once 5 buffer(let take 1 block as one buffer) is filled actual write takes place. So the filler get displayed only after every 1000 records.

---
I tried running a job with
output dataset having RECL = 128 and BLOCK Size = 27904.
Now,
27904/128 = 218 and 218*5 = 1090.
In the output dataset the header record were repeating after 1090 records

similarly another try , RECL was 112 and BLK Size was 27888.
27888/112 = 249 and 249 * 5 = 1245
The header was repeating after every 1245 records in the dataset

horse manure....
but, if You are happy we are happy, ( or rather we do not care )
f Your code was correct then no spurious data would appear, whatever the <i/o> parameters ( buffer setup )

wiser to review the behavior of the WRITE statement the way You are using it ( locate mode )
it has some interesting gotchas,
certainly somebody proficient in COBOL will tell ( laughing ) what happens when mixing in the same program move and locate mode
( it' s for You Bill )

athulvijay, you did EXACTLY what I recommended in my earlier post, and the results were exactly what I thought would happen, yet your conclusion is diametrically opposed to the conclusion I provided.

Contrary to what you think, this particular problem CANNOT be caused anywhere except in your program. And your reaction tells me you are another one of the Immaculate Programmers -- you never wrote a bad line of code, so every problem MUST be a system problem (since your code could never be wrong). Professional programmers see a problem and immediately ask what they could have done in their code to cause that problem; Immaculate Programmer see a problem and blame the system for days (or in some cases, months) until it is proven that their code is flawed.