# Eject and Newpage in work file

**URL:** <https://techcommunity.softwareag.com/t/eject-and-newpage-in-work-file/75392>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [September 17, 2007, 11:15am UTC](https://techcommunity.softwareag.com/t/eject-and-newpage-in-work-file/75392 "2007-09-17T11:15:08Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![rishi](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@rishi](https://techcommunity.softwareag.com/u/rishi)\
**Post date:** [September 17, 2007, 11:15am UTC](https://techcommunity.softwareag.com/t/eject-and-newpage-in-work-file/75392/1 "2007-09-17T11:15:08Z")

</div>

Hi,

Im having problems with using NEWPAGE or EJECT stmts within the READ WORKFILE LOOP.I’m reading data from the workfile.When the name of the program( a field in the workfile) changes then I’ll have to create a new page.None of the report formatting statements are working inside the read work file loop.  
Is there any other way of accomplishing this(using WRITE or something)?

#WK-PROG (FIELD IN THE WORK FILE)  
#PROG-TEMP (LOCAL VARIABLE)  
READ WORK FILE 1 RECORD #WORK-FILE-IN

IF #PROG-TEMP NE #WK-PROG  
RESET #UTIL-CNT  
MOVE #WK-PROG TO #PROG-TEMP

EJECT

WRITE #PROG-TEMP

.  
.  
.

END-WORK

---

<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:** [September 17, 2007, 12:21pm UTC](https://techcommunity.softwareag.com/t/eject-and-newpage-in-work-file/75392/2 "2007-09-17T12:21:25Z")

</div>

can you post the complete program as a text file?

You are probably encountering something other than an issue with READ WORK FILE - for example, EJECT only works if something is written to the page already.

Also, take a look at the IF BREAK and AT BREAK statements to see if they will do what you need. See comments elsewhere in the forum on report program standards.

---

<div class="post-metadata">

**Author:** ![rishi](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@rishi](https://techcommunity.softwareag.com/u/rishi)\
**Post date:** [September 17, 2007, 2:12pm UTC](https://techcommunity.softwareag.com/t/eject-and-newpage-in-work-file/75392/3 "2007-09-17T14:12:14Z")

</div>

One thing which I did not mention i that I’m running this program on batch.  
These write statements are printed in the CMPRT01 step of the jcl. In this CMPRT01 step I’ve used a dataset.  
None of the report formatting statements are working for me in the read work file loop.

My jcl is like this

//CMWKF01 DD DSN=&LDINDEX…LDDLY070.OUTPUT.SRT,DISP=SHR  
//CMSYNIN DD DSN=SYS1.&CNTLIB(  
[program.doc](https://techcommunity.softwareag.com/uploads/short-url/5qZWHD0GrOuUpK7Ves9odPhX0PP.doc) (89 KB)

---

<div class="post-metadata">

**Author:** ![Ralph\_Zbrog](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/ralph_zbrog/32/78_2.png) [@Ralph\_Zbrog](https://techcommunity.softwareag.com/u/Ralph_Zbrog)\
**Post date:** [September 17, 2007, 2:47pm UTC](https://techcommunity.softwareag.com/t/eject-and-newpage-in-work-file/75392/4 "2007-09-17T14:47:48Z")

</div>

Your FORMAT and WRITE statements seem OK. Change your EJECT statement to EJECT (1) to match them.

---

<div class="post-metadata">

**Author:** ![rishi](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@rishi](https://techcommunity.softwareag.com/u/rishi)\
**Post date:** [September 17, 2007, 4:12pm UTC](https://techcommunity.softwareag.com/t/eject-and-newpage-in-work-file/75392/5 "2007-09-17T16:12:17Z")

</div>

I’ve changed it. But not getting any new pages in the report.  
As am running this as a batch job , is there anything specific?  
Or is that all empty lines will be suppressed in the dataset?

---

<div class="post-metadata">

**Author:** ![Steve\_Robinson](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/steve_robinson/32/107_2.png) [@Steve\_Robinson](https://techcommunity.softwareag.com/u/Steve_Robinson)\
**Post date:** [September 17, 2007, 6:57pm UTC](https://techcommunity.softwareag.com/t/eject-and-newpage-in-work-file/75392/6 "2007-09-17T18:57:02Z")

</div>

Do you actually have data in your input workfile?

If so, how many records?

Are you getting your Title?

steve

---

<div class="post-metadata">

**Author:** ![rishi](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@rishi](https://techcommunity.softwareag.com/u/rishi)\
**Post date:** [September 19, 2007, 4:18pm UTC](https://techcommunity.softwareag.com/t/eject-and-newpage-in-work-file/75392/7 "2007-09-19T16:18:19Z")

</div>

Apologies for late reply.  
My input work file has close to 500 records.  
I’m getting title for every 55 records(PS parameter is 55 in my program)  
But not getting a new page!

---

<div class="post-metadata">

**Author:** ![Steve\_Robinson](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/steve_robinson/32/107_2.png) [@Steve\_Robinson](https://techcommunity.softwareag.com/u/Steve_Robinson)\
**Post date:** [September 19, 2007, 6:59pm UTC](https://techcommunity.softwareag.com/t/eject-and-newpage-in-work-file/75392/8 "2007-09-19T18:59:13Z")

</div>

When you say you are “not getting a new page”, what do you mean?

EJECT goes to a new physical page, but not a new logical page. There would be no TITLE on such new pages (but the WRITE after the EJECT should be there).

In the code you sent, #PROG-TEMP does not appear. Is it indeed A8? Are the values for the program names correct on the workfile records?

steve

---

<div class="post-metadata">

**Author:** ![rishi](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@rishi](https://techcommunity.softwareag.com/u/rishi)\
**Post date:** [September 20, 2007, 5:47pm UTC](https://techcommunity.softwareag.com/t/eject-and-newpage-in-work-file/75392/9 "2007-09-20T17:47:39Z")

</div>

When I said new page I meant that I’m not getting a new physical page.  
The #prog-temp is an A8 variable

---

<div class="post-metadata">

**Author:** ![Jerome\_LeBlanc](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/jerome_leblanc/32/111_2.png) [@Jerome\_LeBlanc](https://techcommunity.softwareag.com/u/Jerome_LeBlanc)\
**Post date:** [September 20, 2007, 8:10pm UTC](https://techcommunity.softwareag.com/t/eject-and-newpage-in-work-file/75392/10 "2007-09-20T20:10:09Z")

</div>

I have been following this thread, but there is something that is not clear to me. In your post regarding the JCL you mention that CMPRT01 is being written to a dataset. How does that dataset get printed to paper?

---

<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/eject-and-newpage-in-work-file/75392/11 "2021-04-02T14:48:44Z")

</div>


