Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Creating print files

COBOL language elements for print files

COBOL2000 provides the following language elements for the creation of files that are to be printed:

  • Specification of the symbolic device names in the ASSIGN clause

  • The LINAGE clause in the file description entry

  • The ADVANCING phrase and the END-OF-PAGE phrase in the WRITE statement.

The use of these language elements is detailed in the "COBOL2000 Reference Manual” [1]. The following table shows the use of the symbolic device names in conjunction with the WRITE statement and the generation of the associated control characters:

Symbolic
device name

WRITE statement without
ADVANCING phrase

WRITE statement with
ADVANCING phrase

Comments

PRINTER
literal

Standard spacing when ADVANCING is omitted as if AFTER 1 LINE had been specified; the first character of the record is available for user data.

The first character of the record is available for user data.

The place for the carriage control character is reserved by the compiler and is not accessible to the user.This type of printer supports specification of the LINAGE clause in the file description entry. Write statements both with and without the ADVANCING phrase specified are allowed for a given file.

PRINTER

PRINTER01 -
PRINTER99

As above.

As above.

The place for the carriage control character is reserved by the compiler and is not accessible to the user. The LINAGE clause is not permitted for this file. Use of WRITE statements with and without the ADVANCING phrase for the same file is not permitted. If this does occur, a WRITE AFTER ADVANCING is executed implicitly for the records without the ADVANCING phrase.

literal

Spacing is controlled by the first character in each logical record; the user must therefore supply the appropriate control character before every execution of such a WRITE statement.

Spacing is controlled by the first character in each logical record; the user must therefore supply the appropriate control character before every execution of such a WRITE statement.

Mixed use of WRITE statements both with and without specifications of the ADVANCING phrase is permitted. In either case, however, the user information of the printer record begins only with the second character of the record.

Table 20: Use of symbolic device names in conjunction with the WRITE statement

Line-feed control characters for print files

When a WRITE statement is executed, the control byte of all print files (whose ASSIGN clauses do not contain the “literal” specification) is automatically supplied with a feed control character, which causes the page to be advanced as specified in the ADVANCING phrase (see the two following tables). Should the ADVANCING phrase be omitted, single-line spacing is assumed. The place for the carriage control character is reserved by the compiler and is inaccessible to the user.

When “literal” is specified in the ASSIGN clause for a file, a line-feed control character can be supplied to the control byte in two ways:

  • A WRITE statement with the ADVANCING phrase generates a feed control control character on execution causing the printer to be advanced as specified in the ADVANCING phrase.

  • A WRITE statement without the ADVANCING phrase does not supply a value to the control byte; the required control character must be explicitly transferred to it prior to the execution of the statement.

    This allows the user not only to use feed control characters but also to define other feed control characters in the program (e.g. for special printers). Information concerning the validity of individual characters and how they are interpreted during printing is available in the relevant printer manuals.

    Since carriage control characters are usually not printable, they must be defined in the program by means of the SYMBOLIC CHARACTERS clause, so as to ensure that they can be referenced in MOVE statements (see Example 9-7).

Depending on the output destination different feed control characters are generated:


Feed with output to BS2000

Feed with output to POSIX file system

PRINTER literal

BS2000 feed control characters as per table 21 and table 22

Feed control characters and lines as per UNIX conventions

PRINTER

as above

as above

PRINTER01-99

as above

not supported

literal

as above

BS2000 feed control characters as per table 21, table 22

The following tables list feed control characters:

Advance by
number of lines

Control characters for line spacing

After printing

Before printing

Hex code1

Printed form

1

01

40


(space)

2

02

41


non-printable

3

03

42


non-printable

.
.

.
.

.
.


.
.

11

0B

4A

c

(CENT)

12

0C

4B

.

(period)

13

0D

4C

<

(less than)

14

0E

4D

(

(parenthesis

15

0F

4E

+

(plus sign)

Table 21: Feed control characters

1 Due to hardware characteristics, the values of the second half-byte are 1 less than the desired number of lines.


Skip to punched
tape channels1

Printer control character

After printing

Before printing

Hex. code

Printed form

1

81

C1

A

2

82

C2

B

3

83

C3

C

4

84

C4

D

5

85

C5

E

6

86

C6

F

7

87

C7

G

8

88

C8

H

10

8A

CA

non-printable

11

8B

CB

non-printable

Table 22: Feed control characters for feed via punched tape channels

1 Skipping to channel 9 or 12 is not possible as these are reserved for an end-of-form condition.


The SPECIAL-NAMES paragraph of the Environment Division enables the user to assign a symbolic name to any hexadecimal value, thus ensuring that all such values (including non-printable line-feed control characters) can be addressed in the COBOL compilation unit (see “COBOL2000 Reference Manual” [1]). The example that follows illustrates how linefeed control characters can be defined in this way.

Example 9-7

Supplying a hexadecimal control character to the control byte

In this example, the hexadecimal value 0A is to be transferred to the control byte of the print record. This causes the printer to advance 10 lines after printing.


IDENTIFICATION DIVISION.
   ...
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
    SELECT PRINT-FILE ASSIGN TO "OUTPUT".
CONFIGURATION SECTION.
   ...
SPECIAL-NAMES.
   ...
    SYMBOLIC CHARACTERS HEX-0A IS 11 —————————————————————————————— (1)
   ...
DATA DIVISION.
FILE SECTION.
FD PRINTER-FILE 
   ...
01 PRINT-RECORD.
    02 CONTROL-BYTE            PIC X. 
    02 PRINT-LINE              PIC X(132). 
   ...
PROCEDURE DIVISION.
   ...
    MOVE "CONTENT" TO PRINT-LINE.
    MOVE HEX-0A TO CONYTROL-BYTE. ————————————————————————————————— (2)
    WRITE PRINT-RECORD.
   ...

(1)

The eleventh character of the EBCDIC character set - corresponding to the hexadecimal value 0A - is assigned the symbolic name HEX-0A.

(2)

The MOVE statement refers to this symbolic name in order to transfer hexadecimal value 0A to the control byte.

Using ASA line-feed control characters

ASA line-feed control characters can only be used in files that are assigned with ASSIGN TO literal or ASSIGN TO data-name.
In addition, the following ADD-FILE-LINK command is required for the file to be processed:

ADD-FILE-LINK filename, REC-FORM=*VAR(*ASA)


The ASA control characters and the corresponding WRITE statements that can be used under these conditions are listed in the table below::

ASA line-feed control characters

Format of the WRITE statement

+

WRITE ... BEFORE ADVANCING 0

0

WRITE ... AFTER ADVANCING 0 or 1

-

WRITE ... AFTER ADVANCING 2

1

WRITE ... AFTER ADVANCING PAGE or C01

2

WRITE ... AFTER ADVANCING C02

3

WRITE ... AFTER ADVANCING C03

4

WRITE ... AFTER ADVANCING C04

5

WRITE ... AFTER ADVANCING C05

6

WRITE ... AFTER ADVANCING C06

7

WRITE ... AFTER ADVANCING C07

8

WRITE ... AFTER ADVANCING C08

A

WRITE ... AFTER ADVANCING C10

B

WRITE ... AFTER ADVANCING C11

Table 23: ASA line-feed control characters and corresponding WRITE statements