118

Our Customers Talk About Our Products

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Our Customers Talk About Our Products...

"Everything we hoped it would be. In fact, I can honestly say it exceeded our initialexpectations."

"I can create reports in a few minutes. I don't know what I'd do without it."

“Thanks again for the information. We were able to download the evaluation copy, and I havefound it super easy to use. To me, it is exactly the right tool for us to use.”

"It is easy to use, flexible and has all the features needed to produce virtually any type ofreport."

"The syntax is straightforward, the documentation is good, the support is good."

“Since I only used the product today and saw how easy it was to generate these reports, it wouldsave me a lot of time from writing assembler routines to do this. Hopefully I can get this point acrossto management.”

“I REALLY like your product and I am trying my best to prove how valuable that this productcould be for us at such a low cost. For the couple of times that I have used the product in testing toproduce certain results, I was able to get the information I needed without a large effort and timeon my part. That is what I liked. I didn't have to create a new assembler program to do this work.”

... and Our Customer Service

“Thanks for getting back to me so quickly! ... By the way, you have a terrific product.”

“As I mentioned before, I really appreciate all of your help, and wish that all of the vendors withwhom I work were half as pleasant and helpful as you have been. It has been a pleasure.”

“Thanks but it is all working perfectly. Really pleasantly surprised.”

“Wow!! Excellent turn around time! Thank you!”

“That's perfect! I knew it could be done but I just couldn't find it. Thanks so much for your help.By the way, I love this product. I'm just getting my feet wet with it but I can see a lot of potentialfor our shop.“

Copyright 2011 Pacific Systems Group. All Rights Reserved. The material in this publication is confidential and containsproprietary information and trade secrets. No part of this publication may be reproduced or transmitted in any form or by anymeans, electronic or mechanical, without written permission from Pacific Systems Group.

While every effort has been made to ensure the accuracy of the material in this publication, Pacific Systems Group shall notbe liable for any errors contained herein, or for incidental or consequential damages resulting from the performance,furnishing or use of this manual. If you find technical inaccuracies or typographical errors, we would appreciate hearing aboutthem. Other comments concerning the usefulness of this publication are also welcome.

Z-Writer is a trademark and Pacific Systems Group is a registered trademark of Pacific Systems Group. Other program namesare trademarks of their respective companies.

Printed in the United States of America

Pacific Systems Group, LLCPO Box 790

Lake Oswego OR 97034

1-800-572-5517

www.pacsys.com

Z-Writer Reference Manual

Table of Contents

Chapter 1. Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

What Is Z-Writer? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1DYL-280 Filter Coming Soon! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Sample DYL-280 Program Converted to Z-Writer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2Sample Easytrieve Program Converted to Z-Writer . . . . . . . . . . . . . . . . . . . . . . . . . . . 4Sample Quikjob Program Converted to Z-Writer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5Z-Writer Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Chapter 2. Z-Writer Statement Syntax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

CALL Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8CASE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

WHEN Statement Syntax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Using NOT on WHEN Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

CLOSE Statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12COMPUTE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

Syntax of Computational Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13Operands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14Order of Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

COPY Statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16DELREC Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18DOUNTIL Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20DOWHILE Statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22ELSE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24ELSEIF Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26ENDCASE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27ENDDO Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28ENDIF Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29ENDREDEFINE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30FILE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31FLD Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35GOTO Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42IF Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

Syntax of a Simple Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45Comparing an Operand to a Range of Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46Comparing an Operand to a List of Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46Combining Ranges and Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

LISTOFF STATEMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48LISTON STATEMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49MOVE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50NEWREPORT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52ONERROR Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53OPEN Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

Z-Writer Reference Manual

OPTION Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58PERFORM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60POSITION Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62PRINT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64READ Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69REDEFINE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72RELEASE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74RETRIEVE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76REUSE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78REWRITE Statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79SHOW Statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81SHOWHEX Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82SORT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83STOP Statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85STORE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86TABLE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88TITLE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

How Titles Are Printed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .90TRACEOFF STATEMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93TRACEON STATEMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94WHEN Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95WORKAREA Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96WRITE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97

Appendix A. Built-In Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99

Appendix B. Built-In Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100

Functions that Return a Character Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101Functions that Return a Numeric Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

Appendix C. Syntax of PICTURE Display Formats . . . . . . . . . . . . . . . . . . . . . . . . 107

Examples of PICTUREs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107How PICTUREs Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109Scaling Numbers with PICTUREs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112

Z-Writer Reference Manual 1

Chapter 1. Introduction

What Is Z-Writer?

Z-Writer is a powerful quick code tool for z/OS mainframes:

� Perfect for those quick-and-dirty one-time queries and analyses.

� Ideal for easily developing attractive new production reports.

� Great for manipulating files for scheduled production runs or one-time updates andconversions.

Your programmers will be up and running with Z-Writer in no time at all. Z-Writer also accepts existingCOBOL or Assembler record layouts so you can get started using it right away.

Z-Writer uses what is often referred to as a “simplified COBOL” syntax. It is much more compact andflexible than actual COBOL. In this regard, its syntax is also very similar to that of a number of olderprogramming tools. And that fact makes it an ideal choice to replace any of the following products:

� DYL-280 (now CA’s VISION:Results)

� Easytrieve (Now CA’s product)

� Quikjob (now CA’s VISION:Reports)

� Earl (now CA-Earl)

� SAS mainframe (still from the SAS Institute, and still outrageously expensive)

Coming soon: the syntaxes of the competing products is so similar that in many cases thecode can be translated line-by-line to an equivalent Z-Writer line. For some products we planto develop a front-end filter to automate that conversion. When an add-on filter becomesavailable for your current product, you will be able to run most of your programs without anychange at all. Be sure to check with us to see if the filter you need is available.

Z-Writer is written entirely in fast, efficient Assembler language to be easy on your CPU.

2 Z-Writer Reference Manual

Sample DYL-280 Program Converted to Z-Writer

Below is a sample DYL-280 program, converted line by line to Z-Writer. As you can see, some linesare identical. And most others require only minor syntax changes.

DYL-280 Z-WRITER

OPTION STRUCTUREDFILE CLIENTP STATUS R3EOF KSDS F 200 PARTNUM3 35 (PART SEQ3 4 (SEQ) SWAP 1 (SWAP) BLDG3 14 BIN3 12 PARTNUMB3 35 SEQB3 4 FILLER 8 EMPNUM3 8 (EMPLNUM) REDEFINE AT EMPNUM3 EMPDEPT 5 EMPHNUM 3;WORKAREA FIRSTLOOP 1 VALUE 'Y' TESTDEPT 5 VALUE 'DEV02' EMPNUM 8 PARTOUT 81 BLDG 3 REDEFINE AT BLDG PREFIX 1 SUFFIX 2 BIN 5 TYPF 8 REDEFINE AT PARTOUT SEQA 4 FILLER1 1 PARTNUMA 20 FILLER2 1 SEQB 4 FILLER3 1 PARTNUMB 20;SORT CLIENTP USING EMPNUM3

DOUNTIL EMPDEPT EQ TESTPARTREAD CLIENTPENDDO

DOWHILE R3EOF EQ ‘Y’IF FIRSTLOOP EQ 'Y' LIST 'PART NUM CHANGES FOR DEPT ' AT 1 TESTDEPT AT 28 LIST ' ' AT 1 LIST 'EMP' AT 1 'SEQA' AT 11 'PARTNUMA' AT 17 'SEQB' AT 39 'PARTNUMB' AT 45 'BLDG' AT 67 'BIN' AT 72 MOVE 'N' TO FIRSTLOOPENDIF

FILE CLIENTP TYPE(KSDS) F RECAREA(200)FLD PARTNUM3 35 HDG(‘PART’)FLD SEQ3 4 HDG(‘SEQ’)FLD SWAP 1 HDG(‘SWAP’)FLD BLDG3 14FLD BIN3 12FLD PARTNUMB3 35FLD SEQB3 4FLD FILLER 8FLD EMPNUM3 8 HDG(‘EMPLNUM’)FLD REDEFINE EMPNUM3FLD EMPDEPT 5FLD EMPHNUM 3*WORKAREAFLD FIRSTLOOP 1 INIT('Y')FLD TESTDEPT 5 INIT('DEV02')FLD EMPNUM 8FLD PARTOUT 81FLD BLDG 3REDEFINE BLDGFLD PREFIX 1FLD SUFFIX 2FLD BIN 5FLD TYPF 8REDEFINE PARTOUTFLD SEQA 4FLD FILLER1 1FLD PARTNUMA 20FLD FILLER2 1FLD SEQB 4FLD FILLER3 1FLD PARTNUMB 20*SORT CLIENTP USING EMPNUM3

DOUNTIL EMPDEPT EQ TESTPARTREAD CLIENTPENDDO

DOWHILE #STATUS EQ ‘Y’IF FIRSTLOOP EQ 'Y' PRINT 'PART NUM CHANGES FOR DEPT ' TESTDEPT(@28) PRINT ' ' LIST 'EMP' 'SEQA'(@11) 'PARTNUMA'(@17) 'SEQB'(@39) 'PARTNUMB'(@45) 'BLDG'(@67) 'BIN'(@72) MOVE 'N' TO FIRSTLOOPENDIF

Z-Writer Reference Manual 3

IF EMPDEPT EQ TESTDEPT MOVE SPACES TO PARTOUT IF EMPNUM3 NE EMPNUM MOVE EMPNUM3 TO EMPNUM ENDIF IF SWAP EQ 'Y' MOVE PARTNUM3 TO PARTNUMB MOVE SEQ3 TO SEQB MOVE SEQB3 TO SEQA MOVE PARTNUMB3 TO PARTNUMA ELSE MOVE PARTNUM3 TO PARTNUMA MOVE SEQ3 TO SEQA MOVE SEQB3 TO SEQB MOVE PARTNUMB3 TO PARTNUMB ENDIF IF BLDG3 EQ '999' MOVE 'ALL' TO BLDG ELSE MOVE BLDG3 TO BLDG ENDIFIF BIN3 EQ '99999' MOVE 'ALL' TO BIN ELSE MOVE BIN3 TO BIN ENDIF IF SUFFIX EQ '88' MOVE '**' TO SUFFIXENDIFLIST EMPNUM AT 1 SEQA AT 11 PARTNUMA AT 17 SEQB AT 39 PARTNUMB AT 45 BLDG AT 67 BIN AT 72ENDIF

READ CLIENTPENDDO

IF EMPDEPT EQ TESTDEPT MOVE ‘ ‘ TO PARTOUT IF EMPNUM3 NE EMPNUM MOVE EMPNUM3 TO EMPNUM ENDIF IF SWAP EQ 'Y' MOVE PARTNUM3 TO PARTNUMB MOVE SEQ3 TO SEQB MOVE SEQB3 TO SEQA MOVE PARTNUMB3 TO PARTNUMA ELSE MOVE PARTNUM3 TO PARTNUMA MOVE SEQ3 TO SEQA MOVE SEQB3 TO SEQB MOVE PARTNUMB3 TO PARTNUMB ENDIF IF BLDG3 EQ '999' MOVE 'ALL' TO BLDG ELSE MOVE BLDG3 TO BLDG ENDIFIF BIN3 EQ '99999' MOVE 'ALL' TO BIN ELSE MOVE BIN3 TO BIN ENDIF IF SUFFIX EQ '88' MOVE '**' TO SUFFIXENDIFPRINT EMPNUM SEQA(@11) PARTNUMA(@17) SEQB(@39) PARTNUMB(@45) BLDG(@67) BIN(@72)ENDIF

READ CLIENTPENDDO

DYL-280 (CONTINUED) Z-WRITER (CONTINUED)

4 Z-Writer Reference Manual

Sample Easytrieve Program Converted to Z-Writer

Below is a sample Easytrieve program, converted line by line to Z-Writer. As you can see, some linesare identical. And most others require only minor syntax changes.

EASYTRIEVE Z-WRITER

************************************************ EASYTRIEVE SAMPLE PROGRAM ** ** THIS PROGRAM DOES THE FOLLOWING: ** ** A) READS A FILE WITH DATES IN YYYYMMDD FMT ** B) CONVERT THE DATE TO YYYYMON FORMAT ** C) WRITE OUT THE NEW FILE ************************************************FILE INFILEIN-DATE 01 08 AIN-DATE-YEAR 01 04 AIN-DATE-MONTH 05 02 AIN-DATE-DAY 07 02 A

FILE OUTFILEOUT-DATE 01 09 AOUT-DATE-YEAR 01 04 AOUT-DATE-MONTH 05 03 AOUT-DATE-DAY 08 02 A

*---------------------------------------------JOB INPUT INFILE

*---------------------------------------------CASE IN-DATE-MONTHWHEN '01' OUT-DATE-MONTH = 'JAN'WHEN '02' OUT-DATE-MONTH = 'FEB'WHEN '03' OUT-DATE-MONTH = 'MAR'WHEN '04' OUT-DATE-MONTH = 'APR'WHEN '05' OUT-DATE-MONTH = 'MAY'WHEN '06' OUT-DATE-MONTH = 'JUN'WHEN '07' OUT-DATE-MONTH = 'JUL'WHEN '08' OUT-DATE-MONTH = 'AUG'WHEN '09' OUT-DATE-MONTH = 'SEP'WHEN '10' OUT-DATE-MONTH = 'OCT'WHEN '11' OUT-DATE-MONTH = 'NOV'WHEN '12' OUT-DATE-MONTH = 'DEC'END-CASE

OUT-DATE-YEAR = IN-DATE-YEAROUT-DATE-DAY = IN-DATE-DAY

PUT OUTFILE

************************************************ Z-WRITER SAMPLE PROGRAM ** ** THIS PROGRAM DOES THE FOLLOWING: ** ** A) READS A FILE WITH DATES IN YYYYMMDD FMT ** B) CONVERT THE DATE TO YYYYMON FORMAT ** C) WRITE OUT THE NEW FILE ************************************************FILE INFILEFLD IN-DATE 8FLD IN-DATE-YEAR 4 COL(1)FLD IN-DATE-MONTH 2FLD IN-DATE-DAY 2

FILE OUTFILE OUTPUTFLD OUT-DATE 9FLD OUT-DATE-YEAR 4 COL(1)FLD OUT-DATE-MONTH 3FLD OUT-DATE-DAY 2

*---------------------------------------------READ INFILEDOWHILE #STATUS=’Y’*---------------------------------------------CASE IN-DATE-MONTHWHEN '01' OUT-DATE-MONTH = 'JAN'WHEN '02' OUT-DATE-MONTH = 'FEB'WHEN '03' OUT-DATE-MONTH = 'MAR'WHEN '04' OUT-DATE-MONTH = 'APR'WHEN '05' OUT-DATE-MONTH = 'MAY'WHEN '06' OUT-DATE-MONTH = 'JUN'WHEN '07' OUT-DATE-MONTH = 'JUL'WHEN '08' OUT-DATE-MONTH = 'AUG'WHEN '09' OUT-DATE-MONTH = 'SEP'WHEN '10' OUT-DATE-MONTH = 'OCT'WHEN '11' OUT-DATE-MONTH = 'NOV'WHEN '12' OUT-DATE-MONTH = 'DEC'END-CASE

OUT-DATE-YEAR = IN-DATE-YEAROUT-DATE-DAY = IN-DATE-DAY

WRITE OUTFILEREAD INFILEENDDO

Z-Writer Reference Manual 5

Sample Quikjob Program Converted to Z-Writer

Below is a sample Quikjob program, converted line by line to Z-Writer. As you can see, some lines areidentical. And most others require only minor syntax changes..

QUIKJOB Z-WRITER

OPTION NOSEQ,MBUFFER=NOINFKSDS 1100 ********************************************* * FILE LAYOUT FOR INPUT VSAM AUX FILE * *********************************************EQU AUX-TRLR INF20-21EQU PRODUCT INF04-13EQU SALES-DATE INF44-49EQU SALES-MM INF44-45EQU SAL-DAY INF46-47EQU SALES-YY INF48-49EQU CUSTNAME INF50-79EQU ADDRESS INF134-163EQU CITY INF164-178EQU STATE INF179-180EQU ZIP INF181-185EQU LOCATION INF191-194EQU PHONE INF237-246EQU BRANCH INF186-189

******************************************** * THE TITLE OF THE REPORT * ********************************************TITLE1 'SALES IN BRANCH 4126 IN JAN 2010'TITLE2 'ABC MANUFACTURING COMPANY'

******************************************** * NAMES OF THE FLDS REQUIRED FOR THE REPORT* *AND OVERRIDE COLUMN HEADINGS * ********************************************REPORT PRODUCT (PRODUCT CODE) LOCATION CUSTNAME (CUSTOMER NAME) ADDRESS (STREET ADDRESS) CITY STATE ZIP PHONE

******************************************** * LOOP THRU READING FILE * ********************************************100 GET INF ATEND 900

IF INF02-13 IS LOVALUES GOTO 100. IF AUX-TRLR IS EQUAL C'01' PERFORM 200 THRU 299.

GOTO 100

FILE INF TYPE(KSDS) RECAREA(1100) ********************************************* * FILE LAYOUT FOR INPUT VSAM AUX FILE * *********************************************FLD AUX-TRLR 2 COL(20)FLD PRODUCT 10 COL(4)FLD SALES-DATE 6 COL(44)FLD SALES-MM 2 COL(44)FLD SAL-DAY 2FLD SALES-YY 2FLD CUSTNAME 3FLD ADDRESS 30 COL(134)FLD CITY 15FLD STATE 2FLD ZIP 5FLD LOCATION 4 COL(191)FLD PHONE 10 COL(237)FLD BRANCH 4 COL(186*)FLD INF02-13 12 COL(2)

******************************************** * THE TITLE OF THE REPORT * ********************************************TITLE 'SALES AT BRANCH 4126 IN JAN 2010'(@50)TITLE 'ABC MANUFACTURING COMPANY'(@53)

******************************************** * LOOP THRU READING FILE * ********************************************L100: READ INF IF #STATUS = ‘N’ GOTO L900 ENDIF

IF INF02-13 = LOWVALUES GOTO L100 ENDIF IF AUX-TRLR = '01' PERFORM L200 THRU L299 ENDIF

GOTO L100

6 Z-Writer Reference Manual

******************************************** * PRINT REPORT IF TRAILER MEETS CRITERIA * ********************************************200 IF ISSUE-DATE IS EQUAL C'000000' OR IF ISSUE-DATE IS EQUAL BLANKS GOTO 299.

IF ISSUE-MM IS EQUAL C'01' AND IF ISSUE-YY IS EQUAL C'10' AND IF BRANCH IS EQUAL C'4126' PRINT REPORT.

299 EXIT

900 GOTO EOJ999 END

******************************************** * PRINT REPORT IF TRAILER MEETS CRITERIA * ********************************************L200: IF ISSUE-DATE = '000000' OR ISSUE-DATE = SPACES GOTO L299 ENDIF

IF ISSUE-MM = '01' AND ISSUE-YY = '10' AND BRANCH = '4126' PERFORM PRINT-REPORT ENDIF

L299:

PRINT-REPORT: ******************************************** * NAMES OF THE FLDS REQUIRED FOR THE REPORT* *AND OVERRIDE COLUMN HEADINGS * ******************************************** PRINT PRODUCT(‘PRODUCT CODE’) LOCATION CUSTNAME(‘CUSTOMER NAME’) ADDRESS(‘STREET ADDRESS’) CITY STATE ZIP PHONE

L900:L999:

QUIKJOB (CONTINUED) Z-WRITER (CONTINUED)

Z-Writer Reference Manual 7

Sample SAS Program Converted to Z-Writer

Below is a sample SAS program, converted line by line to Z-Writer..

Z-Writer Features

Some of Z-Writer's major features include:

� control statements use an easy, free format, COBOL–like syntax that's easily learned by non–technical users

� user–friendly field names can be up to 70 characters long (unlike some report writers thatrestrict you to cryptic 8–byte names). This also allows full compatibility with existing COBOL,PL/1 and Assembler data names.

� you can easily work with any number of flat files and VSAM files (DB2 tables are coming next)

� use your existing COBOL or Assembler record layouts instead of creating a data dictionary.Or, use Z-Writer's simple data dictionary for added functionality.

� produces efficient internal machine code that is easy on your CPU

� can produce multiple reports (or output files) in a single execution

� can easily produce comma delimited files for use on PCs

� report lines are not limited to only 132 characters. Z-Writer can format a report as wide asyour laser printer supports.

SAS Z-WRITER

FILENAME RAWIN 'WTAP01A.MYRAW.DATA' MVS LRECL=80;

DATA SASDATA INFILE RAWIN; INPUT IDNUM 1-4 AGE 7-9 STATE $ 17-18 SEX 55-55;

IF SEX = 1 IF AGE < 18 THEN AGEGRP=1; ELSE IF AGE <= 65 THEN AGEGRP=2; ELSE IF AGE > 65 THEN AGRGRP=3;

PROC PRINT DATA=SASDATA;TITLE 'AGE GROUP OF MALES';

RUN;

FILE RAWIN LRECL(80)

FLD IDNUM N4FLD AGE N2 COL(7)FLD STATE 2 COL(17)FLD SEX N1 COL(55)WORKAREAFLD AGEGRP N4*

READ RAWINDOWHILE #STATUS = 'Y'

IF SEX = 1 IF AGE < 18 AGEGRP=1 ELSEIF AGE <= 65 AGEGRP=2 ELSEIF AGE > 65 AGEGRP=3 ENDIF

PRINT IDNUM AGE STATE SEX AGRGRP ENDIF

READ RAWINENDDO

TITLE 'AGE GROUP OF MALES'

8 Z-Writer Reference Manual

� ability to print full–page forms

� full control of carriage control when printing reports

� allows complete control over formatting of numeric fields, including handling of specialcases like telephone numbers, social security numbers, etc.

� has special formatting options for international users

� allows complete control over report titles, column headings

� includes thorough, clear documentation

� includes an option to validity–check numeric data before processing it, to prevent S0C7

abends

� ability to display file data in hexadecimal format, for analyzing invalid data

� full program trace facility, to help when developing new program

� translates fields from EBCDIC to ASCII and vice verse

� supports full "boolean logic" (the use of AND, OR and NOT) in conditional expressions

� ability to scan free format fields, to see if a certain text appears anywhere within the field

� comparisons and computations are allowed among all numeric fields, (even if some arepacked, some are binary, and others are zoned, etc.)

� supports all types of mainframe data widely in use, including packed, BCD, signed andunsigned binary and hexadecimal floating point

� full mathematical calculations are supported when creating new fields, including the use ofmany built–in functions

� supports a full range of functions to manipulate string data, including powerful parsingfeatures

� "compress" formatting features lets you, for example, compress separate city, state and ZIP

fields into a normal formatted line format

� handles complicated record layouts, including variably–located fields, fields located bypointer or pointer expressions, etc.

� supports records that contain arrays with varying number of entries

� allows an unlimited number of input files for a single report or PC file

� allows an unlimited number of print lines per input record

� built–in fields provide the system date, time, jobname, etc.

� can halt input processing when a user-defined condition is met, to eliminate unnecessary I/O

� prints end of job statistics, such as how many records read from each input file, and how manyrecords included in report

Z-Writer Reference Manual 9

Chapter 2. Z-Writer Statement Syntax

This chapter explains the syntax and usage details for each of Z-Writer’s control statements.

CALL Statement

PURPOSE

Calls an external program. Optionally, you may pass one or more parms to the called program.

SYNTAX

DISCUSSION

Z-Writer uses the standard Assembler language linkage conventions when calling the program.Specifically, the following registers will have special settings:

� R1 holds the address of a standard parm list (if parms were specified on the CALL statement.)

� R13 holds the address of an 18 fullword save area that the called program should use topreserve Z-Writer’s registers.

� R14 holds the return address within Z-Writer.

� R15 holds the entry point address of the called program.

CALL STATEMENT SYNTAX

CALL program [ USING fieldname/’literal’ [, fieldname/’literal’] ...) ]

10 Z-Writer Reference Manual

PARMS

programSpecifies the name of the program to call. This parm must be the 1-8 byte name of a load module presentin a program library accessible to the jobstep.

Note: you may need to add the library containing the called program to your JOBLIB orSTEPLIB DD in order for the program to be found.

fieldname / ‘literal’Specifies one parm to be passed to the called program. You may name a field, whose contents shouldbe passed to the program. Or you can specify a literal text, within quotes or apostrophes.

Note: when a field is used as a parm to the program, Z-Writer passes the address of the field’sdata in the actual record area or workarea. The called program is allowed to modify the datathere, but it should be careful not to accidentally modify memory before or after that area.

EXAMPLE

CALL DECRYPT USING ENCRYPT-SEGMENT ‘TYPE1’

Z-Writer Reference Manual 11

CASE Statement

PURPOSE

The CASE statement begins a “case-structure”. The purpose of a case-structure is to conditionallyexecute (at most) one set of statements within the structure.

SYNTAX

DISCUSSION

A case-structure functions just like a set of nested IF’s (or a single IF with a number of ELSEIF’s). Ifyou are simply comparing one field to various values, you can use a case-structure instead of an if-structure. The advantage of the case-structure is that it is less verbose, and may be easier to read, modifyand maintain.

Here is a description of the case-structure syntax.

The CASE statement itself must contain exactly one fieldname, of any type. This is the “test field.”Immediately after the CASE statement, a WHEN statement must follow.

A WHEN statement contains one or more values which the test field (from the CASE statement) willbe compared to. If the test field equals any value on the WHEN statement, then that WHEN statementis true and all of the “other statements” immediately following the WHEN statement will be executed.After those statements are executed, control is passed to the statement immediately following theENDCASE statement. (You are allowed to have zero “other statements,” in which case control isimmediately passed to the first statement after the ENDCASE statement.)

CASE STRUCTURE SYNTAX

CASE fieldname

WHEN [NOT] value/range [value/range ...]other statements

WHEN [NOT] value/range [value/range ...]other statements...

ELSEother statements

ENDCASE

12 Z-Writer Reference Manual

If the CASE test field is not equal to any value on the WHEN statement, then the next WHEN statement(if any) is evaluated. This process continues until a “true” WHEN statement is found, or until there areno more WHEN statements.

If none of the WHEN statements are true, then one of the following occurs:

� if there is a final ELSE statement within the case-structure, the statements following it areexecuted.

� otherwise, control just passes to the statement after the ENDCASE statement, with none ofthe “other statements” being executed

The last thing in a case-structure is always the required ENDCASE statement.

WHEN Statement SyntaxA WHEN statement can contain:

� a single value (either a fieldname or a literal)

� a range of values (specified using the keyword THRU), or

� a list of values and/or ranges

Note: when specifying a list of values, you may separate them with spaces or commas

Using NOT on WHEN StatementsYou may also begin a WHEN statement with the keyword “NOT” (followed with one or more valuesand/or ranges):

WHEN NOT 2, 4, 6, 100 THRU 9999999999

When NOT is specified, the WHEN statement is passed if the test field does not equal any value on thestatement, and does not fall within any range (inclusive) on the statement.

EXAMPLE

CASE AMOUNT WHEN TEST-AMOUNT PRINT ‘EQUALS TEST AMOUNT’ WHEN 400 PRINT ‘EQUALS 400’ WHEN 500 THRU 599 PRINT ‘BETWEEN 500 AND 599 (INCLUSIVE)’ WHEN 2, 4, 6 PRINT ‘EQUALS 2, 4 OR 6’ WHEN 1, 3, 5, 700-799, 1000-1099, 9999 PRINT ‘1, 3, 5, SEVEN HUNDRED SOMETHING, ONE THOUSAND SOMETHING OR 9999’ ELSE PRINT ‘DID NOT EQUAL ANY OF THE ABOVE’ENDCASE

Z-Writer Reference Manual 13

CLOSE Statement

PURPOSE

Closes one file (if it is open.)

SYNTAX

DISCUSSION

You do not normally need to code an explicit CLOSE statement. Z-Writer closes all files for you at theend of your program. (Or at the end of each report’s execution, when the program consists of multiplereports.)

However, this statement (along with the OPEN statement) is useful if you wish to read through a filemore than one time within the same report program.

PARMS

filenameSpecifies the name of the file to close. The file must have been previously defined using a FILEstatement. This parm is required.

EXAMPLE

CLOSE EMPL

CLOSE STATEMENT SYNTAX

CLOSE filename

14 Z-Writer Reference Manual

COMPUTE Statement

PURPOSE

Use this statement to compute a value and move it to a field.

SYNTAX

Note: the statement name (“COMPUTE”) is optional. You may omit it if you prefer. Both ofthe following statements are valid and do the same thing:

COMPUTE TOTAL = AMOUNT + TAXTOTAL = AMOUNT + TAX

DISCUSION

The MOVE statement can be used to simply assign the contents of one field to another field (even whenthe field’s are stored in different formats.) The COMPUTE statement lets you perform calculations onone or more fields and literals to obtain a new value, which is then placed in the target field.

In addition to math operations, Z-Writer has many powerful built-in functions to help calculate yourvalue. These easy-to-use functions can save you a lot of procedural code when performing complextasks, such as:

� computing math functions (such as square roots, modulus, rounding, truncating and more)

� parsing words from text strings

� searching for or replacing text strings

Appendix B, "Built-In Functions" on page 101 contains a complete list of built-in functions.

Syntax of Computational ExpressionsComputational expressions are used to specify a value. A computational expression might be nothingmore than a single field name (or literal value). Or, it might be dozens of lines long and involve manymathematical operations and built-in functions.

COMPUTE STATEMENT SYNTAX

[ COMPUTE ] fieldname = computational-expression

Z-Writer Reference Manual 15

Only the first operand is required. You may specify as many additional operator/operand pairs as youlike. Computational expressions return either a character or numeric value. The expression result mustbe compatible with the target field to which it is being assigned.

OperandsAn operand in a computational expression specifies a data value. An operand can be any of thefollowing:

� a literal value

� a field from a file record area or a workarea

� a built–in field (such as #TIME)

� a built–in function (see Appendix B, "Built-In Functions" on page 101 for a complete list)

OperatorsAn operator in a computational expression specifies an operation to perform on the operandssurrounding. The following table shows the operators that are supported, and the symbol to use for each

Note: be sure to use one or more blanks both before and after the subtraction operator (–) incomputational expressions. This is required because the same symbol is valid as a characterwithin field names. The following:

ABC–XYZ

would be considered the name of a single field, named ABC–XYZ. However, the following:

ABC – XYZ

COMPUTATIONAL EXPRESSION SYNTAX

operand [ operator operand ] [ operator operand ] ...

Parentheses can also be used, indicate the priority of operations. Nesting is allowed to any level.

OPERATORS ALLOWED IN COMPUTATIONAL EXPRESSIONS

CHARACTER OPERATORS NUMERIC OPERATORS

+ (concatenation)

+ (addition)

– (subtraction)

* (multiplication)

/ (division)

** (raise to an integer power)

16 Z-Writer Reference Manual

would be considered a subtraction operation, where field XYZ is subtracted from field ABC. Forall other operators, blanks are not required around the symbol, but are allowed.

Order of OperationsOperations within parentheses are performed first. If nested parentheses are encountered, the mostdeeply nested operations are performed first. Within the same level of nesting, the order of operationsis as follows:

� powers are performed first

� multiplications and divisions are performed next

� additions and subtractions are performed last

Operations of equal priority are performed left to right.

EXAMPLES

COMPUTE PERCENT-TAX = (TAX * 100) / (AMOUNT + TAX)COMPUTE A=A+1COMPUTE DOLLARS = #INT(AMOUNT) /* RETURN INTEGER PORTION */COMPUTE ROUNDED-AMOUNT = #ROUND(AMOUNT,0) /* ROUND TO 0 DECIMALS */COMPUTE FIRST-INITIAL = #SUBSTR(FIRST-NAME,1,1)COMPUTE WHOLE-NAME = LAST-NAME + ‘, ‘ + FIRST-NAMECOMPUTE FORMATTED-NAME = #COMPRESS(FIRST-NAME, LAST-NAME)COMPUTE NEW-DESC = #REPLACE(DESC,’THIS’,’THAT’)

Z-Writer Reference Manual 17

COPY Statement

PURPOSE

Causes control statements from another source to be processed. Use this statement, for example, to copyfile definitions or common processing routines from a copy library.

SYNTAX

DISCUSSION

In addition to copying other Z-Writer statements, if you are in the field definition portion of a program,you may also copy COBOL or Assembler field definitions. Z-Writer internally converts them to Z-Writer field definitions.

PARMS

memberSpecifies library member to copy. This parm must be the 1-8 byte name of a member present in the PDSidentified by the SYSCOPY DD statement in the execution JCL.

COBOL / ASMSpecifies that the member to be copied contains field definitions written in COBOL (or Assembler).These parms are only allowed on COPY statements that follow a FILE statement (and optionally oneor more FLD statements.)

Note: when copying COBOL members, if the first field definition is at the 01 level, then theCOBOL copybook defines fields starting at the beginning of the whole file record area (evenif earlier FLD statements were also processed). If the COBOL member begins at a higherlevel (05, 10, etc.) then the field is defined at the current location within the file record area.That may be the beginning of the record area or, if there were preceding FLD statements, afterthe last field defined.

COPY STATEMENT SYNTAX

COPY member [COBOL/ASM]

18 Z-Writer Reference Manual

EXAMPLES

COPY EMPLDEFSCOPY ACCT120C COBOLCOPY SALEREC ASM

Z-Writer Reference Manual 19

DELREC Statement

PURPOSE

Deletes the current record from a file that has been read for “update” processing.

SYNTAX

DISCUSSION

When you specify UPDATE on a FILE statement, records that you read from that file are available for“update processing.” Each time a record is read, VSAM puts a lock on the record until you take one ofthe following actions:

� you update that record by executing a REWRITE statement to the same file (normally afterchanging the contents and/or length of the record)

� you delete that record by executing a DELREC statement to the same file

� you explicitly release the record by executing a RELEASE statement

� you read a new record from the same file (which releases the hold on the current record)

PARMS

filenameSpecifies the name of the file whose outstanding record should be deleted. The file must have beenpreviously defined as an UPDATE file (with a FILE statement). Also a record must have beensuccessfully read from that file, and not yet rewritten or released. This parm is required.

EXAMPLE

FILE EMPL UPDATE TYPE(KSDS)...

DELREC STATEMENT SYNTAX

DELREC filename

20 Z-Writer Reference Manual

READ EMPL /* READ FIRST RECORD FOR UPDATE */

DOWHILE EMPL.#STATUS = ‘Y’ IF EMPL.EMPL-NUM = ‘444’ DELREC EMPL /* DELETE RECORD FROM FILE */ ELSEIF EMPL.EMPL-NUM = ‘555’ MOVE ‘X’ TO EMPL.TEMPFLAG REWRITE EMPL /* UPDATE STATUS FIELD ON THIS RECORD */ ELSE RELEASE EMPL /* LEAVE RECORD UNCHANGED ON FILE. */ ENDIF

READ EMPL /* READ NEXT RECORD FOR UPDATE */ENDDO

Z-Writer Reference Manual 21

DOUNTIL Statement

PURPOSE

The DOUNTIL statement begins an “iterative-structure.” The purpose of an iterative-structure is toexecute a set of “other statements” some variable number of times, depending on a logical condition.Unlike the similar DOWHILE statement, the “other statements” after a DOUNTIL statement are alwaysexecuted at least one time.

SYNTAX

DISCUSSION

The DOUNTIL structure begins with a DOUNTIL statement and ends with an ENDDO statement.Within the structure any number of other statements (including zero) are allowed. Those statementsmay include additional DOUNTIL structures. Such nesting is permitted to any level.

Here is a description of how the DOUNTIL structure is processed.

When control reaches the DOUNTIL statement, the DOUNTIL statement itself does nothing and the“other statements” after it are then executed. When the corresponding ENDDO statement isencountered, the conditional expression from the DOUNTIL statement is evaluated. If the condition istrue, the structure’s iterations are complete and control passes to the first statement after the ENDDOstatement. If the expression is false, another iteration is performed; control passes back up to theDOUNTIL statement and the statements following it are again executed.

This process continues until the conditional expression from the DOUNTIL statement is found to betrue.

DOUNTIL STRUCTURE SYNTAX

DOUNTIL conditional-expressionother statementsENDDO

22 Z-Writer Reference Manual

EXAMPLE

READ SALESDOUNTIL SALES.#STATUS <> ‘Y’ TOTAL-SALES = TOTAL-SALES + AMOUNT READ SALESENDDO

Z-Writer Reference Manual 23

DOWHILE Statement

PURPOSE

The DOWHILE statement begins an “iterative-structure.” The purpose of an iterative-structure is toexecute a set of “other statements” some variable number of times, depending on a logical condition.Unlike the similar DOUNTIL statement, it is possible for the “other statements” after a DOWHILEstatement not to be executed at all.

SYNTAX

DISCUSSION

The DOWHILE structure begins with a DOWHILE statement and ends with an ENDDO statement.Within the structure any number of other statements (including zero) are allowed. Those statementsmay include additional DOWHILE structures. Such nesting is permitted to any level.

Here is a description of how the DOWHILE structure is processed.

Whenever control reaches the DOWHILE statement, its conditional expression is evaluated.

If the expression is false, the structure’s iterations are complete; control passes to the first statementafter the corresponding ENDDO statement.

If the DOWHILE statement’s condition is true, the “other statements” after it are executed. When theENDDO statement is reached, control is passed back up to the DOWHILE statement (where theconditional expression is reevaluated.) This process continues until the conditional expression from theDOWHILE statement is found to be false.

DOWHILE STRUCTURE SYNTAX

DOWHILE conditional-expressionother statementsENDDO

24 Z-Writer Reference Manual

EXAMPLE

READ SALESDOWHILE SALES.#STATUS = ‘Y’ TOTAL-SALES = TOTAL-SALES + AMOUNT READ SALESENDDO

Z-Writer Reference Manual 25

ELSE Statement

PURPOSE

The ELSE statement is used within “if-structures” and “case-structures.” The purpose of both structuresis to conditionally execute (at most) one set of statements within the structure. The ELSE statementintroduces the final, default set of instructions to be executed when none of the structure’s earlierclauses are true.

SYNTAX

IF STRUCTURE SYNTAX

IF conditional-expressionother statements

[ ELSEIF conditional-expression other statements ] ...

[ ELSE other statements ]

ENDIF

CASE STRUCTURE SYNTAX

CASE fieldname

WHEN [NOT] value/range [value/range ...]other statements

WHEN [NOT] value/range [value/range ...]other statements...

ELSEother statements

ENDCASE

26 Z-Writer Reference Manual

DISCUSSION

A complete discussion of an “if-structure” can be found under the IF statement on page 45. A completediscussion of a “case-structure” can be found under the CASE statement on page 11.

Z-Writer Reference Manual 27

ELSEIF Statement

PURPOSE

The ELSEIF statement is used within an “if-structure”. The purpose of an if-structure is to conditionallyexecute (at most) one set of statements within the structure. The ELSEIF statement introduces a newset of instructions and the condition under which they should be executed, when none of the if-structure’s earlier clauses are true.

SYNTAX

DISCUSSION

A complete discussion of an “if-structure” can be found under the IF statement on page 45.

IF STRUCTURE SYNTAX

IF conditional-expressionother statements

[ ELSEIF conditional-expression other statements ] ...

[ ELSE other statements ]

ENDIF

28 Z-Writer Reference Manual

ENDCASE Statement

PURPOSE

The ENDCASE statement ends a “case-structure”. The purpose of an case-structure is to conditionallyexecute (at most) one set of statements within the structure.

SYNTAX

DISCUSSION

A complete discussion of the “case-structure” can be found under the CASE statement.

CASE STRUCTURE SYNTAX

CASE fieldname

WHEN [NOT] value/range [value/range ...]other statements

WHEN [NOT] value/range [value/range ...]other statements...

ELSEother statements

ENDCASE

Z-Writer Reference Manual 29

ENDDO Statement

PURPOSE

The ENDDO statement ends an iterative-structure. The purpose of an iterative-structure is toconditionally execute a set of statements a variable number of times, depending on a logical condition.

SYNTAX

DISCUSSION

A complete discussion of a iterative-structures can be found under the DOUNTIL and DOWHILEstatement entries.

DOUNTIL STRUCTURE SYNTAX

DOUNTIL conditional-expressionother statementsENDDO

DOWHILE STRUCTURE SYNTAX

DOWHILE conditional-expressionother statementsENDDO

30 Z-Writer Reference Manual

ENDIF Statement

PURPOSE

The ENDIF statement ends an “if-structure”. The purpose of an if-structure is to conditionally execute(at most) one set of statements within the structure.

SYNTAX

DISCUSSION

A complete discussion of an “if-structure” can be found under the IF statement on page 45.

IF STRUCTURE SYNTAX

IF conditional-expressionother statements

[ ELSEIF conditional-expression other statements ] ...

[ ELSE other statements ]

ENDIF

Z-Writer Reference Manual 31

ENDREDEFINE Statement

PURPOSE

Allowed only within record descriptions, this statement cancels the redefine in progress.

SYNTAX

DISCUSSION

When Z-Writer encounters a REDEFINE statement, it remembers its current location within the recordat that time. It then resets the current location to the location of the field named in the REDEFINEstatement.

The ENDREDEFINE statement restores the current location to the value saved when the REDEFINEstatement was encountered. The purpose of this is just to let you “cancel” a redefinition early, withouthaving to redefine all of the bytes in the field being redefined.

EXAMPLE

FLD CUSTOMER 15

FLD TELEPHONE N10REDEFINE TELEPHONEFLD AREA-CODE N3ENDREDEF

FLD TAX N4.2

ENDREDEFINE STATEMENT SYNTAX

ENDREDEFINE

Abbreviations Allowed:ENDREDEFINE - ENDREDEF

32 Z-Writer Reference Manual

FILE Statement

PURPOSE

Defines one input or output file to Z-Writer. Before a file can be used in a run, it must first be definedusing the FILE statement.

FEATURES

Use the FILE statement to:

� define the type of file (for example, whether it's VSAM)

� specify whether the file is an input or output file, or whether it will be updated (used for bothinput and output)

SYNTAX

DISCUSSION

This statement by itself does not perform any I/O operation on the file. This statement simply defines afilename to Z-Writer so that subsequent control statements can refer to that file. After a file has beendefined using this statement, READ, WRITE and various other statements may be used to perform I/Ooperation on the file.

The fields for the file must be defined immediately after the FILE statement. Use FLD statements todefine the fields. Often the FILE and FLD statements for a file are kept together in a copy library”.(Then use a COPY statement to copy them into programs as needed.)

You will also need one DD statement in the JCL for each file that you define and use in a run.

You may have as many FILE statements as you like in a run.

FILE STATEMENT SYNTAX

FILE filename[ INPUT/OUTPUT/UPDATE ][ TYPE(SAM/ESDS/KSDS/RRDS) ][ F/FB/V/VB[(nnnnn)] ]

Z-Writer Reference Manual 33

Z-Writer also maintains certain built-in fields for each file automatically. Some of these fields are“read-only,” meaning that you can examine the contents of the field, but not modify it. The built-infields for each file are shown in the table below. Note that if your program has more than one file, youwill need to qualify these built-in field names with the file name in order to uniquely reference them.(For example, SALES.#STATUS).

Built-In Fields Available for Files

FIELDNAME

TYPE & LENGTH

READ ONLY DESCRIPTION

#COUNT4-byte binary

YesNumber of successful reads from an INPUT or UPDATE file, or number of successful writes for an OUTPUT file.

#EOF1-byte

characterYes

Indicates whether an attempt was made to read past the last record in the file (“end of file”).

Y = the last operation was a POSITION or READ statement which raised the end of file condition

N = the last operation was not a POSITION or READ statement which raised the end of file condition

#RECSIZE4-byte binary

No

After a READ, this field contains the length of the record just read. Before a WRITE or an REWRITE, the user should ensure that this field contains the (new) length of the record.

#RRN4-byte binary

Yes

Defined only for RRDS files. Stands for “relative record number”. After a non-keyed READ, Z-Writer places the RRN of the record that it returns here. After a non-keyed WRITE, Z-Writer places the RRN of the record written here.

(For keyed reads and writes to RRDS files, the user must specify the desired RRN using the KEY parm of the relevant statement.)

#STATUS1-byte

characterYes

Indicates the status of the file after the most recent operation.

(blank) = uninitialized (no operations performed on file yet)

Y = last operation on file was successful

N =last operation on file was unsuccessful. After a keyed read, it may indicates missing record. After a sequential read, it indicates EOF.

34 Z-Writer Reference Manual

PARMS

filenameSpecifies the name of the file being defined. All other control statements will use this name when

referring to this file. You may assign any name you like within the naming conventions in box below.

INPUT/UPDATE/OUTPUT

Specifies the type of processing that will be performed on the file. If you will only be reading from thefile (whether sequentially or randomly) specify INPUT. INPUT is the default if you omit this parm.

If you will be writing all new records to a file specify OUTPUT. To read records, and then possiblymodify or delete the record, specify UPDATE.

F/FB/V/VB[(100/nnnnn)]

Specifies whether the records in the file are fixed (F/FB) or variable (V/VB) in length. If this parm isnot specified, fixed length records are assumed for SAM files, while variable length is assumed forVSAM files.

Optionally, you may also specify the record length in parentheses immediately after the formatcharacter. For variable length files, specify the length of the largest record that could be encounteredduring the run. For SAM files, cbe sure to allow for the 4–byte "record descriptor word" (RDW) at thebeginning of each record. When no length is specified, a 100-byte record area is reserved for the file bydefault.

Note: for fixed length VSAM files, specifying “F” here will improve the efficiency of anysorts performed on that file.

TYPE(SAM/ESDS/KSDS/RRDS)

Specifies the type of access method to use when reading this file. If not specified, SAM is assumed. Validfile types are listed in the following table:

Requirements for File Names

� file names may be from 1 to 8 characters long

� file names may contain alphanumeric characters and the “national” characters #, @, and $

� file names must not begin with a numeric character

� file names are not case sensitive

� file names must not be statement names or other reserved words

ExamplesSALESINSALESOUTMERGE2

Z-Writer Reference Manual 35

EXAMPLES

FILE SALESFILE SALES TYPE(ESDS) FFILE EMPL TYPE(KSDS) V(150)

FILE TYPES ALLOWED IN THE TYPE PARM

FILE TYPE DESCRIPTION

SAM

Standard sequential files, including tapes and disk datasets. The QSAM access method will be used. Sequential files may not be used with UPDATE processing.

ESDSA VSAM ESDS file. The IDCAMS access method will be used. The file is always processed sequentially.

KSDS

A VSAM KSDS file. The IDCAMS access method will be used. The file may processed sequentially, randomly, or a combination of both of those (i.e., random accesse(s) followed by sequential accesse(s).)

RRDS

A VSAM RRDS file. The IDCAMS access method will be used. The file may processed sequentially, randomly, or a combination of both of those (i.e., random accesse(s) followed by sequential accesse(s).) Keyed access requires a 1- to 4-byte KEY field containing the (full or partial) binary relative record number.

36 Z-Writer Reference Manual

FLD Statement

PURPOSE

Defines the properties of one field in the record area of a file or table, or in a work area. Before a fieldcan be referred to in any other control statement, it must first be defined using a FLD statement.

SYNTAX

DISCUSSION

The FLD statement provides certain essential information about a field, such as where it is located in arecord, how long it is and the type of raw data it contains. Optionally, the FLD statement can alsospecify certain reporting options to be used when the field appears in a report (using the PRINTstatement.) These options include the columns headings to use, how the raw data should be formatted,and more.

FLD statements must immediately follow the FILE, TABLE or WORKAREA statement to which theypertain. You may have as many FLD statements as you like.

FLD statements are often kept in a copy library, and copied into reports as needed using a COPYstatement.

The name of the field being defined is the first item in the FLD statement. The next item (and the onlyother required item) must specify the field’s length. The length can be specified in one of two ways:

FLD STATEMENT SYNTAX

FLD fieldname/FILLER[ n / tn / tn.n ][ LEN(n) ][ TYPE(datatype/CHAR) ][ DEC(n/0) ][ COL/DISP(n or +/-n or fieldname) ][ DIM(n [,n] ...) ][ INDEX(indexfld [,indexfld] ...) ][ FORMAT(displayformat) ][ HEADING(‘line1|line2|...’) ][ RJ/CJ/LJ ][ INIT(value) ]

Abbreviations and Alternative Spellings Allowed:FLD - FIELDFORMAT - FMTHEADING - HDG

Z-Writer Reference Manual 37

� using the special shorthand notation. Examples: 10 or N10 or P5.2

� using the LEN parm. Example: LEN(10)

If the data type is character, no other parms are required. For non-character fields, the data type mustbe specified, either along with the length in the shorthand notation, or immediately after the length in aTYPE parm.

After fieldname, length and data type, all other parms are optional and may appear in any order.

PARMS

fieldnameSpecifies the name of the field being defined. All other control statements will use this name whenreferring to the field. You may assign any name you like within the naming conventions in box below.t

Note: you may also specify the special word FILLER as the fieldname. Fillers fields may notactually be referenced in the report.

n / Tn / Tn.n (shorthand specification of type/length/decimal)You can specify the length (and optionally also a data type and decimals parm) using a specialshorthand notation. It is not required to use this shorthand notation-- you can also use explicit LEN (andTYPE and DEC) parms as needed. Whichever syntax you choose, the length must come right after thefieldname.

Requirements for Field Names

� field names may be from 1 to 70 characters long

� field names may contain alphanumeric characters, the “national” characters #, @, and $,underscores (_) and dashes (-).

� field names must not begin with a numeric character

� field names are not case sensitive

� field names must not be statement names or other reserved words

ExamplesJEMPL_NUMEMP#SMF30-ENCLAVE-CPU-TIME-IN-HUNDREDTHS-OF-SECONDS

38 Z-Writer Reference Manual

The table below explains the three formats allowed in the shorthand syntax.

LEN(nnn)

Specifies how many bytes the field occupies in the record or work area. Field length can be specifiedeither with this explicit parm, or using the shorthand notation described earlier. Whichever method isused, the length must come right after the fieldname on the FLD statement. The lengths allowed for afield depend on its data type. The table under the TYPE parm below shows the lengths allowed for eachdata type.

Note: for FILLER fields only, a length of 0 is also allowed.

TYPE(datatype)

Specifies how the raw data is stored in the record or work area. The field’s data type can be specifiedeither with this explicit parm, or using the shorthand notation described earlier. When used, the explicitTYPE parm should immediately follow the length specification.

The following table shows the complete list of data types, the abbreviations allowed, and theiracceptable lengths.

SHORTHAND NOTATION FOR DEFINING FIELDS

SYNTAX DESCRIPTION EXAMPLE

n Defines a character field of “n” bytes. FLD EMPLNAME 20

TnSpecifies a “data type”, and the length of the field in bytes. The field, if numeric, contains no decimal digits.

FLD EMPLNUM N3

Tn.n

Specifies a (numeric) “data type”, the length of the field in bytes, and the number of decimal digits that the field is understood to contain. Note that the field length is specified in bytes, while the decimal digits is the number of digits.

FLD AMOUNT P5.2

Note: a complete list of “data types”, and the lengths allowed for each, can be found in a table under the TYPE parm entry below.

DATA TYPES FOR FIELDS

DATA

TYPE DESCRIPTION

LENGTH

ALLOWED

COBOLEQUIV.

C

CHAR

Character data. Each byte may contain any 8-bit value. Use of this type code is optional. When no data type is specified, character data is assumed.

1 to 2,147,483,647 bytes

PIC X

N

NUM

Numeric data in “zoned” format. The first nibble of the last byte contains the sign information.

1-31 bytes PIC 9

P

PACK

Numeric data in signed, packed format. The last nibble of the last byte contains the sign information.

1-16 bytes COMP-3

Z-Writer Reference Manual 39

DEC(n/0)

Specifies how many of the digits in the numeric field are considered to be decimal digits. When notspecified, zero decimal digits is assumed.The number of decimal digits can be specified either with thisexplicit parm, or using the shorthand notation described earlier.

Note: the DEC parm has a slightly different meaning for fields with the FLOAT data type.By definition, float fields have a floating “decimal” point (technically a hexadecimal point)in their raw format, and thus a varying number of “decimal” digits. So for these fields, theDEC parms does not specify the number of “decimal” digits in the raw data. Instead, the DECparms specifies how many decimal digits to preserve when converting the raw data to fixedpoint decimal.

COL/DISP(n or +/-n or fieldname)

Specifies the field’s beginning column (or displacement) within the record or work area.

By default, the first field in a record or work area begins in column 1. And, by default, all other fieldsare assumed to begin immediately after the previously defined field. Use one of these parms if you wantto override a field’s default starting byte.

When specifying a fixed location (“n”), you may use either COL or DISP, whichever is moreconvenient for you. The first byte of a record is COL(1) or DISP(0). (When using the “+/-n” or“fieldname” syntax, the COL and DISP parms both yield the same result.)

Note: for variable length QSAM records (V or VB) the first four bytes of the record are calledthe record descriptor word (RDW). Thus, the first actual data byte in such records is incolumn 5 (or displacement 4).

PU

Numeric data in unsigned packed (also called BCD) format. The field does not contain sign information and the value is always treated as positive.

1-16 bytes none

B

BIN

Numeric data in signed, binary format. The first bit of the first byte contains the sign information.

1-8 bytesPIC 9 COMP SIGNED

BU

Numeric data in unsigned binary format. The field does not contain sign information and the value is always treated as positive.

1-8 bytesPIC 9 COMP UNSIGNED

F

FLOAT

Numeric value in IBM’s hexadecimal floating point representation. Such fields contain a sign in the leading bit, a hexadecimal exponent is in the next 7 bits, and a hexadecimal fraction in the remaining bytes. Note that while lengths up to 16 bytes are accepted, Z-Writer actually uses only the first 8 bytes (14 hexadecimal digits) of the field. Any additional trailing digits are truncated.

2-16 bytesCOMP-1COMP-2

DATA TYPES FOR FIELDS

DATA

TYPE DESCRIPTION

LENGTH

ALLOWED

COBOLEQUIV.

40 Z-Writer Reference Manual

Note: another way to specify the location of a field is to use the REDEFINES (and optionallythe ENDREDEF) statement.

The table below explains the three ways that you can specify a field’s starting location within the COLand DISP parms.

DIM(n [,n] ...)

The presence of this parm indicates that the field being defined is an array. Use this parm to specify thenumber of elements in each dimension of the array. You must use numeric literals within this parm --field names are not allowed. Z-Writer allows you to specify up to 2,147,483,647 elements perdimension, however memory constraints may limit this as a practical matter.

Z-Writer supports up to 32,767 dimensions.

References to Array Elements. In your program code, fields defined with the DIM parmmust always be referenced using a subscript. Subscripts are placed in square brackets afterthe field name. (The subscript may optionally be separated from the fieldname with one ormore spaces.) Within the brackets, there must be one element specifier per defined dimensionfor the field. The first element of each array dimension has subscript “1”. Each subscript maybe specified as either a numeric literal or a numeric field. (Numeric expressions are notallowed.) A numeric field used as a subscript may itself be subscripted.

Following is an example of defining a one-dimensional array, and using it in a MOVEstatement:

FLD ADDR_LINE 30 DIM(4)...MOVE ADDR_LINE[3] TO OUT_ADDR

Inheritance of the DIM Parm. If you use a REDEFINE statement to redefine an array field,the fields that redefine it will also inherit that DIM parm. (This continues until either anENDREDEF statement is encountered, or until you have redefined beyond the original arrayfield.) Thus, you will also need to use subscripts when referencing any field that redefines anypart of an array field.

For example:

COL AND DISP PARM SYNTAX

SYNTAX DESCRIPTION EXAMPLE

nThe field starts in the column or displacement specified.

FLD EMPLNAME 20 COL(11)FLD EMPLNAME 20 DISP(10)

+/-n

The field will start ‘n‘ bytes before (-) or after (+) its default starting position. Use this syntax if you want to skip over (or back up and redefine) a portion of the record.

FLD DATE-DD 2 COL(*-2)

fieldname

The field starts in the same byte that the named field starts in. (The field must have already been defined, within the same record.)

FLD DATE-YY 2 COL(DATE)

Z-Writer Reference Manual 41

FLD DATE 6 DIM(10)REFEDINE DATEFLD DATE-YY 2FLD DATE-MMFLD DATE-DDENDREDEFINE...MOVE DATE-MM(8) TO WORK2

INDEX(indexfld [,indexfld] ...)

Specifies one or more “index fields” to use when locating the field within a record or workarea. In thisparm, you may name a previously defined numeric field. Or you can provide a valid fieldname that hasnot yet been defined. In that case, Z-Writer defines it for you as a new 4-byte binary field. Each timeyou reference a field that was defined with an INDEX parm, the values of all of its index fields aresummed together and added to the field’s defined location (that is, the location defined by its COL orDISP parm, if any.) This aggregate value determines the field’s location within the record or workareaat that point in the program.

Inheritance of the INDEX Parm: If you use the REDEFINE statement to redefine a fieldthat has an INDEX parm, the fields that redefine it will also inherit that INDEX parm. (Thiscontinues until either an ENDREDEF statement is encountered, or until you have redefinedbeyond the original indexed field.)

Note: one use of indexes is to work with arrays. In most cases, however, specifying the DIMparm, and using array subscripts, is a much easier way to work with arrays.

FORMAT(displayformat)

Specifies how the field’s raw data should be formatted when it is printed in a report (using the PRINTstatement.) See the table on page 67 for a list of display formats.

HEADING(‘line1 | line2 | ...’)

Specifies the column headings to use when printing this field in a report (using the PRINT statement.)

Use one or more “|” characters within the text to indicate how the heading should be broken ontomultiple column heading lines. Each column heading is centered over the column by default. So you donot need to include pad characters in the text to help center it. (You can use left or right pad charactersif you do not want centered headings.)

LJ / CJ / RJ

Specifies how the data should be justified when it is printed in a report (using the PRINT statement.)The values mean left-justified, center-justified and right-justified, respectively.

INIT(value)

Specifies an initial value to be placed in the field before the program begins execution. The value mustbe a character literal for character fields, or a numeric literal for numeric fields.

EXAMPLES

FLD EMPL-NUM 3FLD AMOUNT N5.2FLD LAST-NAME 20FLD LAST-NAME C20 CJFLD LAST-INITIAL 1 COL(LAST-NAME)

42 Z-Writer Reference Manual

FLD FILLER 19FLD DEPT-NUM N3FLD SALES-AMOUNT P8.2 FORMAT(PIC’$$$,$$9.99’)FLD LOOP-COUNTER B2FLD FLOAT-AMOUNT F4.2 HEADING(‘TRANSACTION|AMOUNT’)

Z-Writer Reference Manual 43

GOTO Statement

PURPOSE

Unconditionally transfers execution of the program to the statement with the specified label.

SYNTAX

PARMS

labelSpecifies the statement to which transfer should be transferred. (Labels are optional names, appendedwith a colon, that precede a statement itself.) Labels must follow the naming conventions in the box

below.

GOTO STATEMENT SYNTAX

GOTO label

Requirements for Statement Labels

� labels may be from 1 to 70 characters long

� labels may contain alphanumeric characters, the “national” characters #, @, and $,underscores (_) and dashes (-).

� label names are not case sensitive

� label names must not begin with a numeric character

� labels must end with a colon

ExamplesWRAPUP:A-100-WRITE-OUTPUT:A-100-WRITE-OUTPUT-EXIT:

44 Z-Writer Reference Manual

EXAMPLES

IF EMPL.#STATUS = ‘N’ GOTO WRAPUP...WRAPUP: PRINT ‘END OF RUN’

Z-Writer Reference Manual 45

IF Statement

PURPOSE

The IF statement begins an “if-structure”. The purpose of an if-structure is to conditionally execute (atmost) one set of statements within the structure

SYNTAX

DISCUSSION

An if-structure always begins with an IF statement and ends with an ENDIF statement. Within thestructure, one or more optional ELSEIF statements and/or a single ELSE statement may also be used.

Here is a description of how if-structures are processed.

The IF statement, as well as any optional ELSEIF statements contain a conditional expression. Thoseconditional expressions are evaluated in turn, until the first one is found that is true. The “otherstatements” following the true conditional expression are then executed, after which control passes tothe first statement after the ENDIF statement. (You are allowed to have zero “other statements,” inwhich case control is immediately passed to the first statement after the ENDIF statement.)

Note: GOTO statements are permitted within if-structures. Labels, however are notpermitted.

If none of the conditional expressions are true, then one of the following occurs:

� if there is a final ELSE statement within the if-structure, the “other statements” following itare executed, after which control passes to the first statement after the ENDIF statement.

� otherwise, control simply passes to the first statement after the ENDIF statement.

IF STRUCTURE SYNTAX

IF conditional-expressionother statements

[ ELSEIF conditional-expression other statements ] ...

[ ELSE other statements ]

ENDIF

46 Z-Writer Reference Manual

As mentioned, the IF statement, and also any ELSEIF statements, simply contain a “conditionalexpression.” A conditional expressions is just one or more “tests” (or comparisons) between fields and/or literals.

If the conditional expression has more than one test, those tests must be connected using the keywordsAND and OR. Tests can also be grouped within parentheses, and nested to indicate the desired order ofevaluation. You may also negate either a single test or a parenthesized group of tests by preceding itwith the keyword NOT.

The use of “AND”, “OR”, “NOT” and parentheses is the same as in all common programminglanguages (including COBOL and BASIC) and will not be elaborated upon here.

Now let’s look at the syntax for the individual tests themselves, because Z-Writer does support a fewsyntactical features that are not standard in other languages.

Syntax of a Simple TestThe syntax of a simple test is:

OPERAND1 COMPARATOR OPERAND2

Each of the two operands can be either a field or a literal; the comparator can be any symbol from thefollowing table.

CONDITIONAL EXPRESSION SYNTAX

Conditional expressions take the form:

[NOT] test [ AND/OR [NOT] test ] [ AND/OR [NOT] test ] ...

Parentheses can be used to group two or more tests or groups of tests together. Nestingis allowed to any level. When priority is not indicated by parentheses, “AND”ed testsare performed before “OR”ed tests at the same level.

TEST SYNTAXES

OPERAND1 COMPARATOR OPERAND2OPERAND1 COMPARATOR OPERAND2 THRU OPERAND3OPERAND1 COMPARATOR OPERAND2 [OPERAND3] [OPERAND4] ...

Z-Writer Reference Manual 47

Here is an example of a simple test in an IF statement:

IF AMOUNT = SELECT-AMOUNTIF AMOUNT GT 100.00

Comparing an Operand to a Range of ValuesConditional expressions may also contact tests in this format:

OPERAND1 =/<> OPERAND2 THRU OPERAND3

This syntax compares operand1 to a range of values. For example:

IF AMOUNT = 100 THRU 199.99

The above test is true when the AMOUNT field contains any value between 100.00 and 199.99,inclusive.

Each of the operands can be either a field or a literal.

The comparator must be either “equals” (‘=’, EQ) or “not equals” ( ‘¬=‘, ‘<>’, NE). The othercomparators may not be used with ranges. When “not equal” is used, the test is true as long as operand1does not fall within the inclusive range specified.

Comparing an Operand to a List of ValuesConditional expressions may also contact tests in this format:

OPERAND1 =/<> OPERAND2 [OPERAND3] [OPERAND4] ...

COMPARATORS ALLOWED IN CONDITIONAL EXPRESSIONS

SYMBOL MEANING

=

EQEqual to

¬=<>

NE

Not equal to

<

LTLess than

<=

LRLess than or equal to

>

GTGreater than

>=

GEGreater than or equal to

48 Z-Writer Reference Manual

This syntax compares operand1 to a list of values. You may separate the operands in the list with spacesand/or commas. For example:

IF AMOUNT = 0, 100, 9999999

The above test is true when the AMOUNT field contains any of the three values, zero, one hundred, or99999999.

Each of the operands can be either a field or a literal.

The comparator must be either “equals” (‘=’, EQ) or “not equals” ( ‘¬=‘, ‘<>’, NE). The othercomparators may not be used with operand lists. When “not equal” is used, the test is true as long asoperand1 does not equal any of the operands in the list.

Combining Ranges and ListsYou may also combine lists and ranges within a single test. For example:

IF AMOUNT = 0, 5, 10, 100 THRU 199.99, 500, 1000 THRU 1999.99

EXAMPLES

IF AMOUNT = TEST-AMOUNT PRINT ‘EQUALS TEST AMOUNT’ELSEIF AMOUNT = 400 PRINT ‘EQUALS 400’ELSEIF AMOUNT = 500 THRU 599 PRINT ‘BETWEEN 500 AND 599 (INCLUSIVE)’ELSEIF AMOUNT = 2, 4, 6 PRINT ‘EQUALS 2, 4 OR 6’ELSEIF AMOUNT = 1, 3, 5, 700-799, 1000-1099, 9999 PRINT ‘1, 3, 5, SEVEN HUNDRED SOMETHING, ONE THOUSAND SOMETHING OR 9999’ELSE PRINT ‘DID NOT EQUAL ANY OF THE ABOVE’ENDIF

IF DEPT-NUM = ‘2’ THRU ‘4’ AND (AMOUNT < 100 OR AMOUNT > 5000) MOVE ‘2’ TO STATUS-FLAG PRINT ‘STATUS 2’ EMPL-NUMENDIF

Z-Writer Reference Manual 49

LISTOFF STATEMENT

PURPOSE

Stops the listing of control statements (to the SYSPRINT DD) as they are read and processed. Bydefault, control statements are listed as they are processed.

SYNTAX

EXAMPLES

LISTOFF

LISTOFF STATEMENT SYNTAX

LISTOFF

50 Z-Writer Reference Manual

LISTON STATEMENT

PURPOSE

Resumes the listing of control statements (to the SYSPRINT DD) as they are read and processed. (Thisis also the default mode.)

SYNTAX

EXAMPLES

LISTON

LISTON STATEMENT SYNTAX

LISTON

Z-Writer Reference Manual 51

MOVE Statement

PURPOSE

Moves the contents of one field to another field, changing its data representation if required.

SYNTAX

DISCUSSION

The type of processing performed on the raw data during a move depends on the data types of the sourceand target fields. The table below shows how data is processed during a move.

MOVE STATEMENT SYNTAX

MOVE fieldname/literal TO fieldname

52 Z-Writer Reference Manual

EXAMPLES

MOVE LAST-NAME TO FIRST-NAMEMOVE ‘JONES’ TO LAST-NAMEMOVE BIN-AMOUNT TO PACK-AMOUNT

MOVE Statement Processing

Target Field Data Type

CHAR 1 NUM PACK PU BIN BU FLOAT

Source

Field

Data

Type

CHAR 1 As-Is As-Is As-Is As-Is As-Is As-Is As-Is

NUM As-Is

Converted to

NUM 2

Converted to Pack

Converted to PU

Converted to binary

Converted to BU

N/A

PACK As-IsConverted to NUM

Converted

to Pack 2

Converted to PU

Converted to binary

Converted to BU

N/A

PU As-IsConverted to NUM

Converted to Pack

Converted to

PU 2

Converted to binary

Converted to BU

N/A

BIN As-IsConverted to NUM

Converted to Pack

Converted to PU

Converted

to binary 2

Converted to BU

N/A

BU As-IsConverted to NUM

Converted to Pack

Converted to PU

Converted to binary

Converted to

BU 2N/A

FLOAT As-IsConverted to NUM

Converted to Pack

Converted to PU

Converted to binary

Converted to BU

As-Is 3,4

Notes:

1. For “as-is” moves, the source data is truncated on right if the target is shorter, or right padded with blanks if the

target is longer.

2. If source and target field are the same length and have the same number of decimal digits, an “as-is” move is

performed instead.

3. If source and target field are the same length, an as-is move is performed instead.

4. Source data is truncated on right if target is shorter, and right padded with hex zeros if target is longer.

Z-Writer Reference Manual 53

NEWREPORT Statement

PURPOSE

Specifies that a new report program follows. This marks the end of the previous report program and thebeginning of a new one.

SYNTAX

DISCUSSION

Each report is written to a separate DD which must be present in the execution JCL. The first report (forwhich there should be no NEWREPORT statement) is written to the ZWOUT001 DD. If you then codea NEWREPORT statement to begin the program code of a second report, its output will be written toZWOUT002. The next NEWREPORT statement would produce a report written to ZWOUT003, andso on.

When you begin a new report (by specifying NEWREPORT), none of the fields or files from theprevious report(s) are available. You must define new files, work areas, etc. However, if you do needto use the same file as was defined for a previous report, you can quickly define it for the current reportwith the REUSE statement.

EXAMPLE

NEWREPORT

NEWREPORT STATEMENT SYNTAX

NEWREPORT

Alternate Spellings:

NEWREPORT - NEWREP

54 Z-Writer Reference Manual

ONERROR Statement

PURPOSE

Specifies how Z-Writer should handle certain error situations, if they arise. You may also specify thatthe completion code of the job step be raised if an error occurs.

SYNTAX

DISCUSSION

You may specify any number of error conditions on a single ONERROR statement. The error handlingsettings for all conditions not specified are not be affected.

For each error condition, specify one of the handling options allowed for that parm. Optionally, youmay also specify a job step completion code to be used if the error does occur. (Otherwise, each errorhandling option implies its own default completion code setting, as shown in the tables below.)

The completion code affected is the final program completion code that Z-Writer passes to z/OS at theend of its execution. This completion code is maintained in the #RETCODE built-in field. Note that thecompletion code can only be raised to the setting you specify (or to the default setting.) It is neverlowered if it is already contains higher setting.

This is an executable statement, meaning that it takes effect only after it has been executed. Errors willbe handled according to the most recent ONERROR statement executed (for the applicable errorcondition.) By using multiple statements, you can handle the same error in different ways for differentparts of your program.

You may also specify an error condition with empty parentheses after it; that resets the error conditionback to its default setting

If this statement is not used, Z-Writer handles errors with a default action and completion code.

ONERROR STATEMENT SYNTAX

ONERROR[ PRTSIZE[(BESTFIT/TRUNCATE/WARN/STOP [n/0]) ][ INVDATA[(ZERO/WARN/STOP [n/4]) ][ OVERFLOW[(ZERO/WARN/STOP [n/12]) ][ DIVBYZERO[(ZERO/WARN/STOP [n/12]) ]

Z-Writer Reference Manual 55

PARMS

PRTSIZE[( BESTFIT / TRUNCATE / WARN / STOP [n/0] )]

This condition arises when a PRINT statement is executed and there is not room in the report columnto show all of the field’s significant digits (plus a negative sign if applicable.)

By default, Z-Writer uses the BESTFIT handling (see table below). That means that, rather thanshowing a misleading number with missing leading digits, an approximate value is shown for the field.If the column is too small to show even that, then Z-Writer indicates this error by putting *S* in thereport column. (The S is an error legend and indicates a “size” error.)

The following table shows the settings you can choose for the PRTSIZE condition, if you do not wantthis default handling.

OPTIONS FOR THE PRTSIZE ERROR

OPTION MEANING

DEFAULT COMP CODE

BESTFIT

Z-Writer shows the value of the field to the greatest precision that fits in the column. It tries in turn each of the following, until it finds one that fits in the column: a) just the whole portion of the value (dropping any decimal digits; b) the value rounded to thousands (nnnK); the value rounded to millions (nnnM); and so on. If no fit is found, it prints asterisks in the column with a legend character of S (“size”). This is the default handling.

When this option is chosen, the default is not to change the completion code if the error occurs. However, you can specify your own completion code with this option, if desired.

0

TRUNCATE

Z-Writer shows as many digits as will fit, truncating one or more leading digits (and/or possibly a leading negative sign.) This handling, while it can produce very misleading results, does mimic the handling of certain other widely used reporting tools.

When this option is chosen, the default is not to change the completion code if the error occurs. However, you can specify your own completion code with this option, if desired.

0

WARN

Z-Writer prints a message when a value does not fit within its report column. (One message is printed per field that experiences this error condition.) The report will show a size error indicator (**S**) for the field in the report.

When this option is chosen, the default is to raise the completion code to 4 if the error occurs. However, you can specify your own completion code with this option, if desired.

4

56 Z-Writer Reference Manual

INVDATA[( ZERO / WARN / STOP [n/4])

This condition arises when the raw data being processed contains an invalid value. (For example, a fielddefined as packed actually contains hex zeros; or a field defined as NUM contains alphabeticcharacters.)

By default, Z-Writer prints a warning message (once per field) and shows the actual raw data found.(This is print in the control listing-- not in the report.) It then proceeds as though a valid value of zerohad been found for the field. The completion code to use on exit is raised to 4, if it is lower than that.

The following table shows the settings you can choose for this condition, if you do not want this defaulthandling.

STOP

A warning message will be printed when a value does not fit within its report column, and the current report will be halted.

When this option is chosen, the default is to raise the completion code to 12 if the error occurs. However, you can specify your own completion code with this option, if desired.

12

OPTIONS FOR THE PRTSIZE ERROR

OPTION MEANING

DEFAULT COMP CODE

OPTIONS FOR THE INVDATA, OVERFLOW AND DIVBYZERO ERRORS

OPTION MEANING

DEFAULT COMP CODE

ZERO

Z-Writer uses a value of zero for the field. No message is printed.

When this option is chosen, the default is not to change the completion code if the error occurs. However, you can specify your own completion code with this option, if desired.

0

WARN

Z-Writer uses a value of zero for the field. One message is printed per field that experiences this error condition.

When this option is chosen, the default is to raise the completion code to 4 if the error occurs. However, you can specify your own completion code with this option, if desired.

4

STOP

A warning message will be printed when this error occurs, and the current report will be halted.

When this option is chosen, the default is to raise the completion code to 12 if the error occurs. However, you can specify your own completion code with this option, if desired.

12

Z-Writer Reference Manual 57

OVERFLOW[( ZERO / WARN / STOP [n/12])

This condition arises when a numeric overflow occurs during processing. Such overflows can arisewhen converting very large numbers, multiplying very large numbers, dividing very large numbers bya very small number and in other situations.

By default, Z-Writer prints a warning message and halts the execution of the current report; thecompletion code is raised to 12.

The table above (under INVDATA) shows the settings you can choose for this condition, if you do notwant the default handling.

DIVBYZERO[( ZERO / WARN / STOP [n/12])

This condition arises when a division by zero is attempted during processing.

By default, Z-Writer prints a warning message and halts the execution of the current report. Thecompletion code is raised to 12.

The table above (under INVDATA) shows the settings you can choose for this condition, if you do notwant the default handling.

EXAMPLES

ONERROR PRTSIZE(TRUNCATE) INVDATA(WARN 0) OVERFLOW(ZERO 8)ONERROR INVDATA() /* REVERT TO DEFAULT */

58 Z-Writer Reference Manual

OPEN Statement

PURPOSE

Opens one file for subsequent processing. The OPEN statement does not cause a record to be read from(or written to) the file.

SYNTAX

DISCUSSION

You do not normally need to code an explicit OPEN statement. Z-Writer performs an implicit OPENbefore the first READ, WRITE or POSITION to a file. However, this statement (along with the CLOSEstatements) is useful if you wish to read through a file more than one time in the same report program.

After an OPEN statement, you can check the result of the operation by examining the file’s #STATUS

built-in field. The table below shows its possible values after the operation.

PARMS

filenameSpecifies the name of the file to open. The file must have been previously defined using a FILEstatement. This parm is required.

EXAMPLES

OPEN EMPL

OPEN STATEMENT SYNTAX

OPEN filename

#STATUS Built-In Field Values After an OPEN Statement

Y - file successfully openedN - file not opened

Z-Writer Reference Manual 59

OPTION Statement

PURPOSE

Specifies one or more special options for the current report (or, in some cases, for the run as a whole.)

SYNTAX

DISCUSSION

You may specify as many options as you like on a single OPTION statement. In addition, you may haveas many separate OPTION statements as you like.

OPTION statements should normally appear before all other control statements.

PARMS

COLHDG/COLHDGSCauses column headings to print on each new page of the report. The column headings print after alltitle lines. Specifies the default number of spaces to leave between each column in the current report.Column headings are printed for each field (and literal) found in the PRINT statement

Note: column headings will print only if there is a single PRINT statement in the controlstatements. (To print column headings when multiple PRINT statements are used, specify theMULTICOLHDG option.)

OPTION STATEMENT SYNTAX

OPTION [ COLHDG/COLHDGS ] [ COLSPACE(N/1) ] [ CURRCHAR(‘x’/’$’) ] [ LINES(NN/60) ] [ NOCOLHDG/NOCOLHDGS ] [ MULTICOLHDG/MULTICOLHDGS ] [ PICBASE10(‘x’/’#’) ] [ PICBASE2(‘x’/’@’) ] [ QUOTECHAR(‘x’/’”’) ] [ VERIFY ] [ WIDTH(NNN/132) ]

60 Z-Writer Reference Manual

Note: the column headings printed are taken from (in order of precedence): the PRINTstatement; the FLD statement; the fieldname itself.

by default, if there are more than

COLSPACE(n/1)Specifies the default number of spaces to leave between each column in the current report.

CURRCHAR(‘x’/’$’)Specifies the character to use as the currency symbol, for items formatted with the CURRENCY displayformat. (Display formats are listed on page 67.) You may specify any 1-byte character or hex literalhere. The default currency character is the dollar sign.

LINES(nn/60)Specifies the number of lines to print on each page of the current report.

NOCOLHDG/NOCOLHDGSSuppresses column headings from the report. This is the default.

MULTICOLHDG/MULTICOLHDGSCauses column headings to be printed for the fields in each PRINT statement. The column headingswill print in the same order as the PRINT were found in the control statements.

PICBASE10(‘x’/’#’Specifies the character to be interpreted in PICTUREs as the Base 10 scaling character. (See adescription of this in Appendix C, "Syntax of PICTURE Display Formats" on page 108.) You mayspecify any 1-byte character or hex literal here. The default value is the “number/pound” sign.

PICBASE2(‘x’/’@’Specifies the character to be interpreted in PICTUREs as the Base 2 scaling character. (See a descriptionof this in Appendix C, "Syntax of PICTURE Display Formats" on page 108.) You may specify any 1-byte character or hex literal here. The default value is the “at” sign.

QUOTECHAR(‘x’/’”’Specifies the character to use as the quote character, for items formatted with the QCHAR displayformat. (Display formats are listed on page 67.) You may specify any 1-byte character or hex literalhere. The default quote character is the double quotation mark.

VERIFYSpecifies that the control statements should be verified and any error messages printed; but the programshould not be executed.

WIDTH(nnn/132)Specifies the width of the print lines in the current report.

EXAMPLES

OPTION LINES(55) WIDTH(121)

Z-Writer Reference Manual 61

PERFORM Statement

PURPOSE

Unconditionally executes one or more consecutive paragraphs of the program. Then execution resumeswith the statement immediately following the PERFORM statement.

SYNTAX

DISCUSSION

Within the performed paragraphs, it is permitted to branch outside of the range of those paragraphs.However, this is not usually a good coding practice. If you do branch out of the paragraphs beingperformed, it is strongly recommended that you branch back into them to complete execution of theperformed paragraphs. That allows the processing of the PERFORM statement to wrap up cleanly.

The paragraphs performed must be within the code for the current report.

A paragraph of code begins with a label and ends at the last statement before the next label (or the beforethe end of the program.)

Empty paragraphs are permitted. (That is, two consecutive labels with no statements between them.)

PARMS

labelSpecifies the label of the first (and optionally the last) paragraph to be performed. When only the firstlabel is present, that single paragraph is executed. When both labels are specified, all paragraphs in therange, including the last paragraph named, are performed. (The syntax rules for labels are explained onpage 43.)

PERFORM STATEMENT SYNTAX

PERFORM label [THRU label]

62 Z-Writer Reference Manual

EXAMPLE

PERFORM SWAP-FIELDSPERFORM A-WRITE-100 THRU A-WRITE-100-EXIT...

SWAP-FIELDS:X=AA=BB=X

A-WRITE-100:WRITE OUT01TOTW=TOTW+1

A-WRITE-100-EXIT:

B-100-READ:READ EMPL...

Z-Writer Reference Manual 63

POSITION Statement

PURPOSE

Positions a logical “pointer” in a random access VSAM file, so that sequential reads can begin from thatpoint. This statement does not perform an actual read, so the file’s record area remains unchanged by it.

SYNTAX

DISCUSSION

After a POSITION statement, you can check the result of the operation by examining the file’s

#STATUS built-in field. The table below shows its possible values after a POSITION statement.

A record meets the POSITION criteria by having a key which either:

1) exactly matches the key (or partial key, if GEN specified) in this statement’s KEY parm, or

2) is the first key with a value greater than the key (or partial key) in the KEY parm, if KGE wasspecified.

After a successful POSITION, the next sequential READ statement returns the first record whose keymeet the criteria specified above. (You may then perform additional sequential reads to see if otherrecords exist which meet your criteria.)

Note: if the POSITION is not successful, do not attempt to perform a sequential READ at thatpoint. That can result in a VSAM logical error and the program will end.

POSITION STATEMENT SYNTAX

POSITION filenameKEY(fieldname/’literal’)[GEN][KEQ/KGE]

#STATUS Built-In Field Values After a POSITION Statement

Y - file positioned successfully (a record meeting the specified key criteria exists in the file, but has not read yet)N - file not positioned successfully (no matching record exists in the file -- do not perform a READ NEXT until establishing a position within the file.)

64 Z-Writer Reference Manual

PARMS

filenameSpecifies the name of the file to position. The file must have been previously defined using a FILEstatement. It must have been defined as either a KSDS or RRDS file. This parm is required.

KEY(fieldname/’literal’)This parm is required. It specifies the field (or literal) with the key value that you want to position thefile at. The file will be positioned so that the next sequential READ statement (that is, a READstatement without a KEY parm) will return the record whose key matches or is higher than this KEYparm value, if such a record exists.

[GEN]Indicates that the KEY parm contains a “generic” key. A generic key is shorter than the full key lengthdefined for the file. Use this parm to position a file using only some leading portion of a key. Asubsequent sequential READ statement will return the first record with a key matching the genericportion of the key specified, if such a record exists. If no such match exists, and the KGE is alsospecified, the READ will return the record with the next higher partial key.

[KEQ/KGE]Specifies the key matching criteria to use with the KEY parm.

� KEQ (“key equal”), the default, indicates that a record is considered a match if it’s key (orpartial key) value exactly matches the KEY parm.

� KGE (“key greater than or equal to”) indicates that a record is considered a match if it’s key(or partial key) value is greater than or equal to the KEY parm.

EXAMPLES

POSITION DEPT KEY(TEST-DEPT-PREFIX) GENIF DEPT.#STATUS = ‘Y’ READ DEPT DOWHILE DEPT.#STATUS = ‘Y’ AND EMPL.DEPT-PREFIX = TEST-DEPT-PREFIX PRINT DEPT-NUM DESCRIPTION READ DEPT ENDDO

Z-Writer Reference Manual 65

PRINT Statement

PURPOSE

Prints one line to the current report output.

SYNTAX

DISCUSSION

You can use the PRINT statement to:

� specify the fields (or literal texts) to print in your report

� specify where to place each item on the report line

� specify or override the default column headings

� specify or override the desired format to use for individual items on the report line

� specify line spacing to perform before and/or after the report line itself

PARMS

fieldname/’literal’[(parms)]Specifies one item to include in the report line. This can be either the name of a field whose contentsshould print in the report line, or a literal value to print in report.

PRINT STATEMENT SYNTAX

PRINT [ fieldname/’literal’[(parms)] fieldname/’literal’[(parms)] ] ... [ AFTER(n/0/PAGE) ] [ BEFORE(n/1) ]

66 Z-Writer Reference Manual

One or more optional parms may appear within parentheses after the item. (There should be no spacebefore the parm list.) The following table shows the parms that can be specified for each item. All areoptional and they may be specified in any order, separated by spaces and/or commas.

PARMS ALLOWED FOR ITEMS IN THE PRINT STATEMENT

SYNTAX DESCRIPTION EXAMPLE

nSpecifies an override width (in bytes) to use for this report column. When omitted, Z-Writer picks a default width to use.

PRINT DESCRIPTION(10)

+n

Means begin this column “n” bytes after the end of the previous column. For example, you can specify +0 if no spaces are wanted after the previous column. Z-Writer’s default is to leave 1 space between report columns (overridable with the COLSPACE option.)

PRINT ‘NAME=’ NAME(+0)

@n/

@fieldname

These parms specify where to begin the item’s data in the report line. By default, Z-Writer begins the first item in column 1, and each subsequent item one space past the end of the previous one.

@n means begin the data in column “n” of the report line.

@fieldname means that the report column should begin in the same location as the named field did (in the first PRINT statement encountered for the report.) This parm can help you line up the data in your total lines with the data in your detail lines.

PRINT NAME(@125)PRINT TOT-AMOUNT(@AMOUNT)

‘hdg1|hdg2|...’

Specifies the column heading to use for this field. You can use one or more “|” characters within the text to indicate how the heading text should be broken onto multiple column heading lines.

When omitted, Z-Writer uses the column heading text from the HEADING parm of the FLD statement, if any. Otherwise the fieldname itself is used as the column heading.

Note: to get column headings to your report, you mustexplicitly request them (using an OPTION statement.)The default is for no automatic column headings.

PRINT SEX(‘S|E|X’)

LJ/CJ/RJ

Specifies how the data should be justified within the report column. The values mean left-justified, center-justified and right-justified, respectively

PRINT DEPT-NUM(LJ)

display-format

You may specify the name of any of Z-Writer’s “display formats” that are valid for the data type of the item. This parm determines how the data is formatted in the report line. (The table on page 67 lists all of the display formats.)

When omitted, Z-Writer uses: 1), the display format from the FORMAT parm of the FLD statement, if any, or 2) a default display format.

PRINT AMOUNT(CURRENCY)

Z-Writer Reference Manual 67

BIZ

(Stands for “blank-if-zero”). Use this with a numeric field if you want the report column to be left completely blank for zero values. In reports where most instances of a field are zero, this parm can help make significant data to stand our better. It can also reduce clutter in a busy report.

PRINT ERROR-COUNT(BIZ)

BIR

(Stands for “blank-if-repeat”). Specifies that this report column should be left blank if its contents would be a repeat of its contents in the previous instance of this report line.

PRINT REGION(BIR)

BIRPAGE

(Stands for “blank-if-repeat/page”). Specifies that this report column should be left blank if its contents would be a repeat of its contents in the previous instance of this report line. However, the contents is always shown on the first line of each new page in the report.

PRINT REGION(BIRPAGE)

PARMS ALLOWED FOR ITEMS IN THE PRINT STATEMENT

SYNTAX DESCRIPTION EXAMPLE

DISPLAY FORMATS

DISPLAY

FORMAT DESCRIPTION EXAMPLE

Display Formats That Can Be Used With Any Type Of Data

ASIS

No formatting is done–– data is printed "as is". This is normally used only for character fields, but is allowed for any type of field.

This is the default display format for character fields.

ABC

QCHAR

The data is enclosed within quotation marks. Otherwise, the data is not reformatted at all. This format is useful for formatting character fields for use in PC files. (You can use the QCHAR parm of the OPTIONS statement to choose a character other than the double quotation mark to use with this display format.)

“ABC”

HEX

Each byte of data is expanded into two bytes to show the hexadecimal representation of the data. This format is useful when investigating fields that contain invalid data, such as hex zeros.

C1C2C3

BITSEach byte of data is expanded into an 8-byte character string of 0’s and 1’s, showing the individual bits within the data.

11000001

68 Z-Writer Reference Manual

AFTER(n/1/PAGE)Specifies that the report line is to be printed after special spacing has been performed.. When this parmis omitted, Z-Writer prints the report line after a single “line feed”. This results in a standard singlespaced report.

A numeric literal “n” specifies the number of line feeds to perform before printing the report line. Forexample, a value of 2 would produce a double-spaced report. A value of 0 can be used to overprint theprevious report line, if the printer hardware supports this.

Specifying PAGE for this parm means that the report line should be printed after skipping to a newpage.

Display Formats That Can Be Used Only With Numeric Data

EDIT

The numeric value is edited according to common American presentation conventions. Formatting includes suppression of leading zeros, the use of commas as separators and a decimal point before any decimal digits. A floating negative sign precedes negative numbers.

This is the default display format for all numeric fields.

1,234.56–1,234.56

DOTSEP

The numeric value is edited according to presentation conventions common in Europe and other international regions.

Formatting includes suppression of leading zeros, the use of “dots” as separators and a comma before any decimal digits. A floating negative sign precedes negative numbers.

1.234,56–1.234,56

NOCOMMA

Same as EDIT, except that commas are not inserted among the digits. This format is useful for formatting numeric fields in comma-delimited files, used to export data to PCs.

1234.56–1234.56

CURRENCY

DOLLAR

Same as EDIT, but a floating currency sign will precede the first significant digit. The currency sign is a dollar sign by default. (Use the CURRENCY parm of the OPTIONS statement to choose a character other than the dollar sign to use with this display format.)

$1,234.56–$1,234.56

DISP

DISPLAY

Numbers are displayed without any punctuation (other than a decimal point, if necessary). Leading zeros are not suppressed. The "zone" portion of the last digit contains the sign.

0001234.5670001234.56P

PIC

PICTURE

A "picture" is used to describe exactly how the numeric value should be formatted. This is useful for formatting special purpose numbers, such as telephone numbers, social security numbers, numbers as Kb, Mb, Gb and etc. The details of Z-Writer’s PICTURE syntax are explained in Appendix C, "Syntax of PICTURE Display Formats" on page 108.

(800) 555–1212123–45–67891.29MB

DISPLAY FORMATS

DISPLAY

FORMAT DESCRIPTION EXAMPLE

Z-Writer Reference Manual 69

BEFORE(n/0)Specifies that line spacing is desired after printing the report line. When this parm is omitted, Z-Writerdoes not advance the printer after printing the report line.

A numeric literal “n” specifies the number of line feeds to perform after printing the report line.

Note: in most cases, we recommend using only the AFTER parm to obtain any specialspacing you require.

EXAMPLES

PRINT EMPL-NUM AMOUNT(‘SALES|AMOUNT’ PIC’$$$,$$9.99’)

70 Z-Writer Reference Manual

READ Statement

PURPOSE

Attempts to read one record from an input file.

SYNTAX

DISCUSSION

Depending on the file type and the parms present on this statement, either a sequential or a direct(“keyed“) read will be attempted.

If the READ statement does not have a KEY parm, a sequential read is attempted. That attempts to readthe next record after the one previously read. (Or the first record in the file, if there were no previousread attempts.) Sequential reads are allowed for all file types.

Note: a program error will occur if you attempt to perform a sequential read when the file isnot “positioned” at any record. This can happen after an unsuccessful READ or POSITIONstatement. The file is correctly “positioned” 1) when the program starts execution (it ispositioned before the first record in the file), 2) after a successful keyed READ or POSITIONstatement, and 3) after a successful sequential read.

If the READ statement does have a KEY parm, a direct read is attempted. You may specify either a fullkey or a partial (“generic”) key. Keyed reads are allowed only to VSAM files defined as KSDS orRRDS. (The key for a RRDS file must be a 4-byte binary field.)

Note: after a successful keyed READ, you can follow it with one or more sequential READsto read successive records from that point in the file.

READ STATEMENT SYNTAX

READ filename[KEY(fieldname/’literal’)[GEN][KEQ/KGE]

Z-Writer Reference Manual 71

After a READ statement, you can check the result of the operation by examining the file’s #STATUS

built-in field. The table below shows its possible values after the operation.

After a successful read, the file’s record area contains the new record. The length of that record isavailable in the file’s #LENGTH built-in field. For RRDS files, the RRN of the record read is availablein the file’s #RRN built-in field.

PARMS

filenameSpecifies the name of the file to read. The file must have been previously defined using a FILEstatement. It must have been defined as either an INPUT or an UPDATE file.

[ KEY(fieldname/’literal’) ]Specifies the field (or literal) containing the key value of the record you want to read. You may specifya key value that is shorter than the VSAM file’s defined key length; in that case you must also specifythe GEN parm.

Note: no data conversion is performed on the key field. Byte-by-byte comparisons are usedto match the KEY parm with the key values stored in the file.

[ GEN ]Indicates that the KEY parm contains a “generic” key. A generic key is shorter than the full key lengthdefined for the file. Use this parm to read a record when you only want to match some leading portionof the key. The READ will return the first record with a key matching the generic portion of the key (ifKEQ specified), or the first record with a key matching or greater than the generic portion of the key (ifKGE specified.)

[ KEQ/KGE ]Specifies the key matching criteria desired:

� KEQ (“key equal”), the default, indicates that a record is considered a match if it’s key value(or partial key, if GEN specified) exactly matches the KEY parm.

� KGE (“key greater than or equal to”) indicates that a record is considered a match if it’s keyvalue (or partial key, if GEN specified) is greater than or equal to the KEY parm.

EXAMPLES

FILE SALES TYPE(ESDS)FILE EMPL TYPE(KSDS)...

#STATUS Built-In Field Values After a READ Statement

Y - file successfully readN - no record read. For sequential reads, this indicates EOF; for keyed reads, this indicates that no record that matched the key (or partial key) was found.

72 Z-Writer Reference Manual

READ SALESREAD EMPL KEY(‘040’)READ EMPL KEY(SALES.EMPL-NUM)READ EMPL KEY(SHORT-KEY) GEN KGEREAD EMPL KEY(‘00’) GENREAD EMPL

Z-Writer Reference Manual 73

REDEFINE Statement

PURPOSE

Used only within record descriptions and work area, this statement allows you to back up and redefinean earlier field.

SYNTAX

DISCUSSION

The field defined immediately after a REDEFINE statement will begin in the same byte of the recordas the field named on the REDEFINE statement. After that FLD statement. you may continue definingnew fields in that location, each beginning immediately after the previous field. Or you can jump backto the original location in the record (the location before the REDEFINE statement) with anENDREDEFINE statement.

PARMS

fIeldnameSpecifies the name of a previously defined field in the same record area (or work area). FLD statementsafter this REDEFINE will begin in the starting column of the named field. This parm is required.

EXAMPLE

FLD SALES-DATE 6REDEFINE SALES-DATEFLD SALES-DATE-YY 2FLD SALES-DATE-MM 2FLD SALES-DATE-DD 2FLD CUSTOMER 15FLD TELEPHONE N10REDEFINE TELEPHONEFLD AREA-CODE N3ENDREDEF

REDEFINE STATEMENT SYNTAX

REDEFINE fieldname

74 Z-Writer Reference Manual

FLD TAX N4.2

Z-Writer Reference Manual 75

RELEASE Statement

PURPOSE

Releases a record that has been read for update, without actually updating (or deleting) it.

SYNTAX

DISCUSSION

You are never required to use this statement. However, for performance reasons, you might haveoccasion to use it. The RELEASE statement releases a record that you have read from an “update” file,once you know that you will not need to delete or rewrite it. That releases VSAM’s “lock” on the recordso that other users can access it. The record’s data remains in the record area for your program tocontinue to use.

When you specify UPDATE on a FILE statement, the records read from that file are available for“update processing.” Each time a record is read, VSAM puts a lock on the record until you take one ofthe following actions:

� you update that record by executing a REWRITE statement to the same file (normally afterchanging the contents and/or length of the record)

� you delete that record by executing a DELREC statement to the same file

� you explicitly release the record by executing a RELEASE statement

� you read a new record from the same file (which releases the hold on the current record)

PARMS

filenameSpecifies the name of the file whose outstanding record should be released. The file must have beenpreviously defined as an UPDATE file (with a FILE statement). Also a record must have beensuccessfully read from that file, and not yet rewritten or deleted.

RELEASE STATEMENT SYNTAX

RELEASE filename

76 Z-Writer Reference Manual

EXAMPLE

FILE EMPL UPDATE TYPE(KSDS)...

READ EMPL /* READ FIRST RECORD FOR UPDATE */

DOWHILE EMPL.#STATUS = ‘Y’ IF EMPL.EMPL-NUM = ‘444’ DELREC EMPL /* DELETE RECORD FROM FILE */ ELSEIF EMPL.EMPL-NUM = ‘555’ MOVE ‘X’ TO EMPL.TEMPFLAG REWRITE EMPL /* UPDATE STATUS FIELD ON THIS RECORD */ ELSE RELEASE EMPL /* LEAVE RECORD UNCHANGED ON FILE. */ ENDIF

READ EMPL /* READ NEXT RECORD FOR UPDATE */ENDDO

Z-Writer Reference Manual 77

RETRIEVE Statement

PURPOSE

Retrieves one record from a table. When a record is “retrieved,” it is copied from the table’s internalstorage area to the record area defined immediately after the TABLE statement.

SYNTAX

DISCUSSION

Depending on the type of table and the parms present on this statement, either a sequential or a direct(“keyed“) retrieval will be attempted.

After the RETRIEVE statement, you can check the result of the operation by examining the table’s

#STATUS built-in field. The table below shows its possible values after the operation.

PARMS

tablenameSpecifies the name of the table to retrieve a record from. The table must have been previously definedusing a TABLE statement.

RETRIEVE STATEMENT SYNTAX

RETRIEVE tablename [ FIRST/NEXT/KEY(fieldname/’literal’)/ENTRY(n) ]

#STATUS Built-In Field Values After a RETRIEVE Statement

Y - file successfully retrieved. The table’s record area contains the new record.N - no record retrieved. For sequential retrievals, this indicates end-of-table; for retrievals by key or entry number, this indicates that no matching record was found (or that there was an error in the key/entry value). The table’s record area remains unchanged.

78 Z-Writer Reference Manual

FIRST / NEXT / KEY(fieldname / ‘literal’)/ENTRY(N)Specifies which record to retrieve. If this parm is omitted, the default is to retrieve the “next” record.Note that the KEY parm may only be specified for tables whose definition included the KEYCOL andKEYLEN parms.

The following table explains the meaning of each parm.

EXAMPLES

RETRIEVE MY-SEQ-TABLE FIRSTRETRIEVE MY-SEQ-TABLERETRIEVE MY-KEY-TABLE FIRSTRETRIEVE MY-KEY-TABLERETRIEVE MY-KEY-TABLE KEY(‘123’)RETRIEVE MY-KEY-TABLE KEY(WORKKEY)

TABLE RETRIEVAL OPTIONS

OPTION MEANING

FIRST

Retrieves the first record from the table. For keyed tables, this is the record with lowest key value. For sequential tables, this is the first record that was added to the table.

NEXT

Retrieves the next record from the table. That is the record after the previous record retrieved from the table. (Or the first record if there have been no prior retrievals.)

For keyed tables, this is the record with the next higher key value. For sequential tables, this is the record that was added after the previous record.

KEY(fieldname/’literal’) Allowed only for keyed files (that is, those defined with the KEYCOL and KEYLEN parm in the TABLE statement.)

Retrieves the record whose key field matches the KEY parm’s value.

If no matching record is found, the contents of the table’s record area is not changed, and the table’s #STATUS field is set to ‘N’.

Note: no data conversion is performed on the key field. Byte-by-byte comparisons are used to match the KEY parm with the keyvalues stored in the table.

ENTRY(n) Allowed only for non-keyed files (that is, those defined without the KEYCOL and KEYLEN parm in the TABLE statement.)

Retrieves a record according to its order of entry into the table. Thus ENTRY(1) would return the first record that was added to the table; ENTRY(2) would return the second record that was added to the table, and so on. And ENTRY(#COUNT) would return the latest record added to the table.

If no record is found for the entry specified, the contents of the table’s record area is not changed and the table’s #STATUS field is set to ‘N’.

Z-Writer Reference Manual 79

REUSE Statement

PURPOSE

Specifies that a file defined in an earlier report should also be defined for the current report.

SYNTAX

DISCUSSION

By specifying the REUSE statement, you can avoid retyping the FILE and FLD statements all overagain in the current report.

Note: the file will be closed at the end of the earlier report(s). When used in the current report,it will be opened anew.

PARMS

filenameSpecifies the name of a file defined in an earlier report.

REUSE STATEMENT SYNTAX

REUSE filename/tablename

80 Z-Writer Reference Manual

REWRITE Statement

PURPOSE

Rewrites the current contents of an “update” file’s record area to the file.

SYNTAX

DISCUSSION

When you specify UPDATE on a FILE statement, the records read from that file are available for“update processing.” Each time a record is read, VSAM puts a lock on the record until you take one ofthe following actions:

� you update that record by executing a REWRITE statement to the same file (normally afterchanging the contents and/or length of the record)

� you delete that record by executing a DELREC statement to the same file

� you explicitly release the record by executing a RELEASE statement

� you read a new record from the same file (which releases the hold on the current record)

After the REWRITE statement, you can check the result of the operation by examining the file’s

#STATUS built-in field. The table below shows its possible values after the operation.

REWRITE STATEMENT SYNTAX

REWRITE filename

#STATUS Built-In Field Values After a REWRITE Statement

Y - record successfully rewrittenN - record not rewritten.

Z-Writer Reference Manual 81

PARMS

filenameSpecifies the name of the file whose current record should be rewritten. The file must have beenpreviously defined as an UPDATE file. Also a record must have been successfully read from that file,and not yet deleted or released.

EXAMPLE

FILE EMPL UPDATE TYPE(KSDS)...

READ EMPL /* READ FIRST RECORD FOR UPDATE */

DOWHILE EMPL.#STATUS = ‘Y’ IF EMPL.EMPL-NUM = ‘444’ DELREC EMPL /* DELETE RECORD FROM FILE */ ELSEIF EMPL.EMPL-NUM = ‘555’ MOVE ‘X’ TO EMPL.TEMPFLAG REWRITE EMPL /* UPDATE STATUS FIELD ON THIS RECORD */ ELSE RELEASE EMPL /* LEAVE RECORD UNCHANGED ON FILE. */ ENDIF

READ EMPL /* READ NEXT RECORD FOR UPDATE */ENDDO

82 Z-Writer Reference Manual

SHOW Statement

PURPOSE

Prints a literal text, or the contents of a field in the control listing (not in the report). This statement isuseful when debugging new programs.

SYNTAX

DISCUSSION

Only a single field or literal may be specified on the SHOW statement. See the related SHOWHEXstatement if you need to see the contents of a field in hex format.

When a fieldname is specified, both the name of that field and its formatted contents are printed in thecontrol listing (SYSPRINT).

When a literal text is specified, just that text itself prints in the control listing.

PARMS

fieldname/’literal’Specifies a field or literal to show in the control listing.

EXAMPLE

SHOW ‘AT HEADING ROUTINE’SHOW LAST-NAME

SHOW STATEMENT SYNTAX

SHOW fieldname/’literal’

Z-Writer Reference Manual 83

SHOWHEX Statement

PURPOSE

Like the SHOW statement, this statement prints the contents of a field in the control listing (not in thereport). However this statement prints the raw contents of the field in character and hex format.

SYNTAX

DISCUSSION

Only a single field or literal maybe specified on the SHOWHEX statement.

When a fieldname is specified, Both the name of that field and its raw contents are printed in the controllisting (SYSPRINT).

When a literal text is specified, just that text itself prints in the control listing (in character and hexformat.)

PARMS

fieldname/’literal’Specifies a field or literal to show in the control listing.

EXAMPLE

SHOW ‘FOLLOWING AMOUNT IS CORRUPTED:’SHOWHEX AMOUNT

SHOWHEX STATEMENT SYNTAX

SHOWHEX fieldname

84 Z-Writer Reference Manual

SORT Statement

PURPOSE

This declaratory statement specifies that the named input file should be sorted before being read in theprogram.

SYNTAX

DISCUSSION

This statement is a declaratory, rather than executable, statement. Therefore its exact location in theprogram is not critical. However it is important that it appear before any statement that performs I/O onthe file. (That is, before any OPEN or READ statement to the file.) The SORT statement is often locatedafter the definition statements near the beginning of the executable statements.

When the SORT statement is used, Z-Writer presorts the whole file before performing any READs toit. Thus when the program reads records from the file, they will be read in sorted order. (The net effectis just the same as if you had sorted the input file in a separate, earlier job step.)

PARMS

filenameSpecifies the name of the file to sort. The file must have been previously defined as an INPUT file.(UPDATE and OUTPUT files may not be sorted.)

fieldname[(A/D)]Specifies a field by which the file will be sorted (a “sort field”).

By default, the file will be sorted into the field’s ascending sequence. You may specify D to sort intothe field’s descending sequence.

SORT STATEMENT SYNTAX

SORT filename USING fieldname[(A/D)] [fieldname[(A/D)]] ... [ #EQUALS ]

Z-Writer Reference Manual 85

You may specify as many sort fields as you like. The field specified first is the primary sort field; thenext field is the secondary sort field and so on.

#EQUALSThis optional, final parm indicates how to sort multiple records, all of whose sort fields contain the samevalue. When #EQUALS is specified as the last item on the statement, those duplicate-key records willremain in the same relative order as in the unsorted file. When this parm is not specified, the systemSort program will decide how to order such duplicate records.

EXAMPLE

SORT SALES USING REGION(D) CUSTOMER

86 Z-Writer Reference Manual

STOP Statement

PURPOSE

Halts execution of the program.

SYNTAX‘

DISCUSSION

You are not required to use a STOP statement in your program. Once control reaches the last statementin your program, the run will end. You can use this statement either to provide explicit documentation,or to stop the run from a location other than the end of your code.

EXAMPLE

STOP

STOP STATEMENT SYNTAX

STOP

Z-Writer Reference Manual 87

STORE Statement

PURPOSE

Stores a new record in a sequential or keyed table.

SYNTAX

DISCUSSION

The STORE statement copies the current contents of the table’s record area (the FLD statementsimmediately following the TABLE statement) into the table’s internal storage area. This is handled alittle differently for sequential and keyed tables.

For sequential tables, the record is always appended as a new record after all existing records in thetable.

Z-Writer maintains keyed tables (those defined with the KEYCOL and KEYLEN parms in the TABLEstatement) as balanced binary trees, for processing efficiency. The STORE statement causes the recordto be stored within the tree according to the value of its key. If a record already exists in the table withthe same key, the stored record is not changed and the table’s #STATUS field is set to ‘N’.

PARMS

tablenameSpecifies the name of the table to store a record in. The table must have been previously defined usinga TABLE statement.

STORE STATEMENT SYNTAX

STORE tablename

Alternate Spellings:

NOREPLACE - NOREPREPLACE - REP

88 Z-Writer Reference Manual

EXAMPLES

STORE MY-SEQ-TABLESTORE MY-KEY-TABLESTORE MY-KEY-TABLE NOREPLACE

Z-Writer Reference Manual 89

TABLE Statement

PURPOSE

Defines a table to Z-Writer.

SYNTAX

DISCUSSION

A table can be thought of as a virtual “in-memory file.” Z-Writer supports two types of tables.

� Sequential tables. Tables defined without the KEYCOL/KEYLEN parms are sequentialtables. When storing records in sequential tables, each record is simply appended to the endof the existing records. When retrieving records from a sequential table, the only option is tostart at the beginning of the table and read through it sequentially. Thus, a sequential table issimilar to an in-memory “flat file.”

� Keyed tables. Keyed tables are tables defined with the KEYCOL/KEYLEN parms. Z-Writermaintains keyed tables as “balanced binary trees.” These are very efficient to access and easyto process. When storing records in a keyed table, Z-Writer inserts them directly into thecorrect location based on their key value. Thus, one advantage of a binary table is that it isalways sorted in key order, even while you are adding new records to it. Therefore there is noneed to sort the table before doing a “binary search.” All retrievals from keyed tables areefficient binary retrievals. These table are easy to use since you can mix retrievals and storeswithout needing a sort command. All of the housekeeping associated with binary tables isautomatically handled for you.

The fields for the table must be defined immediately after the TABLE statement. Use FLD statementsto define the fields.

TABLE STATEMENT SYNTAX

TABLE TABLENAME [ KEYCOL(num) ] [ KEYLEN(num) ]

90 Z-Writer Reference Manual

Both types of table have some built-in fields available to examine. These are shown in the table below.

EXAMPLES

TABLE MY-SEQ-TABLETABLE MY-KEY-TABLE KEYCOL(1) KEYLEN(3)

Built-In Fields Available for Tables

FIELDNAME

TYPE & LENGTH

READ ONLY DESCRIPTION

#EOF1-byte

characterYes

Indicates whether an attempt was made to reatrieve a record past the last record in the table.

Y = the last operation was a RETRIEVE statement which raised the end of file condition

N = the last operation was not a RETRIEVE statement which raised the end of file condition

#STATUS1-byte character

Yes

Status of the most recent STORE/RETRIEVE statement.

(blank) = uninitialized (no operations have been performed on table yet)Y = last STORE/RETRIEVE operation was successfulN = last STORE/RETRIEVE operation was unsuccessful. Indicates missing record or end-of-table after RETRIEVE statements

#COUNT4-byte binary

Yes Number of entries in the table.

Z-Writer Reference Manual 91

TITLE Statement

PURPOSE

This is a declaratory statement that specifies one report title line will look like.

SYNTAX

DISCUSSION

TITLE statements simply consist of zero or more fieldnames and/or literal texts. Fieldnames indicatethat the contents of that field should appear in the title. Literal texts print as is in the title. Empty TITLEstatements are allowed and result in a blank title line. Optional parms after the fieldname or literal letyou customize the location and appearance of that item within the title line.

How Titles Are PrintedYou may have as many TITLE statements as you like. Each TITLE statement results in one title line at thetop of your report.

As a declaratory (rather than executable) statement, the exact location of your TITLE statements is notcritical. (They are often placed at the end of the program code.) Their relative order, however, isimportant. Title lines are printed in the same order in which they are found in the control statements.

Z-Writer performs a “page eject” before printing the first title line, which puts it at the top of a newpage. Before each remaining title lines, a single “line feed” is performed before printing. An extra blankline is also printed after the last title line. (This separates the titles from whatever follows -- columnheadings or report body.) You may use the SPACEBEFORE and SPACEAFTER parms on the TITLEstatements to change these defaults.

You may also use TITLE statements is to create column headings.

TITLE STATEMENT SYNTAX

TITLE: [ fieldname/’literal’[(parms)] ] [ fieldname/’literal’[(parms)] ] ... [SKIPBEFORE(n) ] [SKIPAFTER(n) ]

92 Z-Writer Reference Manual

PARMS

fieldname/’literal’[(parms)]Specifies one item to include in the title line. This can be either the name of a field whose contentsshould print in the title line, or a literal value to print in title.

Optionally, you can specify one or more parms in parentheses after the fieldname or literal. (There mustbe no space before the parm list.) The parms let you customize the location and appearance of an itemwithin the title line. The following table shows the parms that can be specified for each item. All areoptional and they may be specified in any order, separated by spaces and/or commas.

SKIPBEFORE(n/1)Specifies that special spacing is desired before printing this title line. By default, single spacing is usedfor all title lines (except the first one.)

A numeric literal “n” specifies the number of line feeds to perform before printing the report line. Forexample, a value of 2 in a TITLE statement would result in an extra blank line before the title line.

A value of 0 can be used to overprint the previous title line, if the printer hardware supports this. Thiscan be used to underline column headings, for example.

PARMS ALLOWED FOR ITEMS IN THE TITLE STATEMENT

SYNTAX DESCRIPTION EXAMPLE

nSpecifies an override width (in bytes) to use for this title item. When omitted, Z-Writer picks a default width to use.

TITLE DESCRIPTION(10)

+n

Means begin this item “n” bytes after the end of the previous item in the title. For example, you can specify +0 if no spaces are wanted after the previous item. (Z-Writer’s default is to leave 1 space between items in the title.)

TITLE ‘NAME=’ NAME(+0)

@n

@n means begin the data in column ”n” of the title. Columns do not include the carriage control character and are numbered starting with 1.

TITLE ‘JOB REPORT’(@40) ‘PAGE’(@125) #PAGENUM

LJ/CJ/RJ

Specifies how the contents of the item should be justified. The values mean left-justified, center-justified and right-justified, respectively

TITLE DEPT-NUM(LJ)

display-

format

You may specify the name of any of Z-Writer’s “display formats” that are valid for the data type of the item. This parm determines how the data is formatted in the title line. (The table on page 67 lists all of the display formats.)

When omitted, Z-Writer uses: 1), the display format from the FORMAT parm of the FLD statement, if any, or 2) a default display format.

TITLE AMOUNT(CURRENCY)

BIZ(Stands for “blank-if-zero”). Use this with a numeric field if you want its title are to be left completely blank for zero values.

TITLE ERROR-COUNT(BIZ)

Z-Writer Reference Manual 93

SKIPAFTER(0/n)Specifies that line spacing is desired after printing the title line. When this parm is omitted, Z-Writerdoes not advance the printer after printing most title lines. (It does advance one extra line after printingthe final title line, by default.)

A numeric literal “n” specifies the number of line feeds to perform after printing the report line.

Note: we recommend using this parm only for the last title line, to indicate spacing before thefirst report detail line.

EXAMPLES

PRINT EMPL-NUM AMOUNT(‘SALES|AMOUNT’ PIC’$$$,$$9.99’)

94 Z-Writer Reference Manual

TRACEOFF STATEMENT

PURPOSE

Turns program flow tracing off.

SYNTAX

DISCUSSION

Program flow tracing causes the programs statement to be printed (in the control listing) as they areexecuted. This feature can be useful in debugging new programs. Program flow tracing is off by default.

EXAMPLES

TRACEOFF

TRACEOFF STATEMENT SYNTAX

TRACEOFF

Z-Writer Reference Manual 95

TRACEON STATEMENT

PURPOSE

Turns program flow tracing on.

SYNTAX

DISCUSSION

Program flow tracing causes the programs statement to be printed (in the control listing) as they areexecuted. This feature can be useful in debugging new programs. Program flow tracing is off by default.

EXAMPLES

TRACETRACEON

TRACEON STATEMENT SYNTAX

TRACEON

Alternate Spellings:TRACEON - TRACE

96 Z-Writer Reference Manual

WHEN Statement

PURPOSE

The WHEN statement is used within a “case-structure”. The purpose of a case-structure is toconditionally execute (at most) one set of statements within the structure.

SYNTAX

DISCUSSION

The WHEN statement presents one set of values to compare to the test field (in the CASE statement.)It is followed by the “other statements” to be executed if a match is found among its values. A completediscussion of the “case-structure” can be found under the CASE statement on page 11.

CASE STRUCTURE SYNTAX

CASE fieldname

WHEN [NOT] value/range [value/range ...]other statements

WHEN [NOT] value/range [value/range ...]other statements...

ELSEother statements

ENDCASE

Z-Writer Reference Manual 97

WORKAREA Statement

PURPOSE

Allows you to define fields in a working storage.

SYNTAX

DISCUSSION

The WORKAREA statement has no parms. This statement should be immediately followed by one ormore FLD statements. These fields are not within any file or table record area. They may be used tostore values as needed by your program logic.

You may have as many WORKAREA statements as you like.

EXAMPLES

WORKAREAFLD COUNTER P3 INIT(0)WORKKEY 5REDEFINE WORKKEYWORKKEY-DEPT 1WORKKEY-SEQ N4

WORKAREA STATEMENT SYNTAX

WORKAREA

98 Z-Writer Reference Manual

WRITE Statement

PURPOSE

Writes a new record to an OUTPUT or UPDATE file.

SYNTAX

DISCUSSION

Before a WRITE, you must ensure that the file’s #LENGTH field contains the correct length of therecord being written.

For F/FB files, Z-Writer initializes #LENGTH one time to the file’s fixed record length (from the DCBor ACB at open time.). You should not need to change it.

But for V/VB files (including variable length VSAM files), Z-Writer initializes #LENGTH one time tothe maximum defined record length (from the DCB or ACB at open time.) You must change this if yourrecord has a different length.

After the WRITE statement, you can check the result of the operation by examining the file’s #STATUS

built-in field. The table below shows its possible values after the operation.

For SAM, ESDS and RRDS files, WRITE appends a new record to the end of the file. After a WRITEto an RRDS file, the RRN of the newly written record can be found in the file’s #RRN built-in field.

For KSDS files, WRITE attempts to add a new record to the file using the key value contained in thekey field in the file’s record area. An error will occur if the file already contains a record with the samekey value.

WRITE STATEMENT SYNTAX

WRITE filename

#STATUS Built-In Field Values After a WRITE Statement

Y - record successfully writtenN - record not written. This may indicate no space left in the file, or some other error.

Z-Writer Reference Manual 99

Note: do not use the WRITE statement to rewrite a record that has been read for update. Usethe REWRITE statement for that. You may perform WRITEs to an UPDATE file, but onlyfor adding new records to the file.

PARMS

filenameSpecifies the name of the file to write to. The file must have been previously defined as an OUTPUTor UPDATE file.

EXAMPLE

FILE EMPL UPDATE TYPE(KSDS)...

READ EMPL /* READ FIRST RECORD FOR UPDATE */

DOWHILE EMPL.#STATUS = ‘Y’ IF EMPL.EMPL-NUM = ‘444’ DELREC EMPL /* DELETE RECORD FROM FILE */ ELSEIF EMPL.EMPL-NUM = ‘555’ MOVE ‘X’ TO EMPL.TEMPFLAG REWRITE EMPL /* UPDATE STATUS FIELD ON THIS RECORD */ ELSE RELEASE EMPL /* LEAVE RECORD UNCHANGED ON FILE. */ ENDIF

READ EMPL /* READ NEXT RECORD FOR UPDATE */ENDDO

100 Z-Writer Reference Manual

Appendix A. Built-In Fields

Z-Writer has a number of "built–in" fields that are available for use. You may refer to these fieldsregardless of what input file(s) you use. Built–in fields are easily distinguished from most other fieldsbecause all built–in field names begin with the pound character (#).

The following table lists the Z-Writer built–in fields.detail. Unless otherwise noted, all of these fieldsare read-only -- they may not be modified by the program.

Z-WRITER BUILT-IN FIELDS

FIELD NAME DESCRIPTION

Character Built-In Fields

#JOBNAME Jobname under which Z-Writer is currently executing.

#DATE 8-byte system date (when program began execution) in MM/DD/YY format.

#DAYNAME 9-byte name of the current day of the week ("MONDAY")

#TIME

#TIME12

8-byte character field containing the system time (when program began execution) inAM /PM format (ex: "12:45 PM").

#TIME248-byte character field containing the system time (when program began execution) in24–hour format (ex: "13:45:59").

Numeric Built-In Fields

#PAGENUM

#PAGE

The current page number of the report. This field may be modified by the userprogram.

#RETCODE

The final value of this field is returned to the z/OS operating system at the end of Z-Writer’s execution. Z-Writer sets raises it when certain errors occur. This field may bemodified by the user program.

Z-Writer Reference Manual 101

Appendix B. Built-In Functions

A number of built–in functions are available for use within computational expressions. Computational

expressions are used in COMPUTE statements. These built–in functions are listed on the following pages,according to the type of data returned by the function (character or numeric).

The arguments to a function will not necessarily be of the same data type as the result. The data typeexpected for each argument is indicated in a function’s syntax. For example, "char" means that acharacter argument is expected. Except where otherwise indicated, an argument may be any of thefollowing:

� a literal value

� the name of a field from any file record area or workarea

� a computational expression (which may itself involve other built–in functions)

Separate the arguments with blanks and/or commas.

The following table lists the Z-Writer built–in functions. After the table, each of the functions isdiscussed in more detail.

Z-WRITER BUILT-IN FUNCTIONS

FUNCTION DESCRIPTION

Functions that Return a Character Value

#AND returns the result of ANDing two character strings

#ASCII returns the ASCII equivalent of an EBCDIC string

#COMPRESS concatenates multiple fields and compresses out extra blanks

#EBCDIC returns the EBCDIC equivalent of an ASCII string

#FORMAT converts a numeric, date or time value to a character value

#LCASE returns the lower–case value of a character string

#LEFT returns the leftmost n characters of a character string

#OR returns the result of ORing two character strings

#PARSE returns one individual word parsed out of a character string

#RIGHT returns the rightmost n characters of a character string

#SUBSTR returns a substring from a character string

#TRANSLATEtranslates one set of characters within a character string to another set ofcharacters

#UCASE returns the upper–case value of a character string

#XOR returns the result of XORing two character strings

102 Z-Writer Reference Manual

Built-In Functions

.Built-In Functions

Functions that Return a Character Value

#AND(char1,char2)

Performs the logical AND operation on the two character arguments and returns the result. (An AND

operation results in a 1 bit if the corresponding bit of both operands is a 1: otherwise it results in a 0 bit.)If the two operands are not the same size, the shorter operand will be right-padded with hex zeros beforeperforming the AND operation. The size of the result is the size of the larger operand.

Example: COMPUTE A = #AND(X'01FF',X'035E') results in A=X'015E'

Here is an example of using the #AND built–in function to change a packed numeric field’s sign fromthe common, but non-standard, F to the standard C. For example, assume that PACKED-NUMBER is a 5-byte packed field that has an F in the zone portion of its last byte (X’000000123F’)

Example: PACKED–NUMBER = #AND(PACKED-NUMBER,X'FFFFFFFFFC'

results in PACKED-NUMBER = X'000000123C'

#ASCII(char)

Returns the ASCII equivalent of the EBCDIC character argument. The size of the value returned by thisfunction is the size of the character argument.

Example: A = #ASCII(X’F1F2F3') results in A=X’313233'

Note: The three characters "123" are represented with X’F1F2F3’ in EBCDIC and with X’313233’ inASCII.

#YEAR returns the 4–byte year pertaining to a given date

Functions that Return a Numeric Value

#ABS returns the absolute value of a number

#INDEX returns the starting column of a substring

#INT returns the integer portion of a number

#MAKENUM converts a character, date or time value to a numeric value

#MAX returns the greater of two or more values

#MIN returns the smaller of two or more values

#MOD returns the remainder left after division ("modulus")

#NUMWORDS returns the number of words within a character string

#ROUND returns the rounded value of a number

#SQRT returns the square root of a number

Z-WRITER BUILT-IN FUNCTIONS (CONTINUED)

FUNCTION DESCRIPTION

Z-Writer Reference Manual 103

#COMPRESS([n,] char [,n] ,char ...)

Concatenates the char arguments (any number), but compresses out all but 1 of the blanks between eachargument The optional override number "n" specifies how many blanks to leave between the two chararguments (if a number other than 1 is desired). You may specify 0 if no blanks are wanted betweentwo arguments. The size of the returned string is the sum of the sizes of all arguments, plus spacingbytes.

Example: COMPUTE NAME=#COMPRESS(LAST–NAME, 0, "," , FIRST–NAME)

might result in NAME="BAKER, VIVIAN "

COMPUTE ADDR=#COMPRESS(CITY, 0, ",", STATE ZIP–CODE)

might result in ADDR="DALLAS, TX 75230 "

Note: The #COMPRESS function does not remove any leading blanks that might be in thecharacter arguments. If your arguments could contain leading (as well as trailing) blanks, youshould first left-justify those arguments to remove the leading blanks. Like this:

Example: COMPUTE LJ-LAST-NAME = #FORMAT(LAST-NAME, LEFT)COMPUTE LJ-FIRST-NAME = #FORMAT(FIRST-NAME, LEFT)COMPUTE NAME = #COMPRESS(LJ-LAST-NAME, 0 "," LJ-FIRST-NAME)

#EBCDIC(char)

Returns the EBCDIC equivalent of the ASCII character argument. The size of the value returned by thisfunction is the size of the character argument.

Example: COMPUTE A = #EBCDIC(X’313233') results in A=X’F1F2F3'

Note: The three characters "123" are represented with X’F1F2F3’ in EBCDIC and with X’313233’ inASCII.

#FORMAT(fieldname [,display–format] [,width] [,BIZ] [,LEFT/CENTER/RIGHT] )

Returns a character string containing the contents of the field (any data type) after formatting it asspecified by the other parms. Only fieldname is required. It must be the first argument. It must also bethe name of an actual field-- expressions are not allowed for this argument. The other parms may appearin any combination and in any order. The display format, if specified, must be valid for the specifiedfield's data type. For an explanation of each of the parms, see the syntax of the PRINT statement, whichuses the same parms.

Example: CCOMPUTE A = #FORMAT(TOTAL–SALES) might result in A=' 92,125.89'

COMPUTE A = #FORMAT(TOTAL–SALES,10) might result in A=' 92,125.89'

COMPUTE A = #FORMAT(TELEPHONE, PIC'(999) 999–9999'))

might result in A='(415) 555–1209'

COMPUTE A = #FORMAT(TOTAL–SALES, BIZ)

results in A=' 92,125.89' when TOTAL–SALES = 92,125.89 or A=' ' when TOTAL–SALES = 0

#LCASE(char)

Returns the character argument's value after translating any of its upper–case alphabetic characters tothe corresponding lower–case character. All other printable characters remain unchanged. (The effectof this function on non-printable characters is not defined.) The size of the value returned by thisfunction is the size of the character argument.

104 Z-Writer Reference Manual

Example: (Assume that DESC = "THIS IS A DESCRIPTION")COMPUTE A = #LCASE(DESC) results in A="this is a description".

#LEFT(char,num1)

Returns a substring of the char argument, starting with the first column, for a length of "num1" bytes.Num1 may be either a literal value or a numeric expression. When num1 is a literal value, the size ofthe value returned by this function is num1. When num1 is an expression, the size returned by thisfunction is the size of the character argument (since that is the maximum possible size of the result).

Example: COMPUTE A = #LEFT('ABCDEFG',4) results in A='ABCD'

#OR(char1,char2)

Performs the logical OR operation on the two character arguments and returns the result. (An OR

operation results in a 1 bit if the corresponding bit of either (or both) operands is a 1: otherwise it resultsin a 0 bit.) If the two operands are not the same size, the shorter operand will be right–padded with hexzeros before performing the OR operation. The size of the result is the size of the larger operand.

Example: COMPUTE A = #OR(X'8024',X'0756') results in A=X'8776'

Note: you can use the #OR function to create packed numeric fields that have a sign of F

(rather than the standard sign of C). For example, assume that AMOUNT has a value of 123 (inany format).

Example: COMPUTE PACKED = #FORMAT(AMOUNT,PACKED,2)

COMPUTE PACKED-F = #OR(PACKED,X'000F') results in PACKED = X'123C' and PACKED–F = X'123F'

#PARSE(char,num)

Returns a single word parsed from the character argument. Internally, the character argument is firstparsed into individual words, each delimited by one or more spaces. The numeric argument specifieswhich of the parsed words should be returned by the function. A numeric argument of 1 indicates thatthe first word should be returned; an argument of 2 means return the second word, etc. Negativenumbers may also be used. A negative number indicates the word to return counting backwards fromthe last word parsed. A numeric argument of –1 means return the last word parsed; an argument of –2means return the second to last word, etc. If the word indicated by the numeric argument doesn't exist,blanks are returned by this function. The size of the value returned by this function is the size of thecharacter argument.

Note: You can use the related #NUMWORDS built–in function to find out how many words acharacter string contains.

Example: (Assume that DESC = "THIS IS A DESCRIPTION")COMPUTE A = #PARSE(DESC,1) results in A="THIS "COMPUTE A = #PARSE(DESC,2) results in A="IS "COMPUTE A = #PARSE(DESC,–1) results in A="DESCRIPTION "COMPUTE A = #PARSE(DESC,5) results in A=" "

Note: To parse a text using a delimiter other than blanks, try using the #TRANSLATE built-infunction to first translate the desired delimiter characters into blanks. For example, you couldparse an IP address (which is delimited with dots) this way:

Example: COMPUTE A = #PARSE(#TRANSLATE(IPADDR,"."," "),2)

Z-Writer Reference Manual 105

Assume that IPADDR = "12.345.67.8". The above statement results in A = "345 "

Note that using #TRANSLATE with #PARSE may not work if the original string contains multiple

consecutive delimiters.

#RIGHT(char,num1)

Returns a substring of the char argument consisting of the last "num1" bytes. Num1 may be either aliteral value or a numeric expression. When num1 is a literal value, the size of the value returned by thisfunction is num1. When num1 is an expression, the size returned by this function is the size of thecharacter argument (since that is the maximum possible size of the result).

Example: COMPUTE A = #RIGHT('ABCDEFG',4) results in A='DEFG'

#SUBSTR(char,num1,num2)

Returns a substring of the char argument, starting at column "num1" for a length of "num2" bytes.Num1 and num2 may be literal values or numeric expressions. When num2 is a literal value, the sizeof the value returned by this function is num2. When num2 is an expression, the size returned by thisfunction is the size of the character argument (since that is the maximum possible size of the result).

Example: COMPUTE A = #SUBSTR('ABCDEFG',2,3) results in A='BCD'

#TRANSLATE(char1,char2,char3)

Returns the char1 string after translating any of its characters found in the char2 argument into thecorresponding character of the char3 argument. (Translated characters in the char1 argument are not

then re–evaluated for additional translation.) The size of the value returned by this function is the sizeof the char1 argument.

Example: (Assume that DESC = "THIS IS A DESCRIPTION")COMPUTE A = #TRANSLATE(DESC,"TA","XY") would result in A="XHIS IS Y DESCRIPXION".

Note: the char2 and char3 arguments must be character or hex literals.

#UCASE(char)

Returns the character argument's value after translating any of its lower–case alphabetic characters tothe corresponding upper–case character. All other printable characters remain unchanged. (The effectof this function on non-printable characters is not defined.) The size of the value returned by thisfunction is the size of the character argument.

Example: (Assume that NAME = "Smith ")COMPUTE SORT–NAME = #UCASE(NAME) results in SORT–NAME = "SMITH "

Note: This function may be useful when sorting a report on a field that contains mixed–case text.For example, in order to ensure that the names "SMITH", "Smith", and "smith" all sort together, youcould compute a new field that contains the upper–case value of the mixed–case name field. Bysorting on this new upper–case field, rather than the original mixed–case field, the three namesabove would sort together. Of course, you can still choose to print the original, mixed–casenames in your report, even though sorting on the upper–case names.

#XOR(char1,char2)

Performs the logical XOR operation on the two character arguments and returns the result. (An XOR

operation results in a 1 bit if the corresponding bit of either (but not both) operands is a 1: otherwise it

106 Z-Writer Reference Manual

results in a 0 bit.) If the two operands are not the same size, the shorter operand will be right-paddedwith hex zeros before performing the XOR operation. The size of the result is the size of the largeroperand.

Example: COMPUTE A = #XOR(X'5766',X'5744') results in A=X'0022'

Functions that Return a Character Value

Functions that Return a Numeric Value

#ABS(num)

Returns the absolute value of the numeric argument.

Example: COMPUTE A = #ABS(–4) results in A= 4

#INDEX(char1,char2)

If the second argument appears somewhere within the first argument, #INDEX returns the byte numberin char1 where the char2 text begins. If char1 does not contain char2, #INDEX returns zero.

Example: COMPUTE A = #INDEX('ABCDEF', 'CDE') results in A=3

#INT(num)

Returns the integer portion of the numeric argument. The argument’s decimal digits, if any, are simplydropped, regardless of the sign of the argument.

Example: COMPUTE A = #INT(12.345) results in A= 12COMPUTE A = #INT(–12.345) results in A= –12

#MAKENUM(char)

Converts the string of numeric characters into a numeric value. No decimal point, commas, or any othernon–numeric character is allowed in the string. The only exception is that leading blanks are allowed.An all–blank string returns the value zero.

Example: COMPUTE A = #MAKENUM(' 125') results in A=125

#MAX(num1,num2,num3,...)

Returns the largest of the numeric arguments. Any number of arguments is allowed.

Example: COMPUTE A = #MAX(12, 25, –3) results in A=25

#MIN(num1,num2,num3,...)

Returns the smallest of the numeric arguments. Any number of arguments is allowed.

Example: COMPUTE A = #MIN(12, 25, –3) results in A=–3

#MOD(num1,num2)

Returns the remainder left when the first argument is divided by the second argument.

Example: COMPUTE A = #MOD(45, 4) results in A= 1COMPUTE A = #MOD(–45, 4) results in A= –1COMPUTE A = #MOD(1.5, .2) results in A= .1

Z-Writer Reference Manual 107

#NUMWORDS(char)

Returns the number of words found within the character argument. The words are parsed in the mannerdescribed under the #PARSE built–in function.

Example: (Assume that DESC = "THIS IS A DESCRIPTION")COMPUTE A = #NUMWORDS(DESC) results in A = 4.

Note: This function may be useful when you want to assign a value to a computed fielddifferently depending on how many, if any, words are in some other field. For example, thefollowing example assigns the second word from the DESC field to the result. However, if theDESC field contains only 1 (or no) words, the text "*NONE*" is assigned instead:

Example: COMPUTE A = WHEN(#NUMWORDS(DESC) >= 2) ASSIGN(#PARSE(DESC,2)) ELSE ASSIGN("*NONE*")

#ROUND(num1,num2)

Returns the first numeric argument, rounded to the precision specified by the second numeric argument.Num2 is the number of decimal places that num1 should be rounded to. Rounding of negative numbersis performed as if they were positive. Num2 must be a literal integer (not an expression). The number

of decimal digits returned by this function is the same as the number of decimal digits in the num1argument.

Num2 can also be a negative number. Use this feature to round to a digit position on the left side of thedecimal point. Use -1 to round to tens, -2 to round to hundreds, and so on.

Example: COMPUTE A = #ROUND(12345.678, 2) results in A= 12345.680COMPUTE A = #ROUND(–12345.678, 2) results in A=–12345.680COMPUTE A = #ROUND(12345.678, 0) results in A= 12346.000COMPUTE A = #ROUND(12345.678, –2) results in A= 12300.000

108 Z-Writer Reference Manual

Appendix C. Syntax of PICTURE Display Formats

A PICTURE is a special display format that describes how a numeric value should be displayed in areport. The PICTURE display format consists of the word PICTURE (or an abbreviation, such as PIC)immediately followed by text enclosed in either apostrophes or quotation marks. (Do not put a spacebefore the apostrophe or quotation mark.) For example:

PICTURE’text’PIC’text’

The characters making up the text give a "picture" of how the formatted result should look. The PICTURE

specifies such thing as:

� the size of the formatted output (that is, how many characters it will occupy in a print line)

� whether leading zeros should be displayed or suppressed

� whether commas (or some other character) will be used to separate the thousands, themillions, etc.

� whether a floating dollar sign should appear in the result

� where the minus sign should appear, for negative numbers

� where (and whether) a plus sign should be displayed for positive numbers

� how many decimal digits should print

� any literal characters that should be included in the formatted result

� whether automatic scaling of the number is wanted (to allow a wide array of values to fit intoa small column)

Examples of PICTUREs

Z-Writer’s PICTUREs are very similar to COBOL’s PICTURE clause, in case you are familiar with those. Ifyou haven’t worked with PICTUREs before, the best way to learn about them is probably to look at someexamples. The following examples show the format produced by various PICTUREs. Pick a result that issimilar to what you want, and use that PICTURE as a guide. Adjust the number of digit symbols in yourPICTURE according to the size of the numbers that you will be printing.

In the table below, a sample positive value (1,234.56) and a sample negative value (-98,765.4) are usedto demonstrate each PICTURE.

EXAMPLES OF PICTURES

PICTURE

FORMATTED

POSITIVE VALUE

FORMATTED

NEGATIVE VALUE

PIC’999999999’ 000001235 ****S****

PIC’999999.9’ 001234.6 ****S***

PIC’999999.99’ 001234.56 ****S****

Z-Writer Reference Manual 109

Note: The first several examples above resulted in size error indicators (***S***) for the negativevalue. That is because the PICTURE did not have a place where the minus sign could be displayed.Since leading zero suppression was not used, there were no leading blanks in which to place aminus sign. If your numbers will include negative values, do not use all 9’s in your PICTURE. Addat least one leading Z or – to the PICTURE.

Below are two additional examples that illustrate special purpose PICTUREs. Notice that when literal textis used heavily, you should normally use "9" as your digit symbol. If you want to display a literalcharacter before the first numeric digit (as in the telephone number example below), you must use "9"for all of your digit symbols.

PICTUREs can be used anywhere that a numeric display format is allowed. Following are a few examplesof how PICTUREs can be used in various control statements:

FLD AMOUNT P5.2 FORMAT(PIC’$$$,$$9’)PRINT EMPL–NAME TOTAL–SALES(PIC’ZZZ,ZZZ,ZZ9.99–’)TITLE ’TELEPHONE DIRECTORY ––’ TELEPHONE(PIC’(999) 999–9999’)

PIC’999999V99’ 00123456 ****S***

PIC’ZZZZZ9.99’ 1234.56 –98765.40

PIC’ZZZZZ9V99’ 123456 –9876540

PIC’ZZZ,ZZ9.99’ 1,234.56 –98,765.40

PIC’–––,––9.99’ 1,234.56 –98,765.40

PIC’+++,++9.99’ +1,234.56 –98,765.40

PIC’ZZZ,ZZ9.99–’ 1,234.56 98,765.40–

PIC’ZZZ,ZZ9.99+’ 1,234.56+ 98,765.40–

PIC’$$,$$$,$$9.99’ $1,234.56 –$98,765.40

PIC’ZZZ.ZZ9V,99’ 1.234,56 –98.765,40

PIC’ZZZ ZZ9V,99’ 1 234,56 –98 765,40

PIC’ZZZ.ZZ9V,99 DM’ 1.234,56 DM –98.765,40 DM

PIC’ZZZZZ9.99%’ 1234.56% –98765.40%

ADDITIONAL PICTURE EXAMPLES

PICTURE UNFORMATTED VALUE FORMATTED VALUE

PIC’(999) 999–9999’ 1234567890 (123) 456–7890

PIC’999–99–9999’ 123456789 123–45–6789

EXAMPLES OF PICTURES (CONTINUED)

PICTURE

FORMATTED

POSITIVE VALUE

FORMATTED

NEGATIVE VALUE

110 Z-Writer Reference Manual

How PICTUREs Work

This section explains in more detail exactly how PICTUREs are processed.

When a numeric value is being formatted according to a PICTURE, the following process takes place.The PICTURE is evaluated one character at a time, from left to right. Each character in the PICTURE iseither:

� a symbol that represents one potential digit of the numeric value

� a literal character that, under certain conditions, will be moved into the result

The character 9 in a PICTURE always represents a digit from the numeric value. It will be replaced bythe appropriate digit of the number, even if that digit is a leading zero.

If you want to suppress leading zeros in your result, use one of the following characters to representleading digits in your PICTURE: Z, $, + or –. When one of these characters appears in the PICTURE beforethe first 9, that character becomes the leading zero suppression symbol for the PICTURE. Eachoccurrence of that symbol will be replaced by the appropriate digit of the number as long as that digit

is not a leading zero. If the digit is a leading zero, then a blank will appear in that position of the result.

Use the $ character for the leading digits in your PICTURE if you want a floating dollar sign to be placedjust before the first significant digit in the result.

Use the + character for the leading digits in your PICTURE if you want a floating sign to be placed justbefore the first significant digit in the result. A plus sign is used for positive numbers; a minus sign isused for negative numbers; no sign is used if the number is zero.

Use the – character for the leading digits in your PICTURE if you want a floating minus sign to be placedjust before the first significant digit in the result (for negative values). Positive and zero values will haveno sign character.

When the letter Z is used for the leading digits in your PICTURE, and no trailing sign symbol appears

in the PICTURE, a floating minus sign is placed before the first significant digit in the result (for negativevalues).

Use a + character as the last byte in your PICTURE if you want a trailing sign (either plus or minus) tobe placed in that position of the result.

Use a – character as the last byte in your PICTURE if you only want a trailing minus sign to be placedin that position of the result (for negative values).

The letter V has a special meaning within a PICTURE. It shows where an "understood decimal point" islocated. A PICTURE may contain only one V symbol. The V symbol does not take up a byte in theformatted output. (Thus, the result of PIC’99V9’ would be just 3 bytes long, not 4.) If a V is present in thePICTURE, all decimal points (.) in the PICTURE are treated as literals and are not used in determiningwhere the decimal digits appear in the result.

The decimal point (.) is treated specially within a PICTURE. If the PICTURE contains a V symbol, alldecimal points within the PICTURE are just treated as literals. (Thus, the two decimal points inPIC’ZZZ.ZZZ.ZZ9V9’ are treated as regular literals.) If no V symbol appears within the PICTURE, a singledecimal point is allowed within the PICTURE. It shows where an "explicit decimal point" is to be locatedin the result.

Z-Writer Reference Manual 111

The number sign (#) and the at sign (@) are used in scaled pictures (page 113) to show where to putthe abbreviation for the scale used (K, M, G, etc.).

All other characters are treated as literals. Literals are moved into the result just as they appear in thePICTURE, with one exception. Any literal that appears before the last zero suppression symbol in aPICTURE is blanked out if zero suppression is still in effect at that point. Such literals are only moved tothe result if one or more non–zero digits have already been moved to the result. (Thus, the commaliterals in PIC’ZZZ,ZZZ,ZZ9.99’ are blanked out until after the first digit appears in the result.) Also, trailing

literals are always moved to the result (even if no non-zero digits were moved.) Trailing literals arethose that appear after all of the numeric positions in a PICTURE. They are usually currency indicators(PIC’ZZ9.99 USD’) or percentage signs (PIC’ZZ9.9%’).

Note: In PICTUREs with no zero suppression symbols (such as PIC’(999) 999–9999’), all literals aremoved to the result.

The following table summarizes the meaning of each character that can appear in a PICTURE.

Note: A PICTURE may contain symbols representing no more than 31 digits. However, the entirePICTURE text (including literal characters) can be larger than 31 characters.

.

MEANING OF SYMBOLS WITHIN A PICTURE

SYMBOL MEANING

9Replace this character with a digit from the numeric value, even if thatdigit is a leading zero.

Z

When used as the leading zero suppression symbol.(1) Replace thischaracter with a digit from the numeric value, with the followingexception: leading zeros will appear as blanks. The position before thefirst non–suppressed digit will contain a minus sign for negativenumbers (unless the PICTURE contains an explicit trailing plus or minussign).

$

When used as the leading zero suppression symbol.(1) Replace thischaracter with a digit from the numeric value, with the followingexception: leading zeros will appear as blanks. The position before thefirst non–suppressed digit will contain a dollar sign. For negativenumbers, a minus sign will appear just before the floating dollar sign(unless the PICTURE contains an explicit trailing plus or minus sign).

When used as the leading zero suppression symbol.(1) Replace thischaracter with a digit from the numeric value, with the followingexception: leading zeros will appear as blanks. The position before thefirst non–suppressed digit will contain a minus sign for negativenumbers.

112 Z-Writer Reference Manual

+

When used as the leading zero suppression symbol.(1) Replace thischaracter with a digit from the numeric value, with the followingexception: leading zeros will appear as blanks. The position before thefirst non–suppressed digit will contain: a plus sign for positive numbers;a minus sign for negative numbers; a blank if the number is zero.

Minus sign, as the last character in a picture. Specifies that a minus signshould appear in that position if the number is negative. Otherwise, ablank will appear in that position.

+

Plus sign, as the last character in a picture. Specifies that: a plus signshould appear in that position if the number is positive; a minus signshould appear in that position if the number is negative; a blank shouldappear in that position if the number is zero.

V

Understood decimal point. This character indicates where theunderstood decimal point exists within a picture. However, no actualdecimal point will appear there. This PICTURE symbol does not affect thesize of the formatted result. When this symbol is used, any decimalpoints (.) in the PICTURE are treated as literals.

.

When used as an explicit decimal point. When a PICTURE does notcontain a V, this becomes the explicit decimal point. It is displayed as is,unless "leading zero suppression" is still in effect. In that case, a blankwill appear in its place.

#

Indicates that the numeric value should be scaled as necessary to fitwithin the PICTURE. Base-10 scaling (division by factors of 1000) isdesired. The "@" symbol also indicates where to put the scaleabbreviation (K, M, G, etc.).

@

Indicates that the numeric value should be scaled as necessary to fitwithin the PICTURE. Base-2 scaling (division by factors of 1024) isdesired. The "?" symbol also indicates where to put the scaleabbreviation (K, M, G, etc.).

other

Any characters other than those listed above are considered literal

characters within a picture. These characters will appear in theformatted result just as they are, unless "leading zero suppression" isstill in effect. In that case, blanks will appear in their place. Trailingliterals (any literal after the last digit position) are always formatted intothe result.

Notes:(1) the first Z, $, + or – character that appears in a picture becomes the "zero

suppression symbol" for that picture. Once the zero suppression symbol has beendetermined for a picture, the other three characters in that set are just treated asliterals.

MEANING OF SYMBOLS WITHIN A PICTURE (CONTINUED)

SYMBOL MEANING

Z-Writer Reference Manual 113

How PICTUREs WorkExamples of PICTUREs

Scaling Numbers with PICTUREs

Z-Writer PICTUREs also have a unique “scaling” option that you won’t find in other languages. SuchPICTURES automatically scale the number being formatted. Scaling means to round the number tothousands, millions, etc. as necessary to make it fit within the PICTURE. The appropriate abbreviation(K, M, G, etc.) indicates what scale the number is shown in.

Scaled PICTUREs allow you to use less space in a report line while still showing approximate values forvery large numbers. Look at these two columns of data:

SALES SALES

26 26

48,712 49 K

5,862,131,092 5,862 M

The first column, while showing the exact value of each number, uses up 13 bytes of the report line(even more if you have to allow room for totals). The second column shows scaled values for the samenumbers and only uses 7 bytes. (And the total would also fit in 7 bytes.)

Here is the COLUMNS statement used to format the above columns:

Example: OPTION: SCALEPICCOLUMNS: SALES(13) SALES(PIC’Z,ZZ9 @’)

The "#" in the PICTURE indicates that base-10 scaling (division by factors of 1000) is wanted for thatcolumn. (Base-10 scaling is normally used with business and financial data.) The "#" symbol alsoindicates just where to place the scale abbreviation (K, M, G, etc.).

Scaled PICTUREs can also include decimal digits, if you like:

Example: OPTION: SCALEPICCOLUMNS: FILESIZE(13) FILESIZE(PIC’ZZ9.9 @’)

The above statements result in the following columns.

SALES SALES

26 26.0

48,712 48.7 K

5,862,131,092 5.9 M

You can also request base-2 scaling (division by factors of 1024, or 2 to the 10th power). This type ofscaling is often used with data related to computer systems. To specify base-2 scaling, use the "?"scaling symbol instead of "@". If you also add a literal "B" to the PICTURE, you will end up with theabbreviations KB, MB, GB, etc. in the column.

Example: OPTION: SCALEPICCOLUMNS: SALES(13) SALES(PIC’Z,ZZ9 ?B’)

The above statements result in the following columns.

FILESIZE FILESIZE

26 26 B

48,712 48 KB

5,862,131,092 5,591 MB

114 Z-Writer Reference Manual

Note: If the field you are scaling can contain negative values, be sure to begin the PICTURE

with a minus sign, a space or an "extra" Z. If you fail to this, you won’t get a size error (***S***)as with regular PICTUREs. But the negative number will have to be scaled down to apotentially misleading degree. Sometimes all the way down to 0.

Take, for example, this PICTURE which has no extra byte for a minus sign: PIC’ZZ9#. The number100,000,000 would format normally as "100M". But the number –100,000,000 appears,surprisingly (at first glance), as " 0G". Z-Writer can’t show "–100M" in the 4-byte PICTURE. So ithas to scale the number down further to –0.1 billion. Rounding that to a whole number (to matchthe PICTURE) gives 0 billion. That does fit in the PICTURE (" 0G") but is not very useful and couldbe misleading. Using the correct PIC’–ZZ9@’ would give the results you expect for both positiveand negative numbers: " 100M" and "–100M".

Note: in most cases, you will want at least 3 digit positions in scaled PICTUREs. Otherwise,you can have a similar problem to the one described above (of having your number roundeddown to meaninglessness) -- even when all values shown will be positive. Take for example,the following PICTURE with only 2 digits positions: PIC’Z9#’. The positive number 100,000,000can only be shown as " 0G" in this small PICTURE.

Note: if you want to use the special scaling symbols "#" or "@" as literals in your PICTURE,specify OPTION NOSCALEPIC. That option disables scaled pictures and those symbols willjust be treated as any other literal text in the PICTURE.