creating a report



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

creating a report

Postby diwas » Mon Apr 18, 2016 1:13 am


IDENTIFICATION DIVISION.
       PROGRAM-ID. P8LIST.
     
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
            SELECT MASTER-FILE-INDEXED
              ASSIGN TO 'THMASTVS.DAT'.
                 ORGANIZATION IS INDEXED
                   ACCESS IS SEQUENTIAL
                     RECORD KEY IS MASTER-NUM-INDEXED.

      ************************************************************
      *       ASSIGN TO DA-I-???     PUT CORRECT NAME HERE ON Z
      ************************************************************


            SELECT SALES-REPORT
              ASSIGN TO 'P8STEP2.DOC'.
              ORGANIZATION IS LINE SEQUENTIAL.

      **************************************************************
      *         ASSIGN TO UT-S-???        PUT CORRECT NAME HERE ON Z  
      *         DELETE ORGANIZATION IS LINE SEQUENTIAL
      **************************************************************

       DATA DIVISION.
       FILE SECTION.
       FD  MASTER-FILE-INDEXED.

       01  MASTER-REC-INDEXED.
           05  MASTER-NUM-INDEXED            PIC X(5).
           05  FILLER                        PIC XX.
           05  NAME-INDEXED.
               10 F-INIT-INDEXED             PIC X.
               10 M-INIT-INDEXED             PIC X.
               10 LAST-NAME-INDEXED          PIC X(20).
           05  TRANS-CUR-SALES-INDEXED       PIC S9(5)V99.
           05  FILLER                        PIC XX.
           05  TRANS-CUR-COMM-INDEXED        PIC S9(5)V99.
           05  FILLER                        PIC XX.
           05  TRANS-YTD-COMM-INDEXED        PIC S9(6)V99.
           05  FILLER                        PIC X(22).


       FD  SALES-REPORT
           RECORDING MODE IS F.
       01  REPORT-LINE-OUT                     PIC X(132).

                 
       WORKING-STORAGE SECTION.
       01  WORKING-FIELDS.
           05  EOF-MASTER-WS              PIC X(3)  VALUE 'NO '.
       01  ACCUMULATORS.
           05  AC-LINE-COUNT              PIC S999  VALUE 0.
           05  AC-PAGE-COUNT              PIC S999  VALUE 0.
           05  AC-RECORD-COUNT            PIC S999  VALUE 0.

       01  REPORT-HEADING.
           02  RH-LINE-1.
               03                              PIC X(26)  VALUE SPACES.
               03                              PIC X(20)  VALUE
                   "SALES REPORT".
               03                              PIC X(18) VALUE SPACES.
               03                              PIC X(6)  VALUE 'PAGE:'.
               03  RH-PAGE-COUNT               PIC ZZ9.  
               03                              PIC X(50) VALUE SPACE.

           

         

           02  RH-LINE-2.
               03                              PIC X(15)  VALUE
                   "  EMP NUMBER".
               03                              PIC X(4)   VALUE SPACES.
               03                              PIC X(13)  VALUE
                   "EMPLOYEE NAME".    
               03                              PIC X(12)  VALUE SPACES.
               03                              PIC X(10)  VALUE "SALES".
                   
               03                              PIC X(9)   VALUE SPACES.
               03                         PIC X(16) VALUE "COMMISSION".
                   
               03                              PIC X(7)   VALUE SPACES.

           

       01  DETAIL-LINE.
           02                                  PIC X(2)  VALUE SPACES.
           02  MASTER-NUM-OUT                  PIC X(5).
           02                                  PIC X(6)  VALUE SPACES.
           02  LAST-NAME-OUT                   PIC X(20).
           02                                  PIC X(2)  VALUE SPACES.
           02                                  PIC X(10).
           02                                  PIC XXX   VALUE SPACES.
           02                                  PIC X(7)  VALUE SPACES.
           02  TRANS-CUR-SALES-OUT             PIC S9(5)V99.
           02                                  PIC X(5) VALUE SPACES.
           02  TRANS-CUR-COMM-OUT              PIC S9(5)V99.

       01  SUMMARY-LINES.
           02  SL-LINE-1.
               03                              PIC X(26)  VALUE SPACES.
               03                              PIC X(25)  VALUE
                   "TOTAL RECORDS PRINTED =  ".
               03  SL-RECORD-COUNT             PIC ZZ9.
               03                              PIC X(76) VALUE SPACES.

           02  SL-EOR-LINE.
               03                              PIC X(32)  VALUE SPACES.
               03                              PIC X(13)  VALUE
                   "END OF REPORT".
               03                              PIC X(85) VALUE SPACES.


       PROCEDURE DIVISION.
     
       100-MAIN-MODULE.
           PERFORM 200-OPEN.
           PERFORM 300-PROCESS
               UNTIL EOF-MASTER-WS = 'YES'.
           PERFORM 600-WRAPUP.
           PERFORM 900-CLOSE.
           STOP RUN.

       200-OPEN.
           INITIALIZE ACCUMULATORS.

           OPEN INPUT MASTER-FILE-INDEXED
                OUTPUT  SALES-REPORT.

           PERFORM 250-READ.

       250-READ.    
           READ MASTER-FILE-INDEXED
               AT END MOVE 'YES' TO EOF-MASTER-WS
           END-READ.

       300-PROCESS.

           IF AC-LINE-COUNT = 0
               PERFORM 500-HEADER
           END-IF



                  MOVE MASTER-NUM-INDEXED       TO MASTER-NUM-OUT
                  MOVE LAST-NAME-INDEXED        TO LAST-NAME-OUT
                  MOVE TRANS-CUR-SALES-INDEXED  TO TRANS-CUR-SALES-OUT
                  MOVE TRANS-CUR-COMM-INDEXED   TO TRANS-CUR-COMM-OUT

                  WRITE REPORT-LINE-OUT FROM DETAIL-LINE
                                AFTER ADVANCING 2 LINES
                  ADD 2 TO AC-LINE-COUNT
                  ADD 1 TO AC-RECORD-COUNT

         
           IF AC-LINE-COUNT > 35
                     MOVE ZERO TO AC-LINE-COUNT
           END-IF

           PERFORM 250-READ.

       500-HEADER.

           ADD 1 TO AC-PAGE-COUNT.
           MOVE AC-PAGE-COUNT TO RH-PAGE-COUNT.
           WRITE REPORT-LINE-OUT FROM RH-LINE-1
               AFTER ADVANCING PAGE.
           WRITE REPORT-LINE-OUT FROM RH-LINE-2
               AFTER ADVANCING 1 LINE.
           MOVE SPACES TO REPORT-LINE-OUT
           WRITE REPORT-LINE-OUT AFTER ADVANCING 3 LINES.

           MOVE 9 TO AC-LINE-COUNT.

       600-WRAPUP.

           MOVE AC-RECORD-COUNT TO SL-RECORD-COUNT.

           WRITE REPORT-LINE-OUT FROM SL-LINE-1
               AFTER ADVANCING 3 LINES.

           WRITE REPORT-LINE-OUT FROM SL-EOR-LINE
               AFTER ADVANCING 2 LINES.

     
       900-CLOSE.
           CLOSE MASTER-FILE-INDEXED
                 SALES-REPORT.
 


its giving me few errors with the "SALES-REPORT" variable. says its not a record. anyone have any idea , why? my professor gave us a similar program with "EMPLOYEE-REPORT", and that program runs fine. Id really appreciate any kind of help.

Coded
diwas
 
Posts: 2
Joined: Mon Apr 18, 2016 12:53 am
Has thanked: 0 time
Been thanked: 0 time

Re: creating a report

 

Re: creating a report

Postby Akatsukami » Mon Apr 18, 2016 2:13 am

Please remember to enclose all code, data, and anything else where alignment could be significant in Code tags.

Now, why are you getting those errors? Because, as you can easily see, SALES-REPORT is not a record; it's an internal file.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1053
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: creating a report

Postby Robert Sample » Mon Apr 18, 2016 4:36 am

Id really appreciate any kind of help.
Yet you managed to NOT tell us which platform you are using -- Unix? Windows? Nor did you tell us which COBOL compiler you are using, and there are a number of them out there for each platform. Most compilers provide some information about the line number of the error and you did not provide us any of that either.

If you want help, you need to provide at least basic information about what you are doing and what you are doing it on. I checked your code on an Enterprise COBOL compiler, and it didn't like the file assignments nor ORGANIZATION IS LINE-SEQUENTIAL but everything else was accepted.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 222 times

Re: creating a report

Postby diwas » Wed Apr 20, 2016 10:44 am

Robert, thanks for your reply. I am using a MIcro Focus compiler on windows. Its giving me an error on every instance of "Sales-Report".
diwas
 
Posts: 2
Joined: Mon Apr 18, 2016 12:53 am
Has thanked: 0 time
Been thanked: 0 time

Re: creating a report

Postby prino » Wed Apr 20, 2016 3:14 pm

diwas wrote:I am using a MIcro Focus compiler on windows

And you have seen the header of this forum?

IBM MAINFRAME FORUM

A Help & Support Forum for Mainframe Beginners


Try Usenet, news://comp.lang.cobol
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 536
Joined: Wed Mar 11, 2009 12:22 am
Location: Oostende, Belgium
Has thanked: 3 times
Been thanked: 21 times

Re: creating a report

Postby Robert Sample » Wed Apr 20, 2016 4:36 pm

You will need to find a Microfocus COBOL forum. As I said, your code compiles fine on the mainframe so the issue is something with Microfocus. It is not a COBOL issue - just Microfocus.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 222 times

Re: creating a report

Postby BillyBoyo » Wed Apr 20, 2016 10:26 pm

I think the comments following the SELECTS (odd place to put comments) indicate the changes to allow compile on z/OS.

The action suggested in the comments needs to be taken.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post