Close CMPRT01

Hi :

We have a lot of Subprograms that uses WRITE (1) to generate. We need now to do next :
In Batch (on an z/os); I have specified CMPRT01 as a file (not as sysout class)
From a Natural program we’ll call this subprogram and after invoking it we need to process the data written in CMPRT01, but if we open it as a Workfile (“DEFINE WORK FILE 1 ‘DDN=CMPRT01’”) we read an empty file because CMPRT01 was never closed. I have tried with CLOSE work file, but It doesn’t work.
Is it possible to force a CLOSE of CMPRT1 ? After the close , I can read the data written by the subprogram.
I don’t want to modify 100’s of programs to change WRITE (1) to WRITE Workfile

I have also used Close PRINTER but it is not enough.
I think I need to allocate / deallocate Dynamically the used file

I use USR2021N to alloc and unalloc but I got this problem :

Using USR2021N I alloc a file with DDN=FIC1

and some WRITE (1)

When I finish I use
CLOSE PRINTER (1) and just after it, I use USR2021N to unalloc DDname FIC1
But I get this error
ALC-ERROR-TXT SVC 99: Environmental error: 0420

This error means that :
Meaning: Specified ddname or dsname associated
with an open data set. (ddname allocation,
concatenation, deconcatenation, unallocation,
dsname allocation)(1)

Application Programmer Action: Change ddname or
dsname, or close the open data set needed.

Why it’s open if I have used an CLOSE PRINTER (1)

Is this a bug ?
Is it a normal behavior ?

Check the setting of the CLOSE sub-parameter of the Natural PRINT profile parameter,

If this is set to FIN, which is the default for batch environments, you won’t be able to de-allocate the file, because it’s only closed when your Natural session terminates:

From the documentation:

With CLOSE=FIN, a DEFINE PRINTER statement causes an error if the printer was opened already. A CLOSE PRINTER statement for the printer is ignored.

Set this parm to CLOSE=USER and it should work.