Output incorrect



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

Output incorrect

Postby cwseay » Sat Jun 29, 2019 5:21 am

In the output, where the page is supposed to advance 2 lines it does not, and it places a number in the place where the 2 line advance is supposed to occur.

Here is what the report should look like:
DATE:  06/26/2019           YEAR-TO-DATE SALES REPORT                 PAGE:    1
 TIME:  23:53                                                          RPT1000

 CUST                            SALES         SALES
 NUM    CUSTOMER NAME           THIS YTD      LAST YTD011110  INFORMATION BUILDERS    1,234.56      1,111.11

 12340  CAREER TRAINING CTR     1,234.56     71,111.12
 22220  HOMELITE TEXTRON CO    34,545.00          0.00
 45670  NEAS MEMBER BENEFITS      123.45     67,890.12
 55550  PILOT LIFE INS. CO.    10,000.00      1,000.00
 01110  DAUPHIN DEPOSIT BANK   11,111.11     11,111.11
 43210  AIRCRAFT OWNERS ASSC    5,426.12     40,420.00
 43210  NORFOLK CORP           11,111.11     11,111.11
 21210  GENERAL SERVICES CO.   11,444.00     11,059.56
 21210  INFO                   11,111.11     11,111.11
 11110  MANAGEMENT CO.         17,481.45     11,892.47
 99990  DOLLAR SAVINGS BANK     5,059.00      4,621.91
 11110  NATL MUSIC CORP.        2,383.46      4,435.26
 
                            122,264.93    246,874.88



Here is what is written to SYSOUT:


1DATE:  06/26/2019           YEAR-TO-DATE SALES REPORT                 PAGE:    1
 TIME:  23:53                                                          RPT1000
0CUST                            SALES         SALES
 NUM    CUSTOMER NAME           THIS YTD      LAST YTD
011110  INFORMATION BUILDERS    1,234.56      1,111.11
 12340  CAREER TRAINING CTR     1,234.56     71,111.12
 22220  HOMELITE TEXTRON CO    34,545.00          0.00
 45670  NEAS MEMBER BENEFITS      123.45     67,890.12
 55550  PILOT LIFE INS. CO.    10,000.00      1,000.00
 01110  DAUPHIN DEPOSIT BANK   11,111.11     11,111.11
 43210  AIRCRAFT OWNERS ASSC    5,426.12     40,420.00
 43210  NORFOLK CORP           11,111.11     11,111.11
 21210  GENERAL SERVICES CO.   11,444.00     11,059.56
 21210  INFO                   11,111.11     11,111.11
 11110  MANAGEMENT CO.         17,481.45     11,892.47
 99990  DOLLAR SAVINGS BANK     5,059.00      4,621.91
 11110  NATL MUSIC CORP.        2,383.46      4,435.26
0                             122,264.93    246,874.88



Here is the source code:
      IDENTIFICATION DIVISION.

       PROGRAM-ID. RPT1000.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

           SELECT CUSTMAST ASSIGN TO CUSTMAST.
           SELECT SALESRPT ASSIGN TO SALESRPT.

       DATA DIVISION.

       FILE SECTION.

       FD  CUSTMAST.

       01  CUSTOMER-MASTER-RECORD.
           05  CM-BRANCH-NUMBER        PIC 9(2).
           05  CM-SALESREP-NUMBER      PIC 9(2).
           05  CM-CUSTOMER-NUMBER      PIC 9(5).
           05  CM-CUSTOMER-NAME        PIC X(20).
           05  CM-SALES-THIS-YTD       PIC S9(5)V9(2).
           05  CM-SALES-LAST-YTD       PIC S9(5)V9(2).

       FD  SALESRPT.

       01  PRINT-AREA      PIC X(132).

       WORKING-STORAGE SECTION.

       01  SWITCHES.
           05  CUSTMAST-EOF-SWITCH     PIC X    VALUE "N".

       01  PRINT-FIELDS.
           05  PAGE-COUNT      PIC S9(3)   VALUE ZERO.
           05  LINES-ON-PAGE   PIC S9(3)   VALUE +55.
           05  LINE-COUNT      PIC S9(3)   VALUE +99.
           05  SPACE-CONTROL   PIC S9.

       01  TOTAL-FIELDS.
           05  GRAND-TOTAL-THIS-YTD   PIC S9(7)V99   VALUE ZERO.
           05  GRAND-TOTAL-LAST-YTD   PIC S9(7)V99   VALUE ZERO.

       01  CURRENT-DATE-AND-TIME.
           05  CD-YEAR         PIC 9999.
           05  CD-MONTH        PIC 99.
           05  CD-DAY          PIC 99.
           05  CD-HOURS        PIC 99.
           05  CD-MINUTES      PIC 99.
           05  FILLER          PIC X(9).
     
       01  HEADING-LINE-1.
           05  FILLER          PIC X(7)    VALUE "DATE:  ".
           05  HL1-MONTH       PIC 9(2).
           05  FILLER          PIC X(1)    VALUE "/".
           05  HL1-DAY         PIC 9(2).
           05  FILLER          PIC X(1)    VALUE "/".
           05  HL1-YEAR        PIC 9(4).
           05  FILLER          PIC X(11)   VALUE SPACE.
           05  FILLER          PIC X(20)   VALUE "YEAR-TO-DATE SALES R".
           05  FILLER          PIC X(20)   VALUE "EPORT               ".
           05  FILLER          PIC X(8)    VALUE "  PAGE: ".
           05  Hl1-PAGE-NUMBER PIC ZZZ9.
           05  FILLER          PIC X(52)   VALUE SPACE.
     
       01  HEADING-LINE-2.
           05  FILLER          PIC X(7)    VALUE "TIME:  ".
           05  HL2-HOURS       PIC 9(2).
           05  FILLER          PIC X(1)    VALUE ":".
           05  HL2-MINUTES     PIC 9(2).
           05  FILLER          PIC X(58)   VALUE SPACE.
           05  FILLER          PIC X(10)   VALUE "RPT1000".
           05  FILLER          PIC X(52)   VALUE SPACE.
     
       01  HEADING-LINE-3.
           05  FILLER      PIC X(20)   VALUE "CUST                ".
           05  FILLER      PIC X(20)   VALUE "            SALES   ".
           05  FILLER      PIC X(20)   VALUE "      SALES         ".
           05  FILLER      PIC X(72)   VALUE SPACE.
     
       01  HEADING-LINE-4.
           05  FILLER      PIC X(20)   VALUE "NUM    CUSTOMER NAME".
           05  FILLER      PIC X(20)   VALUE "           THIS YTD ".
           05  FILLER      PIC X(20)   VALUE "     LAST YTD       ".
           05  FILLER      PIC X(72)   VALUE SPACE.
     
       01  CUSTOMER-LINE.
           05  CL-CUSTOMER-NUMBER  PIC 9(5).
           05  FILLER              PIC X(2)     VALUE SPACE.
           05  CL-CUSTOMER-NAME    PIC X(20).
           05  FILLER              PIC X(3)     VALUE SPACE.
           05  CL-SALES-THIS-YTD   PIC ZZ,ZZ9.99-.
           05  FILLER              PIC X(4)     VALUE SPACE.
           05  CL-SALES-LAST-YTD   PIC ZZ,ZZ9.99-.
           05  FILLER              PIC X(78)    VALUE SPACE.
     
       01  GRAND-TOTAL-LINE.
           05  FILLER              PIC X(27)    VALUE SPACE.
           05  GTL-SALES-THIS-YTD  PIC Z,ZZZ,ZZ9.99-.
           05  FILLER              PIC X(1)     VALUE SPACE.
           05  GTL-SALES-LAST-YTD  PIC Z,ZZZ,ZZ9.99-.
           05  FILLER              PIC X(78)    VALUE SPACE.
     
       PROCEDURE DIVISION.
     
       000-PREPARE-SALES-REPORT.
     
           OPEN INPUT  CUSTMAST
                OUTPUT SALESRPT.
           PERFORM 100-FORMAT-REPORT-HEADING.
           PERFORM 200-PREPARE-SALES-LINES
               UNTIL CUSTMAST-EOF-SWITCH = "Y".
           PERFORM 300-PRINT-GRAND-TOTALS.
           CLOSE CUSTMAST
                 SALESRPT.
           STOP RUN.
     
       100-FORMAT-REPORT-HEADING.
     
           MOVE FUNCTION CURRENT-DATE TO CURRENT-DATE-AND-TIME.
           MOVE CD-MONTH   TO HL1-MONTH.
           MOVE CD-DAY     TO HL1-DAY.
           MOVE CD-YEAR    TO HL1-YEAR.
           MOVE CD-HOURS   TO HL2-HOURS.
           MOVE CD-MINUTES TO HL2-MINUTES.
     
       200-PREPARE-SALES-LINES.
     
           PERFORM 210-READ-CUSTOMER-RECORD.
           IF CUSTMAST-EOF-SWITCH = "N"
               PERFORM 220-PRINT-CUSTOMER-LINE.
     
       210-READ-CUSTOMER-RECORD.
     
           READ CUSTMAST
               AT END
                   MOVE "Y" TO CUSTMAST-EOF-SWITCH.
     
       220-PRINT-CUSTOMER-LINE.
     
           IF LINE-COUNT >= LINES-ON-PAGE
               PERFORM 230-PRINT-HEADING-LINES.
           MOVE CM-CUSTOMER-NUMBER  TO CL-CUSTOMER-NUMBER.
           MOVE CM-CUSTOMER-NAME    TO CL-CUSTOMER-NAME.
           MOVE CM-SALES-THIS-YTD   TO CL-SALES-THIS-YTD.
           MOVE CM-SALES-LAST-YTD   TO CL-SALES-LAST-YTD.
           MOVE CUSTOMER-LINE TO PRINT-AREA.
           WRITE PRINT-AREA AFTER ADVANCING SPACE-CONTROL LINES.
           ADD 1 TO LINE-COUNT.
           ADD CM-SALES-THIS-YTD TO GRAND-TOTAL-THIS-YTD.
           ADD CM-SALES-LAST-YTD TO GRAND-TOTAL-LAST-YTD.
           MOVE 1 TO SPACE-CONTROL.

       230-PRINT-HEADING-LINES.

           ADD 1 TO PAGE-COUNT.
           MOVE PAGE-COUNT     TO HL1-PAGE-NUMBER.
           MOVE HEADING-LINE-1 TO PRINT-AREA.
           WRITE PRINT-AREA AFTER ADVANCING PAGE.
           MOVE HEADING-LINE-2 TO PRINT-AREA.
           WRITE PRINT-AREA AFTER ADVANCING 1 LINES.
           MOVE HEADING-LINE-3 TO PRINT-AREA.
           WRITE PRINT-AREA AFTER ADVANCING 2 LINES.
           MOVE HEADING-LINE-4 TO PRINT-AREA.
           WRITE PRINT-AREA AFTER ADVANCING 1 LINES.
           MOVE ZERO TO LINE-COUNT.
           MOVE 2 TO SPACE-CONTROL.

       300-PRINT-GRAND-TOTALS.

           MOVE GRAND-TOTAL-THIS-YTD TO GTL-SALES-THIS-YTD.
           MOVE GRAND-TOTAL-LAST-YTD TO GTL-SALES-LAST-YTD.
           MOVE GRAND-TOTAL-LINE     TO PRINT-AREA.
           WRITE PRINT-AREA AFTER ADVANCING 2 LINES.
 


The program compiles, links, and runs error free.
Thanks!
cwseay
 
Posts: 16
Joined: Thu Oct 05, 2017 8:28 am
Has thanked: 4 times
Been thanked: 0 time

Re: Output incorrect

Postby Robert Sample » Sat Jun 29, 2019 7:45 am

Research mainframe carriage control. Broadly, mainframe systems have (for 50 years and more) used the first column of output for carriage control. A 1 in the first column (which your output shows) tells the printer to advance to the next page; a space tells the printer to advance to the next line; a zero tells the printer to advance 2 lines; there are other characters possible.

In other words, the output you are seeing is normal and expected for when the printer (or terminal) does not honor the mainframe carriage control. The output is NOT incorrect -- your understanding is lacking.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Output incorrect

Postby steve-myers » Sat Jun 29, 2019 5:28 pm

Mr. Sample is correct about the carriage control. The convention has been in place for more than 60 years, possibly as much as 70 years.

blank - Start a new line
0 - Insert a blank line and then print the line
- - Insert two blank lines and print the line
+ - Do not move the carriage and print the line
1 - The line starts on the first line of a new page

As Mr. Sample indicated, there are more, but they are usually considered risky and should be avoided unless you really know what you are doing AND the printer is setup to recognize them. The 0 and - carriage control characters are more important than most beginners appreciate: 60 years ago it was usually faster for the printer to skip a line than to "print" a line containing blanks. Believe me, it was noticeable and made a difference.

Now I can discuss the origin of the 1 carriage control. 60 years ago printers had a looped paper tape. There were 12 hoizontal positions on the tape, 1 through 12. The convention was a hole in position 1 defined the start of a page. Use Google or Bing to search for carriage control tape. Google works much better for this search!
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Output incorrect

Postby resh_97 » Fri Apr 03, 2020 3:15 pm

hi,
i am facing the same issue...were u able to find a soln? and can u tell me where the carriage control is being defined in your source code?i am completely new to this
resh_97
 
Posts: 3
Joined: Fri Apr 03, 2020 2:53 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Output incorrect

Postby NicC » Fri Apr 03, 2020 3:18 pm

Do not tailgate other people's topics. Do not post the same query twice.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post