cobol file sort
From: ritchie (ritchie_s01_at_yahoo.com)
Date: 01/01/04
- Next message: Michael Mattias: "Re: cobol file sort"
- Previous message: Doug Scott: "Re: (not entirely...) OT: OPINION... chicken entrails, runic stones, and crystal balls... WAS CoBOL moved to OO"
- Next in thread: Michael Mattias: "Re: cobol file sort"
- Reply: Michael Mattias: "Re: cobol file sort"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 1 Jan 2004 06:20:54 -0800
Hi,
I am trying to produce a sorted report using the report writer.
I am using the Fujitsu compiler.
I am trying to read a file, sort it and then make a report from the
sorted file.
I need to exclude certain records from the file (say: numbers less
than 100..)
I want to use input & output procedures for my sort rather than using
& giving.
For the "OUTPUT PROCEDURE IS sort-output.", would it be better to have
this calling "REPORT-PARAGRAPH." or somehow
produce the report from the output procedure? This is what I ideally
want to do.
I have tried a couple of ways but I can't get it right.
I'm not sure where i'm going wrong.
I have done sorts before with 'USING' and 'GIVING' but not with imput
& output procedures.
If anyone could help me understand the differences between USING &
GIVING - and input &
output procedures that would be great.
Any help would be much aprechiated,
Thanks again,
Ritchie.
~~~~~~~~~~~~~~~~~~~~~~~~~CODE START~~~~~~~~~~~~~~~~~~~~~~~~~~~~
000120 INPUT-OUTPUT SECTION.
000130
000140 FILE-CONTROL.
000150 SELECT detail-file ASSIGN TO "detail.dat"
000160 ORGANIZATION IS Indexed
000170 ACCESS MODE IS DYNAMIC
...
*sort work file
000210 SELECT sort-file ASSIGN TO DUMMY.
*sorted file
000211 SELECT sorted-file ASSIGN TO "sorted.dat".
*report file
000220 SELECT report-file ASSIGN TO "report.dat" .
.........
001502***********SORT****************************
001503 SORT-PARA.
001504 SORT sort-file ON ASCENDING
001505 sort-surname, sort-number
001506 INPUT PROCEDURE IS INPUT-PROC
001507 OUTPUT PROCEDURE IS OUTPUT-PROC >>>>*can this be the
REPORT-PARAGRAPH?
001508
001510 INPUT-PROC.
001511 OPEN INPUT detail-file
001512 SET not-end-of-file-flag TO TRUE
001515 PERFORM WITH TEST AFTER UNTIL end-of-file-flag
001516 READ detail-file NEXT
001517 AT END
001518 SET end-of-file-flag TO TRUE
001519 NOT AT END
001521 IF amount < 100
*move (FD) - surname & number to sort work file...
001522 MOVE surname TO sort-surname
001523 MOVE number TO sort-number
001525 RELEASE sort-record
001527 END-IF
001528 END-READ
001529 END-PERFORM.
001530 CLOSE detail-file.
001567*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
001568 OUTPUT-PROC.
* report file
001569 OPEN OUTPUT report-file.
*sorted-file
001570 OPEN OUTPUT sorted-file
INITIATE report
001573 PERFORM WITH TEST AFTER UNTIL end-of-file-flag
001574 OPEN OUTPUT sorted-file
001575 RETURN sort-file
001576 AT END SET end-of-file-flag TO TRUE
001577 NOT AT END
001578 MOVE sort-surname TO sorted-surname
001579 MOVE sort-number TO sorted-number
001583 PERFORM REPORT-PARAGRAPH
001585 END-RETURN
001587 END-PERFORM
001588 TERMINATE cust-report
001592
001593*****************END SORTS **************************
002740 REPORT-PARAGRAPH.
003060 GENERATE report1
003061 READ sorted-file NEXT RECORD
003062 AT END SET end-of-file-flag TO TRUE
003066 END-READ.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~CODE END~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Next message: Michael Mattias: "Re: cobol file sort"
- Previous message: Doug Scott: "Re: (not entirely...) OT: OPINION... chicken entrails, runic stones, and crystal balls... WAS CoBOL moved to OO"
- Next in thread: Michael Mattias: "Re: cobol file sort"
- Reply: Michael Mattias: "Re: cobol file sort"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|