You are on page 1of 5

Output specifications describe the record and the format of fields in a program-described output file and when the

record is to be written. Output specifications are optional for an externally described file. If MAIN or NOMAIN is coded on a control specification, only exception output can be done. Output specifications are not used for all of the files in your program. For some files, you must code data structures in the result field of your output and update operatons. The following files in your program do not use Output specifications:

Files defined in subprocedures Files defined with the QUALIFIED keyword Files defined with the TEMPLATE keyword Files defined with the LIKEFILE keyword

Output specifications can be divided into two categories: record identification and control (positions 7 through 51), and field description and control (positions 21 through 80). Detailed information for each category of output specifications is given in:

Entries for program-described files Entries for externally described files

Program Described Files

Position 6 (Form Type) : An O must appear in position 6 to identify this line as an output specifications statement.

Record Identification and Control Entries

Positions 7-16 (File Name) Positions 16-18 (Program-described Logical Relationship) Position 17 (Type Program-Described File) Positions 18-20 (Record Addition/Deletion) Position 18 (Fetch Overflow/Release)

Fetch Overflow Release

Positions 21-29 (File Record ID Indicators) Positions 30-39 (EXCEPT Name) Positions 40-51 (Space and Skip) Positions 40-42 (Space Before) Positions 43-45 (Space After) Positions 46-48 (Skip Before) Positions 49-51 (Skip After)

Entries in positions 7 through 51 identify the output records that make up the files, provide the correct spacing on printed reports, and determine under what conditions the records are to be written.

Field Description and Control Entries These entries determine under what conditions and in what format fields of a record are to be written. Each field is described on a separate line. Field description and control information for a field begins on the line following the record identification line.

Positions 21-29 (File Field Description Indicators) Positions 30-43 (Field Name)

Field Names, Blanks, Tables and Arrays PAGE, PAGE1-PAGE7 *PLACE User Date Reserved Words *IN, *INxx, *IN(xx)

Position 44 (Edit Codes) Position 45 (Blank After) Positions 47-51 (End Position) Position 52 (Data Format) Positions 53-80 (Constant, Edit Word, Data Attributes, Format Name)

Constants Edit Words Record Format Name

Sample O Spec Program:

*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 OQPRINT O O O O O O O O O O O E Headings E *DATE Headings PAGE E Headings 2 2

8 'PAGE' 13 50 'WEEKLY SALES REPORT' 64 'DATE' Y 1 7 'SLSPSN.' 48 'DATE OF' 77 'SALE' 2 3 'NO.' 75

O O O O O O O O O O E Detail

21 'NAME' 46 'SALE' 61 'ITEM SOLD' 77 'PRICE' 1 4 37 Y 48 67 79

SlspNumber SlspName DateOfSale ItemNumber Price 1


Externally Described

Positions 7-16 (Record Name) Position 17 (Type Externally Described File) Position 18 (Release) Positions 18-20 (Record Addition) Positions 21-29 (External File Record ID Indicators) Positions 30-39 (EXCEPT Name)

Printer File Figure 1. Printer file code example Note: By using the code examples, you agree to the terms of the Code license and disclaimer information. |...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 00010A* PRINTER FILE CODING EXAMPLE 00020A* 00030A 00040A 00050A 00060A* 00070A 00080A 00090A 00100A 00110A 00120A 00130A 00140A* 00150A 00160A 00170A 00180A 00190A 00200A N15 00210AO 32 33 34 00220A A 47TIME SPACEB(1) DEPT 3 0 R PUBR SKIPB(58) 47'Published by Department' +1 47DATE EDTCDE(Y) 31 31 31 FIELD2 40 FIELD1 40 R AUTHORR 66'by' 47SPACEB(1) 50DFT('Task Force I') SPACEA(1) 65'and' 47 30 R TITLER FLD1 FLD2 40 40 SKIPB(3) 47SPACEA(2) UNDERLINE 47SPACEA(2) UNDERLINE


Printer files can be program-described or externally described. Program-described printer files are assigned to a device of PRINTER. Externally described printer files are assigned to a device of FORMATFILE. Using FORMATFILE allows you to exploit the AS/400 function to its maximum, and using PRINTER allows for greater program portability. The use of externally described printer files has the following advantages over program-described printer files:

Multiple lines can be printed by one WRITE statement. When multiple lines are written by one WRITE statement and the END-OF-PAGE condition is reached, the END-OF-PAGE imperative statement is processed after all of the lines are printed. It is possible to print lines in the overflow area, and onto the next page before the END-OF-PAGE imperative statement is processed. Figure 116 shows an example of an occurrence of the END-OF-PAGE condition through FORMATFILE.

Optional printing of fields based on indicator values is possible. Editing of field values is easily defined. Maintenance of print formats, especially those used by multiple programs, is easier.

Use of the ADVANCING phrase for FORMATFILE files causes a compilation error to be issued. Advancing of lines is controlled in a FORMATFILE file through DDS keywords, such as SKIPA and SKIPB, and through the use of line numbers.