OUTPUT SPECIFICATION


Output specifications are used to define the output of the program. In the modern RPG language, output specifications are used for three purposes: defining program-defined printer files, releasing database record locks, and overriding the basic control for externally described output files. Figures 2.15 through 2.17 illustrate the output specifications.

start figure

 .....OFormat++++DAddn01n02n03Except++++SpbSpaSkbSka 

end figure

Figure 2.15: Output header specification.

start figure

 .....O.........And..n01n02n03 

end figure

Figure 2.16: Output header continuation specification.

start figure

 .....O..............n01n02n03Field+++++++++YB?End++PConstant/Editword+++++++++++ 

end figure

Figure 2.17: Output field specification.

Program-Described Output File Control Entries

Table 2.17 summarizes output specification program-described file entries.

Table 2.17: Output Specification Program-Described File Summary

Column

Title

Values

Description

6

Form type

O

Identifies this statement as an output specification.

7 – 16

Output file name

Blank

The name used is the same as the more recently specified output file name.

File name

Any file opened for output can be specified.

17

Output type

H

Heading records. For documentation purposes only. The H in this column is functionally equivalent to placing a D in this column. Heading records usually contain report column titles, page numbers, and date information.

D

Detail records. Usually, detail records contain information that will be repeated on subsequent output records, such as a printed report. Additionally, detail records are used to write and update records in program-defined data files.

T

Total-time records. Usually, total-time records are used to output the results of the program.

E

Exception records. Exception records are written using the EXCEPT op code. Indicators or an exception name can condition exception output.

16 – 18

Conditioning continuation controls

AND/OR

The conditioning indicators are a continuation of the previous line. The indicator condition on the previous line and/or the indicator condition on this line must be satisfied for the output line to be written.

18 – 20

File addition and file deletion

ADD

For database (DISK) files only. Records are added to the file. File addition must be specified on the file specification for the file being written.

DEL

For database (DISK) files only. The record is deleted from the file; it will no longer be accessible. The file must be declared as an UPDATE file on the file specification.

18

Output control

Blank

No special controlling is specified for this output statement.

F

Fetch overflow. When fetch is specified, RPG checks for overflow after each printed line. If the overflow indicator for this printer file is on and fetch has been specified, any detail and heading lines that are conditioned by that indicator are printed before this line.

R

The WORKSTN file specified is released from the program. See REL operation.

21 – 29

Controlling indicators

Blank

No indicators condition this output line.

1P

First page indicator (valid for heading and detail output only). Output lines conditioned with the 1P indicator are printed after the *INZSR subroutine is performed.

Indicator

Any valid indicator (up to three) can be specified to control the output line. If more than three indicators are required, the continuation controls (AND/OR) can be specified.

30 – 39

Except name

Blank

No exception name controls the output line.

Name

This line is exception output, and is controlled by the exception name. If conditioning indicators are specified, their condition must be satisfied for the line to be output. See EXCEPT operation.

40 – 42

Line spacing before printing

Blank

For PRINTER files only. The printer won't advance before printing the output line.

0 to 255

The printer advances the number of lines specified before printing the output line.

43 – 45

Line spacing after printing

Blank

For PRINTER files only. The printer advances one line after printing the output line.

0 to 255

The printer advances the number of lines indicated after printing the output line.

46 – 48

Line skipping before

Blank or 0

For PRINTER files only. The printer does not advance before printing the output line.

1 to 255

The printer advances to the line on the current page before printing. If the current print line is beyond the line specified, the printer ejects the current page and advances to the line on the next page before printing.

49 – 51

Line skipping after

Blank

For PRINTER files only. The printer won't advance after printing the output line.

1 to 255

The printer advances to the line on the current page after printing. If the current print line is beyond the line specified, the printer ejects the current page and advances to the line on the next page after printing.

52 – 80

Not used.

Program-Described Output File Field Description

The advanced support for externally described files has led RPG programmers to rarely use program-described files. While the use of program-defined WORKSTN and DISK files is virtually nonexistent, it is quite common to find program-described PRINTER output files (see Table 2.18). This is probably due to the advanced support RPG has for printed output (a principle design element in the original RPG language).

Table 2.18: Output Specification Program-Described File Field Description Summary

Column

Title

Values

Description

6

Form type

O

Identifies this statement as an output specification.

7 – 20

Not used for program-defined output fields.

21 – 29

Controlling indicators

Blank

The output field is always written whenever the controlling output specification is written.

1P

The output field is written only once—at first page output time (1P).

Any valid indicator (up to three)

The output field is included in the output operation only when the test of the controlling indicators is true.

30 – 43

Output field name

Name

The name of the field to be output when the controlling output specification is written. The field name must have already been defined in the program or it must be a predefined name, such as *DATE, UDATE, PAGE, or *INxx.

Name constant

The name of the named constant to be output when the controlling output specification is written.

30 – 43

PAGE, or PAGE1 to PAGE7

The current page number is output. The various PAGE fields include PAGE and PAGEn, where n is 1 to 7, giving a total of eight page-counter fields.

Conditioning indicators condition the resetting, not the printing, of the page number fields. When the indicator condition is met, the PAGEn field is reset to zero. When the indicator condition is not met, the PAGEn field value is printed normally.

*INxx

The value of the indicator xx is output to the record; xx can be any valid RPG indicator.

*IN,xx

The value of the indicator xx is output to the record; xx can be any general-purpose indicator (01 to 99).

*PLACE

This reserved word causes the data that has been specified up to the first *PLACE to be repeated to the right of that same data. For example, if 4-up labels for the same name and address are required, the output specification contains the field for the name, followed by three *PLACE entries.

44

Edit code

Blank

No edit code is used for this output field.

1 to 9

A, B, C, D, J, K, L, M, N, O, P, Q, X, Y, Z

The predefined edit code is used to mask the output field. The output field must be a numeric variable or a numeric named constant.

For more information on edit codes and edit words, see Table 2.23.

45

Blank after

Blank

The field is output and no other action is taken.

B

The field is output and then it is cleared. Numeric fields are set to zero and character fields are set to blanks.

40 – 43

Output positions

Blank

The output field is output to a relative position of +0. That is, it is output adjacent to the previous output field's right-most character.

Ending position

1 to 65535

The ending (right-most) position of the output field.

Relative position

- 65,534 to +65,534

The field is output relative to the previous field's ending position. The value of the relative position represents the number of spaces between the first character of this field and the last character of the previous field. For example, an ending position of +1 puts one space between this field and the previous field.

The (plus or minus) sign must precede the relative number. The number itself, however, must be left justified.

K1 to K10

For program-defined workstation device files, the K1 to K10 entry represents the length of the format name.

52

Data type

Blank

The output field is written as zoned decimal (if it is a numeric data-type) or character.

A

(CHARACTER) character field. Default for fields with no decimal positions.

B

(NUMERIC) binary field.

C

(CHARACTER) UCS-2 field.

D

(DATE) date field.

F

(NUMERIC) floating-point numeric.

G

(GRAPHIC) double-byte character set field.

I

(NUMERIC) integer field.

L

(NUMERIC) zoned decimal with a preceding sign.

N

(CHARACTER) named indicator field.

P

(NUMERIC) packed decimal field, the output field is written as packed decimal.

R

(NUMERIC) zoned decimal with a trailing sign.

S

(NUMERIC) zoned decimal.

T

(TIME) time field.

U

(NUMERIC) unsigned integer field.

Z

(TIME) timestamp field.

53 – 80

Output constant or edit word

Blank

No constant or edit word is used with this output field. These columns must be blank when a non-numeric value is being output.

Quoted literal

Any quoted character string can be specified. When the quoted character string contains embedded quotes, they must be doubled within the character string itself. So, O'Clock becomes 'O''Clock'.

Edit word

Any valid edit word can be specified to format the output of a numeric field. See Table 2.23 for more information.

Date or time format

Any valid date or time format can be specified to control the format of the date/time output field. These values are as follows:

Format

Description

Sep

Format

*MDY

Month Day Year

Yes

mm/dd/yy

*DMY

Day Month Year

Yes

dd/mm/yy

*YMD

Year Month Day

Yes

yy/mm/dd

*JUL

Juilian

Yes

yy/ddd

*ISO

ISO standard

No

ccyy-mm-dd

*USA

USA standard

No

mm/dd/ccyy

*EUR

European standard

No

dd.mm.ccyy

*JIS

Japan standard

No

ccyy-mm-dd

Format

Description

Sep

Format

*HMS

Standard

Yes

hh:mm:ss

*ISO

ISO standard

No

hh.mm.ss

*USA

USA standard

No

hh:mm AM

*EUR

European standard

No

hh.mm.ss

*JIS

Japan standard

No

hh:mm:ss

Attribute

The data attribute for variable length fields can be specified. Use *VAR to indicate that the output field is a variable length field.

Format name

The name of a format for a WORKSTN file. The name of the format must be left adjusted and enclosed in single quotation marks. Also, any length entry of Kn (where n is the number of characters in the format name) must be specified.

Externally Described Output File Control Entries

Externally described output files can be controlled with RPG IV operations such as WRITE, UPDATE, DELETE, and EXCEPT, or by the RPG cycle. See Table 2.19.

Table 2.19: Output Specification Externally Described File Summary

Column

Title

Values

Description

6

Form type

O

Identifies this statement as an output specification.

7 – 16

Record format name

Blank

The name used is the same as the more recently specified output format name.

Format name

Any record format name opened for output can be specified.

17

Output type

H

Heading records. For documentation purposes only. The H in this column is functionally equivalent to placing a D in this column. Heading records usually contain report column titles, page numbers, and date information.

D

Detail records. Usually, detail records contain information that is repeated on subsequent output records such as a printed report. Additionally, detail records are used to write and update records in program-defined data files.

T

Total-time records. Usually, total-time records are used to output the results of the program.

E

Exception records. Exception records are written using the EXCEPT operation code. Indicators and/or an exception name can condition exception records.

16 – 18

Conditioning continuation controls

AND/OR

The conditioning indicators are a continuation of the previous line. The indicator condition on the previous line AND/OR the indicator condition on this line must be satisfied for the output line to be written.

18 – 20

File addition and file deletion

ADD

For database (DISK) files only. Records are added to the file. The file addition must be specified on the file description specification for the file being written.

DEL

For database (DISK) files only. The record is deleted from the file; it is no longer accessible. The file must be declared as an UPDATE file on the file specification.

18

Output control

Blank

No special controlling is specified for this output statement.

F

Fetch overflow. When fetch is specified, RPG checks for overflow after each printed line. If the overflow indicator for this printer file is on and fetch has been specified, any detail and heading lines that are conditioned by that indicator are printed before this line.

R

The WORKSTN file specified is released from the program. See REL operation.

21 – 29

Controlling indicators

Blank

No indicators condition this output line.

1P

First page indicator (valid for heading and detail output only). Output lines conditioned with the 1P indicator are printed after the *INZSR subroutine is performed.

Indicator

Any valid indicator (up to three) can be specified to control the output line. If more than three indicators are required, the continuation controls (AND/OR) can be specified.

30 – 39

Except name

Blank

No exception name controls the output line.

Name

This line is exception output and it is controlled by the exception name. If conditioning indicators are specified, their condition must be satisfied for the line to be output.

See EXCEPT operation.

40 – 80

Not used.

Externally Described Output File Field Description

Externally described file output fields are used to specify the fields to be output (Table 2.20).

Table 2.20: Output Specification Externally Described File Field Description Summary

Column

Title

Values

Description

6

Form type

O

Identifies this statement as an output specification.

7 – 20

Not used for program-defined output fields.

21 – 29

Controlling indicators

Blank

The output field is always written whenever the controlling output specification is written.

1P

The output field is written only once—at first-page output time (1P).

Any valid indicator (up to three)

The output field is included in the output operation only when the test of the controlling indicators is true.

30 – 43

Output field name

Name

The name of the field to be output when the controlling output specification is written. The field name must have already been defined in the program or it must be a predefined name, such as *DATE, UDATE, PAGE, or *INxx.

Name constant

The name of the named constant to be output when the controlling output specification is written.

*ALL

All fields in the externally described file are output.

30 – 43

PAGE, OR PAGE1 TO PAGE7

The current page number is output. The various PAGE fields include PAGE and PAGEn, where n is 1 to 7, giving a total of eight page-counter fields.

Conditioning indicators condition the resetting, not the printing, of the page number fields. When the indicator condition is met, the PAGEn field is reset to zero. When the indicator condition is not met, the PAGEn field value is printed normally.

*INxx

The value of the indicator xx is output to the record; xx can be any valid RPG indicator.

*IN,xx

The value of the indicator xx is output to the record; xx can be any general-purpose indicator (01 to 99).

*PLACE

This reserved word causes the data that has been specified up to the first *PLACE to be repeated to the right of that same data. For example, if 4-up labels for the same name and address are required, the output specification contains the field for the name, followed by three *PLACE entries.

45

Blank after

Blank

The field is output and no other action is taken.

B

The field is output, then it is cleared. Numeric fields are set to zero and character fields are set to blanks.




The Modern RPG IV Language
The Modern RPG IV Language
ISBN: 1583470646
EAN: 2147483647
Year: 2003
Pages: 156
Authors: Robert Cozzi

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net