• Keine Ergebnisse gefunden

IFIL~ !all l1 crt

Im Dokument RPG II (Seite 183-190)

j

Filename

Position

Input: Specifications

Record Identification Codes

Position Position

Field Location

From To

Field Name

Field Indicators

Zero Plus Minus or

Blank

5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

01 IFIL~

!all l1 crt

o 2 I

OR !NCIT

o 3 I o 4 I o 5 I

A record identifying indicator is used to condition an operation. When a record is read that has a T in position 1, the 01 indicator turns on. If this indicator is on, the field named SAVE is added to SUM. When a record having no T in position 1 is read, the 02 indicator is on.

The subtract operation, conditioned by 02, is then done instead of the add operation.

Calculation Specifications

C

Indicators

~.

~ ~

~I

j

At At

Factor 1 Operation Factor 2

Line .... "0 E ;.

.L§Q Z 0;

3 4 5 6 7·j 13 14 15 16 17 18 19 20 21 22 13 24 25 26 27 2829 30 31 32 33 34 35 36 37 38 39 40 41 42

0 1 C

SuM Ann SA VE

0 2 C 5UI~

sue

S~

VIE

0 3 c II/IX

0 4 C

"-0 5 C

"

--Record identifying indicators 01 and 02 are assigned on the input specifications. They are used here to condition calculation operations.

Figure 8-6. Conditioning Operations (Resulting Indicators)

8-10 Calculation Specifications

Result Field .g I Length ~~

Name

~ ~ ~ -;

Q J:

4344 4S 46 47 48 49 50 51 52 53

SUM

a~

su~

gl2

11

Resulting Indicators Arithmetic

Plus IMinusl Zero Comments

Compare 1>211<211=2 LookuplFactor 2)is High Low Equal

5455 5657 58 59 GO 01 62 63 64 65 66 67 68 69 70 71 72 73 74

Resulting Indicators (01-99)

Use any resulting indicators specified in columns 54 through 59 on the calculation specifications to condition operations according to the results of calculation operations. See Columns 54-59 (Resulting Indicators) in this chapter.

Control Level Indicators (L1-L9)

Use any control level indicators that are specified in columns 59 and 60 of the input specifications or in columns 54 through 59 of the calculation specifications.

If control level indicators are used in these columns but not in columns 7 and 8, the operation is performed at detail calculation time on the first record of a new control group or whenever the indicators are on.

Last Record Indicator (LR)

To condition operations to be performed at end of job, use the last record (LR) indicator in columns 9 through 17 only if LR is turned on during calculations. All operations to be performed at end of job should be conditioned by LR in columns 7 and 8.

Matching Record Indicator (MR)

Use the matching record (MR) indicator to condition an operation that is to be done only when matching records are found. See Columns

61-62

(Matching Fields) in Chapter

7,

Input Specifications for more information on matching fields.

Halt Indicators (H1-H9)

Use any halt indicators that are specified in columns 65 through 70 on the input specifications or in columns 54 through 59 on the calculation specifications to prevent the operation from being done when a specified error condition is found in the input data or during

calculations. See Columns 19-20 (Record Identifying Indicator) in Chapter 7, Input Specifications. Using a halt indicator is necessary because the record that causes the halt condition is completely processed before the program stops. Thus, if the operation is performed on an error condition, the results are in error. A halt indicator can also be used to condition an operation that

:~ to be done onl',' when an error occurs.

Note: The system message displayed on a halt can be overridden by a user message member. (See User Message Member in Chapter 10, Operation Codes.)

External Indicators (U1-U8)

Use any external indicator previously specified to condition which operations should be done and which files should be used for a specific job. If a file is conditioned by an external indicator, any calculations that are to be performed only on that file should be conditioned by the same external indicator.

Overflow Indicators (OA-OG, OV)

Use any overflow indicators that are specified in columns 33 and 34 of the file description specifications to condition operations that are to be done when the last line to be printed on a page is reached. See Overflow Indicators in Chapter 9, Output Specifications, for more information.

Relationship Between Columns 7-8 and Columns 9-17

In one program cycle, all operations conditioned by control level indicators in columns 7 and 8 (total time) are done before operations conditioned by control level indicators in columns 9 through 17 (see Figure 8-4).

When a control level indicator is used in columns 9 through 17 and columns 7 and 8 are not used (detail time), the operation conditioned by the indicator is done only on the record that causes a control break or any higher-level control break.

When a control level indicator (L 1 through L9) is specified in columns 7 and 8 (total time) and MR is specified in columns 9 through 17, M R indicates the matching condition of the previous record and not the one just read that caused the control break. After all operations conditioned by control level indicators (specified in columns 7 and 8 of the calculation

specifications) are done, MR then indicates the matching condition of the record just read.

Columns 9-17 (Indicators) 8-11

COLUMNS 18-27 (FACTOR 1) AND COLUMNS 33-42 (FACTOR 2)

Use columns 18 through 27 and 33 through 42 to name the fields or to give the actual data (literals) on which an operation is to be performed. See Figure 8- 7 for a summary of the operation codes.

The entries you can use for factor 1 and factor 2 are:

• The name of any field that has been defined

• Any alphameric or numeric literal

• Any subroutine, table, array name, or array element

• Any date field name (UDATE, UMONTH, UDAY, UYEAR)

• The special names PAGE, PAGEl, PAGE2, PAGE3, PAGE4, PAGE5, PAGE6, orPAGE7

• . Any figurative constant (*BLANK, *BLANKS, *ZERO,

*ZEROS)

The following restrictions apply to entries in factor 1 and factor 2:

• A data structure name cannot be specified in factor 1 or factor 2.

• A data structure subfield name can be used in factor 1 or factor 2; however, overlapping subfields in a data ·structure cannot be used in the same calculation. A subfield is considered to be an overlapping subfield if its from or t~ position occurs within the from and to positions of another subfield within the same data structure. If factor 1, factor 2, or the result field references a subfieldin a data . structure that is an array or array element with a

variable index, the entire array is used to determine whether overlap exists. The same array name can be referenced in the appropriate factors of a calculation specification without violating the overlap rule. See Figure 8-8 for examples of the overlap rule.

• Figurative constants cannot be used with move zone operations, bit operations, or the SET, KEY, SORT, or DEBUG operation codes.

The following entry can be made for factor 1 only:

• A label for a TAG, BEGSR, or ENDSR operation

8-12 Calculation Specifications

The following entries can be made for factor 2 only:

• A label for a GOTO or EXSR operation

• A filename for a SET, CHAIN, DEBUG, READ, FORCE, ACO, REL, or NEXT operation

• A subroutine name for an EXIT operation

• An array name for an SORTA operation.

An entry in factor 1 must begin in column 18; an entry in factor 2 must begin in column 33.

Entries for factor 1 and factor 2 depend upon the operation code used in columns 28 through 32. Some operations require entries in both factors, some require entries in only one, and some require no entries at all.

See Columns 28-32 (Operation) for more information on operation codes. For information on how to name a subroutine, see Subroutine Operations in Chapter 10, Operation Codes.

Literals

A literal is the actual data used in an operation rather than the field name representing that data. A literal can be either alphameric or numeric.

Alphameric Literals

Consider the following rules when using an alphameric literal (see Figure 8-9):

• Any combination of characters can be used in an alphameric literal. Blanks are also valid.

• The maximum length of an alphameric literal is 8 characters.

• Alphameric literals must be enclosed in apostrophes

n.

• An apostrophe required as part of a literal is represented by two apostrophes. For example, the literal O'CLOCK is coded as 'O"CLOCK'.

• Alphameric literals cannot be used for arithmetic operations.

Numeric Literals

Consider the following rules when using a numeric literal (see Figure 8-9):

• A numeric literal consists of any combination of the digits

a

through 9. A decimal point or sign can also be included.

• The sign (+ or -), if present, must be the leftmost character. An unsigned literal is treated as a positive number.

• The maximum total length of a numeric literal is 10 characters including the sign and decimal point.

• Blanks cannot appear in a numeric literal.

• Numeric literals must not be enclosed in apostrophes

n.

• Numeric literals are used in the same way as a numeric field.

Figurative Constants

The figurative constants *BLANK, *BLANKS, *ZERO, and *ZEROS can be specified as literals. The following rules apply for figurative constants:

• The figurative constants *BLANK and *BLANKS can only be used with alphameric fields.

• The figurative constants *ZERO and *ZEROS can be used with either alphameric or numeric fields.

• The length of the figurative constant is assumed to be equal to the length of the other factor field, if present. Otherwise, the length of the figurative constant is assumed to be equal to the length of the result field.

• Figurative constants are considered to be elementary items, and, if used in conjunction with an array, act like a field. For example:

MOVE *ZEROS ARR

If ARR has 4-character elements, each element of ARR contains '0000' after the move is executed.

• After a figurative constant has its length set, the figurative constant's logical placement in the collating sequence can be altered by specifying an alternate cQUating sequence.

Columns 18-27 (Factor 1) and Columns 33-42 (Factor 2) 8-13

Control Level Conditioning

Indicators Indicators Resulting Indicators

Operation Columns

Result Columns

Code 7-8 9-17 Factor 1 Factor 2 Field 54-55 56-57 58-59

ACQ a a R R a

ADD a a a R R a a a

BEGSR SR or blank R

BITaF a a R R

BITaN a a R R

CHAIN a a R R a

caMP a a R R 03 03 03

DEBUG a a a R 0

DIV a a a R R a a a

ENDSR SR or blank a a

EXCPT a a

EXIT a a R

EXSR a a R

FORCE a R

GaTa

a a R a

KEYnn1 a a a R a a 0

LaKUP a a R R 04 04 04

(Array)

LaKUP a a R R a 04 04 04

(Table)

MHHza a a R R

MHLza a a R R

MLHza a a R R

MLLza a a R R

Figure 8-7 (Part 1 of 2). Operation Codes

8-14 Calculation Specifications

Control Level Conditioning

Indicators Indicators Resulting Indicators

Operation Columns

Result Columns

Code 7-8 9-17 Factor 1 Factor 2 Field 54-55 56-57 58-59

MOVE 0 0 R R

MOVEA 0 0 R R

MOVEL 0 0 R R

MULT 0 0 0 R R 0 0 0

MVR 0 0 R 0 0 0

NEXT 0 0 R R 0

POST 0 0 R R 0

READ 0 0 R 0 2 0

REL 0 0 R R 0

RLABL R

SETnnl 0 0 0 0 0 0 0

SETOF 0 0 0 3 0 3 0 3

SETON 0 0 0 3 0 3 0 3

SETLL 0 0 R R

SHTDN 0 0 R

SORTA 0 0 R

SQRT 0 0 R R

SUB 0 0 0 R R 0 0 0

TAG 0 R

TESTB 0 0 R R 0 3 0 3 0 3

TESTZ 0 0 R 0 3 0 3 0 3

TIME 10 0 R

XFOOT 0 0 R R 0 0 0

Z-ADD 0 0 R R 0 0 0

Z-SUB 10 0 R R 0 0 0

lThe nn entries in columns 31 and 32 are for message indicator numbers. If the result field of a SET operation contains the keyword ERASE, factor 2 must contain the name of the CONSOLE file.

Otherwise, factor 2 and the result field must be blank.

2Columns 56 and 57 can contain an indicator when the READ operation is used with a WORKSTN device.

3At least one resulting indicator must be specified in columns 54 through 59.

4At least one resulting indicator must be specified in columns 54 through 59, but no more than two can be used.

Fields without entries must be blank.

o

Optional

R Required

SR The only allowable non blank characters in columns 7 and 8 for the BEGSR and ENDSR operation codes.

Figure 8-7 (Part 2 of 2). Operation Codes

Columns 18-27 (Factor 1) and Columns 33-42 (Factor 2) 8-15

Input Specifications

I

Record Identification Codes Field Location Field

1 2 3 Indicators

r

-'"

Line Filename D ~ Field Name

(; Q; Q; u: Zero

: Position

~ § I

Position - ~ Position ~~

Iii

From To Plus Minus or

~ e E ·c Blank

-f-,.- o ~ ~ .;;;

o R z u u z u u ~ U <5

"A'Nto

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2122 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 5 1 52 53 54 55 56 57 5 8 59 60 61 62 6364 65 66 67 68 69 70 71 72 73 74

o 1 It) ~T ~DS D~

o 2 I ~

5 IAILP

~

o 3 I

16 11 IAILP IA2

o 4 I ~

IAL PW

~

o 5 I '1 ~IL

PH IA

o 6 I

, 11

~ltP ~

o 7 I

1 INU Ml

o B I

1 HOM

o 9 I

1 0 I

NUM

11 I

tN VM;;

1 2 I 2~

Is AA

~Il

1 3 I

*11 7 ARR

1 4 I 1 5 I

1 6 I i The data structure DATADS contains subfields

1 7 I

and arrays that are defined as overlapping (that

1 B I

is, occupying part of the same area). ARR1 (on

1 9 I

2 0 I line 12) has six elements, and each element is

I five positions long for a total length of 30. ARR2

I (on line 13) has five elements, and each element

I is six positions long for a total length of 30.

I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I

I 1 1 1 1 I I

Figure 8-8 (Part 1 of 3). Examples of Valid and Invalid Calculations with Overlapping Subfields in a Data Structure

8-16 Calculation Specifications

C

Indicators

-

At AL

Line

0 0 0

Z Z Z

Im Dokument RPG II (Seite 183-190)