Code Comments
Programming Forum and web based access to our favorite programming groups.Hi everyone! This is my first post to Google Groups - please be gentle! =) Problem: I'm generating a report in Cobol 85 using the report writer, and unfortunately I'm not so good at it. For some reason it appears that only my last detail line is being printed in my report! I've double checked all my line numbers to make sure I"m not overwriting them. I displayed a portion of each detail on my display when I compile and it shows that it is in fact reading all the records from the infile, BUT it's reading the last line twice. If would appreciate if anyone could take a pat my code. Once I can get the detail lines printing I'll be able to finish this program with no problems. The code is VERY raw and I know that my calculations are current incorrect, I only care about getting the detail lines to print. Thank you VERY much in advance! Tracy IDENTIFICATION DIVISION. PROGRAM-ID. IRS-REPORT. AUTHOR. TK. DATE-WRITTEN. APRIL 15, 2005. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. VAX. OBJECT-COMPUTER. VAX. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT INFILE ASSIGN TO "data" organization is line sequential. SELECT WORK-FILE ASSIGN TO "Sort.tmp". SELECT REPORT-FILE ASSIGN TO "Report". DATA DIVISION. FILE SECTION. FD INFILE LABEL RECORDS ARE STANDARD DATA RECORD IS INPUT-REC. 01 INPUT-REC. 02 TAXPAYERNUM PIC 9(2). 02 STATE PIC 9. 02 REGION PIC 9. 02 NAME PIC X(10). 02 MONTHSPASTDUE PIC 9. 02 ORIGBAL PIC 9(5)V99. 02 PENALTY PIC X. SD WORK-FILE DATA RECORD IS WORK-REC. 01 WORK-REC. 02 TAXPAYERNUM-WR PIC 9(2). 02 STATE-WR PIC 9. 02 REGION-WR PIC 9. 02 NAME-WR PIC X(10). 02 MONTHSPASTDUE-WR PIC 9. 02 ORIGBAL-WR PIC 9(5)V99. 02 PENALTY-WR PIC X. FD REPORT-FILE LABEL RECORDS ARE OMITTED REPORT IS TAXPAYERS-REPORT. WORKING-STORAGE SECTION. 01 VARIABLES. 02 PAGE-TOTAL PIC 9(10) VALUE ZERO. 02 REGION-ORIGBAL-T PIC 9(5)V99 VALUE ZERO. 02 STATE-ORIGBAL-T PIC 9(5)V99 VALUE ZERO. 01 FLAGS. 02 EOF-FLAG PIC X(3) VALUE "NO". 88 END-OF-FILE VALUE "YES". REPORT SECTION. RD TAXPAYERS-REPORT CONTROLS ARE FINAL REGION STATE PAGE LIMIT IS 66 LINES FIRST DETAIL 5 LAST DETAIL 25. 01 MAJOR-HEADING TYPE IS REPORT HEADING NEXT GROUP NEXT PAGE. 02 LINE NUMBER IS 10. 03 COLUMN 44 PIC X(25) VALUE "INTERNAL REVENUE SERVICES". 02 LINE NUMBER IS PLUS 2. 03 COLUMN 43 PIC X(28) VALUE "DELINQUENT TAX PAYERS REPORT". 02 LINE NUMBER IS PLUS 2. 03 COLUMN 45 PIC X(22) VALUE "BY STATE WITHIN REGION". 01 MAJOR-HEADING2 TYPE IS PAGE HEADING. 02 LINE NUMBER IS 1. 03 COLUMN 46 PIC X(21) VALUE "DELINQUENT TAX PAYERS". 03 COLUMN 106 PIC X(4) VALUE "PAGE". 03 COLUMN 111 PIC ZZ SOURCE IS PAGE-COUNTER. 02 LINE NUMBER IS PLUS 2. 03 COLUMN 1 PIC X(8) VALUE "TAXPAYER". 03 COLUMN 12 PIC X(5) VALUE "STATE". 03 COLUMN 21 PIC X(6) VALUE "REGION". 03 COLUMN 44 PIC X(6) VALUE "MONTHS". 03 COLUMN 55 PIC X(8) VALUE "ORIGINAL". 03 COLUMN 68 PIC X(7) VALUE "PENALTY". 02 LINE NUMBER IS PLUS 1. 03 COLUMN 2 PIC X(6) VALUE "NUMBER". 03 COLUMN 12 PIC X(6) VALUE "NUMBER". 03 COLUMN 21 PIC X(6) VALUE "NUMBER". 03 COLUMN 32 PIC X(4) VALUE "NAME". 03 COLUMN 43 PIC X(8) VALUE "PAST DUE". 03 COLUMN 53 PIC X(11) VALUE "BALANCE DUE". 03 COLUMN 69 PIC X(4) VALUE "CODE". 03 COLUMN 78 PIC X(7) VALUE "PENALTY". 03 COLUMN 90 PIC X(8) VALUE "INTEREST". 03 COLUMN 103 PIC X(9) VALUE "GROSS DUE". 01 DETAIL-LINE TYPE IS DETAIL LINE NUMBER IS PLUS 2. 02 COLUMN 4 PIC 99 SOURCE IS TAXPAYERNUM-WR. 02 COLUMN 14 PIC 9 SOURCE IS STATE-WR. 02 COLUMN 23 PIC 9 SOURCE IS REGION-WR. 02 COLUMN 30 PIC X(10) SOURCE IS NAME-WR. 02 COLUMN 46 PIC 9 SOURCE IS MONTHSPASTDUE-WR. 02 COLUMN 54 PIC $ZZ,ZZZ.99 SOURCE IS ORIGBAL-WR. 02 COLUMN 70 PIC X SOURCE IS PENALTY-WR. 01 STATE-SUMMARY-LINE TYPE IS CONTROL FOOTING STATE LINE NUMBER IS PLUS 2. 02 COLUMN 37 PIC X(5) VALUE "STATE". 02 COLUMN 43 PIC 9 SOURCE IS STATE-WR. 02 COLUMN 45 PIC X(6) VALUE "TOTALS". 02 COLUMN 54 PIC $ZZ,ZZZ.99 SUM ORIGBAL-WR. * 02 COLUMN 70 PIC X SOURCE IS PENALTY-WR. 01 REGION-SUMMARY-LINE TYPE IS CONTROL FOOTING REGION LINE NUMBER IS PLUS 2. 02 COLUMN 36 PIC X(6) VALUE "REGION". 02 COLUMN 43 PIC 9 SOURCE IS REGION-WR. 02 COLUMN 45 PIC X(6) VALUE "TOTALS". 02 COLUMN 54 PIC $ZZ,ZZZ.99 SOURCE IS REGION-ORIGBAL-T. 01 TYPE IS CONTROL FOOTING FINAL LINE NUMBER IS PLUS 2. 02 COLUMN 39 PIC X(12) VALUE "GRAND TOTALS". 02 COLUMN 54 PIC $ZZ,ZZZ.99 SOURCE IS STATE-ORIGBAL-T. PROCEDURE DIVISION. 1000-MAIN-LOGIC SECTION. 1001-MAIN-LOGIC. SORT WORK-FILE ON ASCENDING KEY REGION-WR STATE-WR TAXPAYERNUM-WR USING INFILE OUTPUT PROCEDURE IS 2000-PROCESS-OUT STOP RUN. 2000-PROCESS-OUT SECTION. 2001-PROCESS-OUT. PERFORM 3000-INITIALIZE-REPORT. PERFORM 5000-PROCESS-RECORD UNTIL END-OF-FILE. PERFORM 6000-TERMINATE-REPORT. 3000-INITIALIZE-REPORT. OPEN INPUT INFILE. OPEN OUTPUT REPORT-FILE. INITIATE TAXPAYERS-REPORT. PERFORM 4000-READ-FILE. 4000-READ-FILE. RETURN WORK-FILE AT END MOVE "YES" TO EOF-FLAG. 5000-PROCESS-RECORD. display "generate name " name-wr. GENERATE DETAIL-LINE. ADD ORIGBAL-WR TO STATE-ORIGBAL-T. ADD ORIGBAL-WR TO REGION-ORIGBAL-T. PERFORM 4000-READ-FILE. 6000-TERMINATE-REPORT. TERMINATE TAXPAYERS-REPORT. CLOSE INFILE. CLOSE REPORT-FILE.
Post Follow-up to this messageTracy wrote: > Hi everyone! > > This is my first post to Google Groups - please be gentle! =) But of course :-). I've never written using R/W but go to University of Limerick; some R/W examples there :- http://www.csis.ul.ie/COBOL/examples/ I should point out the U of L. examples write to a disk-file and not direct to the printer. If you search on COBOL and Report Writer you may well find more examples at other universities. Jimmy, Calgary AB
Post Follow-up to this messageOUTPUT PROCEDURE IS 2000-PROCESS-OUT STOP RUN. 2000-PROCESS-OUT SECTION. 2001-PROCESS-OUT. PERFORM 3000-INITIALIZE-REPORT. PERFORM 5000-PROCESS-RECORD UNTIL END-OF-FILE. PERFORM 6000-TERMINATE-REPORT. 3000-INITIALIZE-REPORT. 2000-Process-Out is a SECTION. The section will execute until it reaches the next section header. It does 3000-Init.. then 5000-proc.. until EOF then 6000-term.. then drops through the label 3000-Init and executes the statements there then drops through .... until it reaches the statement GENERATE DETAIL-LINE then drops through until it gets to the end of 6000-Terminate.. at which point the implicit perform of the output procedure is complete. With an ANS-85 compiler the output procedure can be a paragraph so change this to 2001-Process-Out.
Post Follow-up to this messageTHANK YOU SO MUCH!!!! You guys are amazing. Keep up the great work. I can't thank you enough! Tracy
Post Follow-up to this message.. On 14.04.05 wrote tkartes@gmail.com (Tracy) on /COMP/LANG/COBOL in 1113522510.733754.207910@l41g2000cwc.googlegroups.com about Problem With Cobol Report Writer having all those paragraphs being performed ... one does not see the wood for the trees. t> 2000-PROCESS-OUT SECTION. t> 2001-PROCESS-OUT. t> PERFORM 3000-INITIALIZE-REPORT. t> PERFORM 5000-PROCESS-RECORD t> UNTIL END-OF-FILE. t> PERFORM 6000-TERMINATE-REPORT. t> t> 3000-INITIALIZE-REPORT. t> OPEN INPUT INFILE. t> OPEN OUTPUT REPORT-FILE. t> INITIATE TAXPAYERS-REPORT. t> PERFORM 4000-READ-FILE. t> t> 4000-READ-FILE. t> RETURN WORK-FILE t> AT END MOVE "YES" TO EOF-FLAG. t> t> 5000-PROCESS-RECORD. t> display "generate name " name-wr. t> GENERATE DETAIL-LINE. t> ADD ORIGBAL-WR TO STATE-ORIGBAL-T. t> ADD ORIGBAL-WR TO REGION-ORIGBAL-T. t> PERFORM 4000-READ-FILE. t> t> 6000-TERMINATE-REPORT. t> TERMINATE TAXPAYERS-REPORT. t> CLOSE INFILE. t> CLOSE REPORT-FILE. As has already been pointed out, after the first paragraph, the program "falls thru" to the next paragraph, "INITIALIZE-REPORT", where the report is again opened for output, and the REPORT is initiated again. Then the program executes the remaining paragraphs, reading the first two records, generating a DETAIL from the second record, and then closing up. BTW, the program does an OPEN INPUT INFILE in the section where the RETURN from the sorted file is being processed, but never uses that file in this process. Delete the OPEN and CLOSE of INFILE in that part. Next, these two lines: t> ADD ORIGBAL-WR TO STATE-ORIGBAL-T. t> ADD ORIGBAL-WR TO REGION-ORIGBAL-T. are superflouus, you can accomplish that by the appropriate SUM clauses in the CONTROL FOOTINGs for those controls, as you already do in the STATE-SUMMARY-LINE. Give the column 54 in there a name, and you should be able to reference this SUM counter in the upper CONTROL FOOTINGS. You may have to RESET the SUM counter, though. Instead of using t> AT END MOVE "YES" TO EOF-FLAG. use the file status Put the whole thing in one section with a proper loop, as shown in this my example (which processes an OPTIONAL sequential file): --------- schnipp ----------------------------------------- OPEN INPUT input-file IF is-not-present-file in status-input-file THEN *> minor filestat = '5' DISPLAY "input-file is not present" ELSE READ input-file IF has-reached-EOF in status-input-file THEN *> Major filestat = '1' DISPLAY "input-file is empty" ELSE OPEN OUTPUT output-file INITIATE output-report PERFORM WITH TEST AFTER UNTIL has-reached-EOF in status-input-file *> do something useful with the input record *> whose presence is asserted here GENERATE report-detail-item READ input-file END-PERFORM TERMINATE output-report CLOSE output-file END-IF CLOSE input-file END-IF STOP RUN
Post Follow-up to this messageTracy wrote: > THANK YOU SO MUCH!!!! You guys are amazing. > > Keep up the great work. I can't thank you enough! > > Tracy Just illustrating the rule: "Don't use SECTIONS." They are an artifact of a more complicated time.
Post Follow-up to this message"HeyBub" <heybubNOSPAM@gmail.com> wrote in message news:115vd671ecudr9a@news.supernews.com... > Tracy wrote: > > Just illustrating the rule: "Don't use SECTIONS." They are an artifact of a > more complicated time. > Or, just illustrating the rule: "Don't use COBOL." It is an artifact of a simpler time. If you are going to use COBOL, there is nothing wrong with using sections, provided you don't perform paragraphs as well. We have thrashed this to death here many times. It is a question of style. COBOL with or without sections, provided it is well written, should be easily maintainable by any competent COBOL programmer. Pete.
Post Follow-up to this message.. On 16.04.05 wrote dashwood@enternet.co.nz (Pete Dashwood) on /COMP/LANG/COBOL in 3cascbF6lme65U1@individual.net about Re: Problem With Cobol Report Writer PD> If you are going to use COBOL, there is nothing wrong with using PD> sections, provided you don't perform paragraphs as well. Back in the days of COBOL-74, when I had written sort of a rulebook for COBOL programming at Sperry Univac Germany, I stipulated that only SECTIONs might be target of a PERFORM, and that only paragraphs might be target of a GOTO (as in a GOTO DEPENDING ON, the way one could code a CASE statement in a pre-85 COBOL). Sure, with COBOL-85 a GOTO isn't necessary anymore at all, but I stick to the rule, and recommend it to everybody else. All other DIVISIONs, except the ultra-short IDENTIFICATION DIVISION are divided in SECTIONS, so the PROCEDURE DIVISION should follow the pattern. Yours, Lüko Willms http://www.willms-edv.de /--------- L.WILLMS@jpberlin.de -- Alle Rechte vorbehalten -- Vorstellungen sind auch ein Leben und eine Welt. -G.C.Lichtenberg
Post Follow-up to this message> Sure, with COBOL-85 a GOTO isn't necessary anymore at all, but I > stick to the rule, and recommend it to everybody else. All other > DIVISIONs, except the ultra-short IDENTIFICATION DIVISION are divided > in SECTIONS, so the PROCEDURE DIVISION should follow the pattern. It may well be that the PROCEDURE DIVISION should be divided up into SECTIONs. In fact I used to do that for the purpose of using 'priorities' in order to overlay the program into the memory space available to me. But it doesn't follow, as you seem to claim, that these SECTIONs should therefore be what the PERFORMs target. After all one doesn't INITIALISE WORKING-STORAGE as a SECTION.
Post Follow-up to this message.. On 16.04.05 wrote riplin@Azonic.co.nz (Richard) on /COMP/LANG/COBOL in 1113676699.610450.255030@g14g2000cwa.googlegroups.com about Re: Problem With Cobol Report Writer r> It may well be that the PROCEDURE DIVISION should be divided up into r> SECTIONs. In fact I used to do that for the purpose of using r> 'priorities' in order to overlay the program into the memory space r> available to me. This is ancient ... but has nothing to do with the SECTION as such. I have never played around with segmentation. r> r> But it doesn't follow, as you seem to claim, that these SECTIONs r> should therefore be what the PERFORMs target. This is a questin of individual discipline or shop standards. It just makes sense, and it made much more sense before COBOL-85 was implemented which finally made proper programming possible in COBOL. It is a simple rule: PERFORM only SECTIONs, never a paragraph, and GOTO only to paragraphs, never SECTIONs. Today, where a GOTO is superflouus even in COBOL, I see the only sense in paragraphs to serve as a visual documentation tool. r> After all one doesn't INITIALISE WORKING-STORAGE as a SECTION. I don't understand what that is supposed to mean. Yours, Lüko Willms http://www.willms-edv.de /--------- L.WILLMS@jpberlin.de -- Alle Rechte vorbehalten -- Der Mann hatte soviel Verstand, daß er zu fast nichts mehr in der Welt zu ge brauchen war. -G.C.Lichtenberg
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.