# Close CMPRT01

**URL:** <https://techcommunity.softwareag.com/t/close-cmprt01/74989>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [July 7, 2007, 4:28pm UTC](https://techcommunity.softwareag.com/t/close-cmprt01/74989 "2007-07-07T16:28:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pakito](https://avatars.discourse-cdn.com/v4/letter/p/dc4da7/32.png) [@pakito](https://techcommunity.softwareag.com/u/pakito)\
**Post date:** [July 7, 2007, 4:28pm UTC](https://techcommunity.softwareag.com/t/close-cmprt01/74989/1 "2007-07-07T16:28:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pakito](https://avatars.discourse-cdn.com/v4/letter/p/dc4da7/32.png) [@pakito](https://techcommunity.softwareag.com/u/pakito)\
**Post date:** [July 7, 2007, 11:24pm UTC](https://techcommunity.softwareag.com/t/close-cmprt01/74989/2 "2007-07-07T23:24:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pakito](https://avatars.discourse-cdn.com/v4/letter/p/dc4da7/32.png) [@pakito](https://techcommunity.softwareag.com/u/pakito)\
**Post date:** [July 10, 2007, 12:50am UTC](https://techcommunity.softwareag.com/t/close-cmprt01/74989/3 "2007-07-10T00:50:34Z")

</div>

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

Using USR2021N I alloc a file with DDN=FIC1

I use DEFINE PRINTER (1) OUTPUT ‘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-CODE 0420  
ALC-INFO-CODE 0000  
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 ?

---

<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:** [July 10, 2007, 3:31pm UTC](https://techcommunity.softwareag.com/t/close-cmprt01/74989/4 "2007-07-10T15:31:43Z")

</div>

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:

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

---

<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, 2:48pm UTC](https://techcommunity.softwareag.com/t/close-cmprt01/74989/5 "2021-04-02T14:48:31Z")

</div>


