Download presentation
Presentation is loading. Please wait.
Published byHorace Nicholson Modified over 9 years ago
1
Any Questions!
2
Agenda Fun with Functions Externally Described Files Condition Names Iteration Logical Files Random Reads
3
Fun with Functions ILEFUNCT
4
Condition Names Used with Code Fields –Eg. ARE-THERE-MORE-RECORDS –Eg. FINAL-GRADE –Eg. Indicators
5
Condition Names 01 ARE-THERE-MORE-RECORDS PIC X(3) VALUE ‘YES’. 88 THERE-ARE-MORE-RECORDS VALUE ‘YES’. 88 END-OF-FILEVALUE ‘NO’. IF THERE-ARE-MORE-RECORDS READ EMPLOYEE-FILE. IF END-OF-FILE PERFORM TERMINATION-RTN.
6
Set Verb Used to initialize fields to a Condition- Name. 01 ARE-THERE-MORE-RECORDS PIC X(3). 88 THERE-ARE-MORE-RECORDS VALUE ‘YES’. 88 END-OF-FILEVALUE ‘NO’. SET END-OF-FILE TO TRUE.
7
Conditions Cont’d 01 WORK-DAYS PIC X(3). 88 MONDAY VALUE ‘MON’. 88 TUESDAY VALUE ‘TUE’. 88 WEDNESDAY VALUE ‘WED’. 88 THURSDAY VALUE ‘THU’ 88 FRIDAY VALUE ‘FRI’. SET MONDAY TO TRUE. IF FRIDAY DISPLAY ‘GO HOME EARLY’.
8
Conditions Cont’d 01 FALL-MONTHS PIC X(3). 88 SEPTEMBER VALUE ‘SEP’. 88 OCTOBER VALUE ‘OCT’. 88 NOVEMBERVALUE ‘NOV’. 88 DECEMBER VALUE ‘DEC’. IF OCTOBER DISPLAY ‘HAPPY HALLOWEEN!!’ SET DECEMBER TO TRUE.
9
Option Indicators and Conditions 01 WS-indicators. 05 IN90 INDICATOR 90 PIC 1. 88 display-message value B’1’. 88 dont-display-message value B’0’. Set display-message to true. Set dont-display-message to true. If display-message If don’t-display-message If not display-message
10
Response Indicators and Conditions 01 WS-Control. 05 ws-function-key pic x(2). 88 F3 value ’03’ 88 F12 value ’12’. 88 Enter value ’00’ 05 ws-device-name pic x(10). 05 ws-record-format pic x(10). If F3 If not F3
11
Iteration Looping
12
BASIC Perform Statement PERFORM (paragraph-name)
13
Basic PERFORM READ Emp-File PERFORM DSP-Rtn STOP RUN DSP-RTN move emp-in to emp- out. write dsp-record format is ‘SCREEN’. read dsp-file record.
14
PERFORM Until PERFORM paragraph-name UNTIL Condition
15
PERFORM Until Condition Met? Execute Program Statements NO YES
16
PERFORM Until READ Emp-File AT END Move ‘YES’ TO EOF. PERFORM Dsp-Rtn UNTIL EOF = ‘Y’ STOP RUN DSP-RTN move emp-in to emp-out. write dsp-record format is ‘SCREEN’. read dsp-file RECORD. read emp-file at end move ‘YES’ to EOF.
17
PERFORM X Times PERFORM (paragraph-name) THROUGH/THRU (paragraph-name) (integer/variable) TIMES
18
PERFORM X Times Number of Times Met? Execute Program Statements NO YES
19
PERFORM X Times READ Emp-File AT END Move ‘YES’ TO EOF. PERFORM Dsp-Rtn 5 TIMES STOP RUN DSP-RTN move emp-in to emp- out. write dsp-record format is ‘SCREEN’. read dsp-file record.
20
PERFORM With Test After PERFORM (paragraph-name) THROUGH/THRU (paragraph-name) WITH TEST AFTER UNTIL Condition
21
PERFORM With Test After Condition Met? Execute Program Statements NO YES
22
PERFORM With Test After READ Emp-File AT END Move ‘YES’ TO EOF. PERFORM Dsp-Rtn WITH TEST AFTER UNTIL EOF = ‘Y’ STOP RUN DSP-RTN move emp-in to emp-out. write dsp-record format is ‘SCREEN’. read dsp-file record. read emp-file AT END MOVE ‘YES’ TO EOF.
23
PERFORMs within PERFORMs READ Emp-File AT END Move ‘YES’ TO EOF. PERFORM DSP-Rtn UNTIL 5 TIMES STOP RUN DSP-RTN MOVE EMP-IN TO EMP-OUT. PERFORM Write-Rtn
24
Iteration Statement to Use? Perform Until –Tests for the condition first –Statements are executed only if the condition is true Perform With Test After –tests for the condition last –Statements are always executed at least once
25
Iteration Statement to Use? Perform X Times –Use this when you know the number of times the paragraph(s) are to be executed.
26
Sorting Data Using Access Paths
27
Physical Files vs Logical Files EMPLOYEEPF *FILE EMPLOYEE *FILE Physical Files or Logical Files?
28
Externally Described Files Select Statement when physical/logical file has a key. SELECT Cobol-file-name ASSIGN TO database-actual-file-name [ORGANIZATION IS INDEXED] [ACCESS MODE IS SEQUENTIAL] RECORD KEY is data-element. (data-element could be EXTERNaLLY-DESCRIBED-KEY)
29
Externally Described Files Copying the record layout. FD Cobol-file-name. 01 Cobol-Record-Name. COPY DD-actualrecordname OF actualfilename. (DD can be replaced by DDS if you require the 10 char field names instead of the aliases)
30
Handy Physical File Commands DSPPFM – Display Physical File Member Displays the contents of a Physical File in arrival sequence. DSPFD – Display File Description Information about the file – eg access path. DSPFFD – Display File Field Description Displays the fields in the file.
31
Random Reads Used to retrieve a record based on the value of a key field Need an access path sorted by the key field needed Select statement changes
32
Defining a Random Access File SELECT Employee-File ASSIGN to DATABASE-EMPPF ORGANIZATION is INDEXED ACCESS MODE is RANDOM RECORD KEY is EXTERNALLY-DESCRIBED-KEY (with duplicates).
33
Random Reads If the key field to EMPPF is the Employee- Number then: Move 1 to Employee-Number. Read Employee-File Invalid Key Move ‘Error’ to Employee-Name-Out Not invalid key Move Employee-Name to Employee-Name- out End-Read.
34
Validating the Province Code Database object: PROVINCES
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.