cobol file sort

From: ritchie (ritchie_s01_at_yahoo.com)
Date: 01/01/04


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~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Relevant Pages

  • Re: Report in FM 6 or 7
    ... Please adivse on this- and then, I get to attack this report again in ... you cannot sort by AgeDivision_Category and why the Export/Import ... act they want to be the last act of the show, they have to sort by their ... If the Age Division field contains data in the form "3-5 Age Division" ...
    (comp.databases.filemaker)
  • Re: Report in FM 6 or 7
    ... Please adivse on this- and then, I get to attack this report again in ... you cannot sort by AgeDivision_Category and why the Export/Import ... act they want to be the last act of the show, they have to sort by their ... If the Age Division field contains data in the form "3-5 Age Division" ...
    (comp.databases.filemaker)
  • Re: sort in report
    ... "fredg" wrote: ... date on my report. ... fields I would like to sort on in a report: ... so the format is irrelevant). ...
    (microsoft.public.access.gettingstarted)
  • Re: Report in FM 6 or 7
    ... Please adivse on this- and then, I get to attack this report again in ... you cannot sort by AgeDivision_Category and why the Export/Import ... act they want to be the last act of the show, they have to sort by their ... If the Age Division field contains data in the form "3-5 Age Division" ...
    (comp.databases.filemaker)
  • Re: "Sort" a combination of letters and numbers e.g. 20, 21a,200,
    ... The sorting for the report works beautifully, however, any VBA code ... Sometimes I will want to sort by a) area and then b) Tag, ... I only have one piece of code in my database so far, ...
    (microsoft.public.access.reports)