Академический Документы
Профессиональный Документы
Культура Документы
The called program needs to have a LINKAGE SECTION. This must appear after
the WORKING-STORAGE SECTION in the DATA DIVISION.
The PROCEDURE DIVISION needs to have a USING clause. This identifies the
variables passed to the program and their ordering.
Entries in the LINKAGE SECTION can be in any order, but the entries in the
USING clause must be in the order of their usage in the CALL statement of
the CALLing program.
Instead of a STOP RUN statement, the called program must contain an EXIT
PROGRAM statement to transfer control back to the calling program.
SORTING AND MERGING
DATA FILES
Overview
COBOL –Sorting
SalesFile SortedSalesFile
Unsorted Sorted
Records Records
SORT
Process
WorkFile
Overview
How the INPUT PROCEDURE
works.
SalesFile SortedSalesFile
Unsorted Sorted
Records Records
Unsorted
Hat SORT
Records Process
SelectHatSale
s
WorkFile
OPEN
OPENINPUT
INPUTInFileName
InFileName
READ
READInFileName
InFileNameRECORD
RECORD
PERFORM
PERFORMUNTIL
UNTILCondition
Condition
RELEASE
RELEASESDWorkRec
SDWorkRec
READ
READ InFileNameRECORD
InFileName RECORD
END-PERFORM
END-PERFORM
CLOSE
CLOSEInFile
InFile
COBOL – SORT
Input Procedure – e.g.
The input procedure opens the input file, processes input records
and releases them into the sort file. It is similar to writing a
record to the sort file.
RELEASE Sort-record-name-1
[ FROM Identifier-1 ]
Complex Sort :INPUT FILE
COMPLEX SORT:INPUT PROCEDURE
COMPLEX SORT:INPUT PROCEDURE
COMPLEX SORT: INPUT PROCEDURE
COMPLEX SORT:RUN JCL
COMPLEX SORT : OUTPUT FILE
COMPLEX SORT : Input File
COBOL SORT: OUTPUT
PROCEDURE
COBOL – SORT Output Procedure
In case of sort if the giving option is used, then the sorted records are
automatically written onto the out-file after they are used.
MAIN-PARA.
SORT WORK-FILE
USING IN-FILE
OUTPUT PROCEDURE CHECK-PARA.
STOP RUN.
PROCESS-PARA.
RETURN SORT-FILE AT END MOVE ‘NO’ TO NO-MORE-RECORDS.
IF AMT-OF-PURCHASE > 6000
MOVE 0.02 TO DISCOUNT
ELSE
MOVE 0.00 TO DISCOUNT
END-IF.
WRITE OUT-REC FROM SORT-REC.
COMPLEX SORT: Output Procedure
Complex Sort : Output Procedure
COMPLEX SORT : OUTPUT PROCEDURE
COMPLEX SORT : RUN JCL
COMPLEX SORT: OUTPUT DATA
COBOL – Merge
COBOL has a MERGE statement that will combine two or more files
into a single file.
Overview
COBOL – Sort & Merge Summary
Processing of records can be carried out before or after sorting by using Input
or Output procedures or using both