Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie Stuck on First Real Program (help!) 1

Status
Not open for further replies.

ZenAbra

Technical User
Aug 20, 2001
5
US
Hi All--

I already posted this in the Fujitsu forum, but I'm not sure which forum would be more accurate for my issue, so I'm cross-posting. I sincerely apologize if this bothers someone.

Hi All--

I'd really, really appreciate some help!

I'm totally new to COBOL, and I'm using the Fujitsu 4.0 compiler. I'm *this* close to having a program done (I think, hehe), but I think I'm getting multiple compile errors from only a couple of mistakes.

My program reads from a simple flatfile with several columns, sorts the data by one column, then prints a single page report with three summary lines and date & time stamps. Well, it doesn't do that, yet, but that's the goal. :)

Would it be possible to either email my code to someone for some advice or post it here for some response? I'm at a point where I'm just getting frustrated, and I'd really, really appreciate if someone could nudge me in the right direction.

Thank you so much.

ZenAbra
 
Just post it, that way everyone can have a look.
 
Wow... well, I REALLY appreciate everyone looking at my cruddy code. :)

I apologize if it seems like a long post, but I think I've seen a few long code examples, so here goes... the Orders Report, unabridged:

IDENTIFICATION DIVISION.
************************

PROGRAM-ID. ORDERSRPT.
AUTHOR. D. Johnston.
DATE-WRITTEN. AUGUST 18, 2001.
DATE-COMPILED. AUGUST ?, 2001.
******************************************************************
* PROGRAM NARRATIVE *
* *
* THE ORDERS FILE IS SORTED BY COMPANY NAME. THIS *
* PROGRAM THEN PRINTS THE CUSTOMER ID, CUSTOMER NAME, MODEL *
* QUANTITY ORDERED PER CUSTOMER, THE CONTRACT TERM, THE *
* MONTHLY CHARGE, AND THE TOTAL COST OF THAT CONTRACT. AT THE *
* END OF THE REPORT, THE PROGRAM TALLIES THE TOTAL CONTRACT *
* AMOUNT, THE TOTAL NUMBER OF CUSTOMERS, AND THE TOTAL NUMBER *
* OF UNITS LEASED. *
* *
* INPUT: FLATFILE.DAT - ORDERS REPORT *
* *
* *
* SORT FILE: SORT-WORK - SORT BY COMPANY NAME *
* *
* *
* OUTPUT: PRINTER - NEW ORDERS REPORT *
* *
* *
******************************************************************
/
ENVIRONMENT DIVISION.
**********************

INPUT-OUTPUT SECTION.
**********************

FILE-CONTROL.

SELECT ORDERS-REPORT
ASSIGN TO "FLATFILE.DAT".

SELECT SORT-FILE
ASSIGN TO SORT-WORK.

SELECT SORTED-ORDERS-REPORT
ASSIGN TO "SORTED-ORDERS.DAT".

SELECT NEW-ORDERS-REPORT
ASSIGN TO PRINTER.


/
DATA DIVISION.
***************

FILE SECTION.
**************

******************************************************************
* *
* INPUT FILE - ORDERS FILE *
* *
******************************************************************

FD ORDERS-REPORT.

01 ORDERS-REC PIC X(73).

******************************************************************
* *
* SORT FILE - SORT OF ORDERS FILE *
* *
******************************************************************

SD SORT-FILE.

01 SORT-REC.
02 PIC X(11).
02 SR-COMPANY-NAME PIC X(23).
02 PIC X(39).
/
******************************************************************
* *
* SORTED FILE - SORTED ORDERS FILE *
* *
******************************************************************

FD SORTED-ORDERS-REPORT.

01 SORTED-ORDERS-REC PIC X(73).

******************************************************************
* *
* REPORT FILE - NEW ORDERS REPORT *
* *
******************************************************************

FD NEW-ORDERS-REPORT.

01 LINE-OUT PIC X(73).
/
* WORKING-STORAGE SECTION.
************************

******************************************************************
* *
* SWITCHES *
* *
******************************************************************

01 SWITCHES.

02 SW-END-OF-FILE PIC X.
88 END-OF-FILE VALUE "Y".

******************************************************************
* *
* ACCUMULATORS *
* *
******************************************************************

01 ACCUMULATORS.

02 AC-TOTAL-CONTRACTS PIC 9(4).
02 AC-TOTAL-CUSTOMERS PIC 99.
02 AC-TOTAL-QUANTITY PIC 99.
/
*****************************************************************
* *
* WORK AREA *
* *
*****************************************************************

01 WORK-AREA.

02 WA-TODAYS-DATE-TIME.
03 WA-TODAYS-DATE.
04 WA-TODAYS-YEAR PIC 9(4).
04 WA-TODAYS-MONTH PIC 99.
04 WA-TODAYS-DAY PIC 99.
03 WA-TODAYS-TIME.
04 WA-TODAYS-HOUR PIC 99.
04 WA-TODAYS-MINUTES PIC 99.
03 PIC X(9).

02 WA-DATE.
03 WA-MONTH PIC 99.
03 WA-DAY PIC 99.
03 WA-YEAR PIC 9(4).

02 WA-RUN-DATE REDEFINES
WA-DATE PIC 9(8).

02 WA-SAVE PIC X(23).


/

******************************************************************
* *
* *
* ORDERS RECORD LAYOUT *
* *
* *
******************************************************************


01 ORDERS-REC.

02 OR-CUSTOMER-ID PIC X(11).
02 OR-COMPANY-NAME PIC X(23).
02 OR-MODEL PIC X(10).
02 OR-QUANTITY PIC 9(9).
02 OR-TERM PIC X(6).
02 OR-MONTHLY PIC X(9).
02 OR-CONTRACT PIC 9(4).

/
******************************************************************
* *
* REPORT HEADINGS FOR NEW ORDERS REPORT *
* *
******************************************************************

01 REPORT-HEADINGS.

02 RH-LINE-1.
03 PIC X(10) VALUE
"RUN DATE: ".
03 RH-DATE PIC 9(18).
03 PIC X(22) VALUE SPACES.
03 PIC X(5) VALUE "PAGE".

02 RH-LINE-2.
03 PIC X(9) VALUE
"RUN TIME:".
03 PIC XX VALUE SPACES.
03 RH-HOUR PIC Z9.
03 PIC X VALUE ":".
03 RH-MINUTES PIC 99.
03 PIC X VALUE SPACES.
03 RH-AM-PM PIC XX.
03 PIC X(5) VALUE SPACES.
03 PIC X(26) VALUE
"LEASE LEASUM ORDERS REPORT".

02 RH-LINE-3.
03 PIC X(8) VALUE
"CUSTOMER".
03 PIC X(52) VALUE SPACES.
03 PIC X(7) VALUE
"MONTHLY".
03 PIC XX VALUE SPACES.
03 PIC x(8) VALUE
"CONTRACT".

02 RH-LINE-4.
03 PIC XX VALUE
"ID".
03 PIC X(9) VALUE SPACES.
03 PIC X(12) VALUE
"COMPANY NAME".
03 PIC X(11) VALUE SPACES.
03 PIC X(5) VALUE
"MODEL".
03 PIC X(5) VALUE SPACES.
03 PIC X(8) VALUE
"QUANTITY".
03 PIC XX VALUE SPACES.
03 PIC X(4) VALUE
"TERM".
03 PIC XX VALUE SPACES.
03 PIC X(5) VALUE
"CHARGE".
03 PIC XXX VALUE SPACES.
03 PIC X(5) VALUE
"TOTAL".

02 RH-LINE-5.
03 PIC X(8) VALUE ALL"-".
03 PIC X(3) VALUE SPACES.
03 PIC X(20) VALUE ALL "-".
03 PIC X(3) VALUE SPACES.
03 PIC X(8) VALUE ALL "-".
03 PIC X(2) VALUE SPACES.
03 PIC X(8) VALUE ALL "-".
03 PIC X(2) VALUE SPACES.
03 PIC X(4) VALUE ALL "-".
03 PIC X(2) VALUE SPACES.
03 PIC X(7) VALUE ALL "-".
03 PIC X(2) VALUE SPACES.
03 PIC X(8) VALUE ALL "-".

/
******************************************************************
* *
* DETAIL LINE FOR NEW ORDERS REPORT *
* *
******************************************************************

01 DETAIL-LINE.
02 DL-CUSTOMER-ID PIC X(11).
02 DL-COMPANY-NAME PIC X(23).
02 DL-MODEL PIC X(10).
02 DL-QUANTITY PIC 9(9).
02 DL-TERM PIC X(6).
02 DL-MONTHLY PIC X(9).
02 DL-CONTRACT PIC 9(4).
/
******************************************************************
* *
* SUMMARY LINES FOR NEW ORDERS REPORT *
* *
******************************************************************

01 SUMMARY-LINES.

02 SL-LINE-1.
03 PIC X(16) VALUE SPACES.
03 PIC X(24) VALUE
"TOTAL CONTRACT AMOUNT = ".
03 SL-TOTAL-CONTRACTS PIC $ZZ,ZZ9.99.

02 SL-LINE-2.
03 PIC X(12) VALUE SPACES.
03 PIC X(28) VALUE
"Total Number of Customers = ".
03 SL-TOTAL-CUSTOMERS PIC 99.

02 SL-LINE-3.
03 PIC X(9) VALUE SPACES.
03 PIC X(31) VALUE
"TOTAL NUMBER OF UNITS LEASED = ".
03 SL-TOTAL-QUANTITY PIC 99

02 SL-LINE-4.
03 PIC X(34) VALUE SPACES.
03 PIC X(13) VALUE
"END OF REPORT".
/
PROCEDURE DIVISION.
*******************
******************************************************************
* *
* MAIN-PROGRAM. THIS IS THE MAIN PARAGRAPH OF THIS PROGRAM *
* *
******************************************************************

MAIN-PROGRAM.

PERFORM A-100-INITIALIZATION.
PERFORM B-100-PROCESS-FILE.
PERFORM C-100-WRAP-UP.
STOP RUN.

******************************************************************
* *
* THE INITIALIZATION PARAGRAPH FOLLOWS *
* *
******************************************************************

A-100-INITIALIZATION.

INITIALIZE ACCUMULATORS
MOVE ZERO TO AC-TOTAL-CONTRACTS
AC-TOTAL-CUSTOMERS
AC-TOTAL-QUANTITY.

MOVE FUNCTION CURRENT-DATE TO WA-TODAYS-DATE-TIME.
MOVE WA-TODAYS-MONTH TO WA-MONTH.
MOVE WA-TODAYS-DAY TO WA-DAY.
MOVE WA-TODAYS-YEAR TO WA-YEAR.


SORT SORT-FILE
ON ASCENDING KEY SR-COMPANY-NAME
USING ORDERS-REPORT
GIVING SORTED-ORDERS-REPORT.
/
******************************************************************
* *
* REPORT PROCESSING PARAGRAPH *
* *
******************************************************************

B-100-PROCESS-FILE.

OPEN INPUT SORTED-ORDERS-REPORT
OUTPUT NEW-ORDERS-REPORT.

MOVE "N" TO SW-END-OF-FILE.

READ SORTED-ORDERS-REPORT INTO ORDERS-RECORD
AT END MOVE "Y" TO SW-END-OF-FILE.

MOVE OR-COMPANY-NAME TO WA-SAVE.

PERFORM B-300-PRINT-HEADINGS.

PERFORM B-200-PROCESS-RECORDS
UNTIL END-OF-FILE.

MOVE AC-TOTAL-CONTRACTS TO SL-TOTAL-CONTRACTS.
MOVE AC-TOTAL-CUSTOMERS TO SL-TOTAL-CUSTOMERS.
MOVE AC-TOTAL-QUANTITY TO SL-TOTAL-QUANTITY.


WRITE LINE-OUT FROM SL-LINE-1
AFTER ADVANCING 3 LINES.
WRITE LINE-OUT FROM SL-LINE-2
AFTER ADVANCING 1 LINE.
WRITE LINE-OUT FROM SL-LINE-3
AFTER ADVANCING 1 LINE.
WRITE LINE-OUT FROM SL-LINE-4
AFTER ADVANCING 1 LINE.
WRITE LINE-OUT FROM SL-LINE-5
AFTER ADVANCING 2 LINES.
/
******************************************************************
* *
* RECORD PROCESSING PARAGRAPH *
* *
******************************************************************

B-200-PROCESS-RECORDS.

MOVE OR-CUSTOMER-ID TO DL-CUSTOMER-ID.

IF OR-COMPANY-NAME NOT = WA-SAVE
ADD 1 TO AC-TOTAL-CUSTOMERS.

MOVE OR-COMPANY-NAME TO DL-COMPANY-NAME.
MOVE OR-COMPANY-NAME TO WA-SAVE.

MOVE OR-MODEL TO DL-MODEL.

ADD OR-QUANTITY TO AC-TOTAL-QUANTITY.
MOVE OR-QUANTITY TO DL-QUANTITY.

MOVE OR-TERM TO DL-TERM.
MOVE OR-MONTHLY TO DL-MONTHLY.

ADD OR-CONTRACT TO AC-TOTAL-CONTRACTS.
MOVE OR-CONTRACT TO DL-CONTRACT.

WRITE LINE-OUT FROM DETAIL-LINE
AFTER ADVANCING 1 LINE.

READ SORTED-ORDERS-REPORT INTO ORDERS-RECORD
AT END MOVE "Y" TO SW-END-OF-FILE.
/
******************************************************************
* *
* PAGE HEADING PARAGRAPH *
* *
******************************************************************

B-300-PRINT-HEADINGS.

WRITE LINE-OUT FROM RH-LINE-1
AFTER ADVANCING 1 LINE.
WRITE LINE-OUT FROM RH-LINE-2
AFTER ADVANCING 1 LINE.
WRITE LINE-OUT FROM RH-LINE-3
AFTER ADVANCING 2 LINES.
WRITE LINE-OUT FROM RH-LINE-4
AFTER ADVANCING 1 LINE.
WRITE LINE-OUT FROM RH-LINE-5
AFTER ADVANCING 1 LINE.

/
******************************************************************
* *
* END OF JOB PARAGRAPH *
* *
******************************************************************

C-100-WRAP-UP.

CLOSE SORTED-ORDERS-REPORT
NEW-ORDERS-REPORT.
DISPLAY " ".
DISPLAY "ORDERS REPORT PROGRAM HAS TERMINATED".
DISPLAY " ".

******************************************************************
* END OF PROGRAM *
******************************************************************
/
 
Sorry, i meant to say put it here so we can all have a laugh!!

but seriously...

what are the error messages you are getting?
bruce08.gif
 
You may want to say what Compiler you are using and what type of computer OS it is running on.

Example: "Fujitsu compiler on an IBM PC"

On a first program often the problem may be the Assign statements and the access methods for the files.
If you say "file.dat" how does the compiler know where that file is at? Better be running it in the same location as the program or it will not find it.

Sometimes you have to insert an "ACCESS IS LINE SEQUENTIAL" statement on a PC file with line returns. How is the file organized? Is it a continuous file, with each record runs end to end, or is each record on a separate line. You can tell if you look at it in Notepad if you are using Windows. The compiler may hava a default access of "sequential".

Tell us the errors word for word.

Is this a control break program with sub-totals after each break?

If you do not like my post feel free to point out your opinion or my errors.
 
Thank you all for the excellent help... almost there!

(I'm running Fujitsu 4.0 and my source & .dat files are both in the A: drives root directory)

Through the help of emails from a couple of people from the forum I've got it compiling & linking without errors... but now when I execute it doesn't seem to process the detail lines properly (or at all).

My header lines & summary lines print out perfectly (except the totals for the summary lines are just "0"), but I get a dense series of strange box symbols where my detail lines should print.

I'm not sure if this is a problem with how I coded my detail lines, my sort, or if it's something I'm doing wrong with the .dat file that the program is supposed to read.

Right now I have the .dat file in the same directory (the A: drive's root directory) as the source code and the executable. It's a sequential file with all data in a single, streaming line (no carriage returns).

Should I format the .dat file? Should I place the .dat and source files in different (not separate, just different) locations?

I'm sorry to ramble on... but I'm so close and I just can't figure out what I'm doing wrong. It seems like it might be something outside of the code itself. I'm running Fujitu 4.0 for my compiler.

I REALLY, really would appreciate any assistance you might provide.

To re-emphasize: it compiles fine, links fine, but doesn't seem to execute the detail lines at all.

Here's the compiling & linking properly but not executing properly version of the code:


******************************************************************
* PROGRAM NARRATIVE *
* *
* THE ORDERS FILE IS SORTED BY COMPANY NAME. THIS *
* PROGRAM THEN PRINTS THE CUSTOMER ID, CUSTOMER NAME, MODEL *
* QUANTITY ORDERED PER CUSTOMER, THE CONTRACT TERM, THE *
* MONTHLY CHARGE, AND THE TOTAL COST OF THAT CONTRACT. AT THE *
* END OF THE REPORT, THE PROGRAM TALLIES THE TOTAL CONTRACT *
* AMOUNT, THE TOTAL NUMBER OF CUSTOMERS, AND THE TOTAL NUMBER *
* OF UNITS LEASED. *
* *
* INPUT: FLATFILE.DAT - ORDERS REPORT *
* *
* *
* SORT FILE: SORT-WORK - SORT BY COMPANY NAME *
* *
* *
* OUTPUT: PRINTER - NEW ORDERS REPORT *
* *
* *
******************************************************************
/
ENVIRONMENT DIVISION.
**********************

INPUT-OUTPUT SECTION.
**********************

FILE-CONTROL.

SELECT ORDERS-REPORT
ASSIGN TO "A:FLATFILE.DAT".

SELECT SORT-FILE
ASSIGN TO SORT-WORK.

SELECT SORTED-ORDERS-REPORT
ASSIGN TO "A:SORTED-ORDERS.DAT".

SELECT NEW-ORDERS-REPORT
ASSIGN TO PRINTER.


/
DATA DIVISION.
***************

FILE SECTION.
**************

******************************************************************
* *
* INPUT FILE - ORDERS FILE *
* *
******************************************************************

FD ORDERS-REPORT.

01 ORDERS-REC PIC X(80).

******************************************************************
* *
* SORT FILE - SORT OF ORDERS FILE *
* *
******************************************************************

SD SORT-FILE.

01 SORT-REC.
02 PIC X(11).
02 SR-COMPANY-NAME PIC X(23).
02 PIC X(46).
/
******************************************************************
* *
* SORTED FILE - SORTED ORDERS FILE *
* *
******************************************************************

FD SORTED-ORDERS-REPORT.

01 SORTED-ORDERS-REC PIC X(80).

******************************************************************
* *
* REPORT FILE - NEW ORDERS REPORT *
* *
******************************************************************

FD NEW-ORDERS-REPORT.

01 LINE-OUT PIC X(80).
/
WORKING-STORAGE SECTION.
************************

******************************************************************
* *
* SWITCHES *
* *
******************************************************************

01 SWITCHES.

02 SW-END-OF-FILE PIC X.
88 END-OF-FILE VALUE "Y".

******************************************************************
* *
* ACCUMULATORS *
* *
******************************************************************

01 ACCUMULATORS.

02 AC-TOTAL-CONTRACTS PIC 9(4).
02 AC-TOTAL-CUSTOMERS PIC 99.
02 AC-TOTAL-QUANTITY PIC 99.
/
*****************************************************************
* *
* WORK AREA *
* *
*****************************************************************

01 WORK-AREA.

02 WA-TODAYS-DATE-TIME.
03 WA-TODAYS-DATE.
04 WA-TODAYS-YEAR PIC 9(4).
04 WA-TODAYS-MONTH PIC 99.
04 WA-TODAYS-DAY PIC 99.
03 WA-TODAYS-TIME.
04 WA-TODAYS-HOUR PIC 99.
04 WA-TODAYS-MINUTES PIC 99.
03 PIC X(9).

02 WA-DATE.
03 WA-MONTH PIC 99.
03 WA-DAY PIC 99.
03 WA-YEAR PIC 9(4).

02 WA-RUN-DATE REDEFINES
WA-DATE PIC 9(8).

02 WA-SAVE PIC X(23).

02 SORTED-ORDERS-RECORD PIC X(80).


/

******************************************************************
* *
* *
* ORDERS RECORD LAYOUT *
* *
* *
******************************************************************


01 ORDERS-REC.

02 OR-CUSTOMER-ID PIC X(11).
02 OR-COMPANY-NAME PIC X(23).
02 OR-MODEL PIC X(10).
02 OR-QUANTITY PIC 9(9).
02 OR-TERM PIC X(6).
02 OR-MONTHLY PIC X(9).
02 OR-CONTRACT PIC 9(4).

/
******************************************************************
* *
* REPORT HEADINGS FOR NEW ORDERS REPORT *
* *
******************************************************************

01 REPORT-HEADINGS.

02 RH-LINE-1.
03 PIC X(10) VALUE
"RUN DATE: ".
03 RH-DATE PIC X(18).
03 PIC X(42) VALUE SPACES.
03 PIC X(6) VALUE
"PAGE 1".

02 RH-LINE-2.
03 PIC X(10) VALUE
"RUN TIME: ".
03 RH-HOUR PIC Z9.
03 PIC X VALUE ":".
03 RH-MINUTES PIC 99.
03 PIC X VALUE SPACES.
03 RH-AM-PM PIC XX.
03 PIC X(5) VALUE SPACES.
03 PIC X(26) VALUE
"LEASE LEASUM ORDERS REPORT".

02 RH-LINE-3.
03 PIC X(8) VALUE
"CUSTOMER".
03 PIC X(52) VALUE SPACES.
03 PIC X(7) VALUE
"MONTHLY".
03 PIC XX VALUE SPACES.
03 PIC x(8) VALUE
"CONTRACT".

02 RH-LINE-4.
03 PIC XX VALUE
"ID".
03 PIC X(9) VALUE SPACES.
03 PIC X(12) VALUE
"COMPANY NAME".
03 PIC X(11) VALUE SPACES.
03 PIC X(5) VALUE
"MODEL".
03 PIC X(5) VALUE SPACES.
03 PIC X(8) VALUE
"QUANTITY".
03 PIC XX VALUE SPACES.
03 PIC X(4) VALUE
"TERM".
03 PIC XX VALUE SPACES.
03 PIC X(6) VALUE
"CHARGE".
03 PIC XXX VALUE SPACES.
03 PIC X(5) VALUE
"TOTAL".

02 RH-LINE-5.
03 PIC X(8) VALUE ALL "-".
03 PIC X(3) VALUE SPACES.
03 PIC X(20) VALUE ALL "-".
03 PIC X(3) VALUE SPACES.
03 PIC X(8) VALUE ALL "-".
03 PIC X(2) VALUE SPACES.
03 PIC X(8) VALUE ALL "-".
03 PIC X(2) VALUE SPACES.
03 PIC X(4) VALUE ALL "-".
03 PIC X(2) VALUE SPACES.
03 PIC X(7) VALUE ALL "-".
03 PIC X(2) VALUE SPACES.
03 PIC X(8) VALUE ALL "-".

/
******************************************************************
* *
* DETAIL LINE FOR NEW ORDERS REPORT *
* *
******************************************************************

01 DETAIL-LINE.
02 DL-CUSTOMER-ID PIC X(11).
02 DL-COMPANY-NAME PIC X(23).
02 DL-MODEL PIC X(10).
02 DL-QUANTITY PIC 9(9).
02 DL-TERM PIC X(6).
02 DL-MONTHLY PIC X(9).
02 DL-CONTRACT PIC 9(4).
/
******************************************************************
* *
* SUMMARY LINES FOR NEW ORDERS REPORT *
* *
******************************************************************

01 SUMMARY-LINES.

02 SL-LINE-1.
03 PIC X(16) VALUE SPACES.
03 PIC X(24) VALUE
"TOTAL CONTRACT AMOUNT = ".
03 SL-TOTAL-CONTRACTS PIC 9(4).

02 SL-LINE-2.
03 PIC X(12) VALUE SPACES.
03 PIC X(28) VALUE
"TOTAL NUMBER OF CUSTOMERS = ".
03 SL-TOTAL-CUSTOMERS PIC 99.

02 SL-LINE-3.
03 PIC X(9) VALUE SPACES.
03 PIC X(31) VALUE
"TOTAL NUMBER OF UNITS LEASED = ".
03 SL-TOTAL-QUANTITY PIC 99.

02 SL-LINE-4.
03 PIC X(34) VALUE SPACES.
03 PIC X(13) VALUE
"END OF REPORT".
/
PROCEDURE DIVISION.
*******************
******************************************************************
* *
* MAIN-PROGRAM. THIS IS THE MAIN PARAGRAPH OF THIS PROGRAM *
* *
******************************************************************

MAIN-PROGRAM.

PERFORM A-100-INITIALIZATION.
PERFORM B-100-PROCESS-FILE.
PERFORM C-100-WRAP-UP.
STOP RUN.

******************************************************************
* *
* THE INITIALIZATION PARAGRAPH FOLLOWS *
* *
******************************************************************

A-100-INITIALIZATION.

INITIALIZE ACCUMULATORS
MOVE ZERO TO AC-TOTAL-CONTRACTS
AC-TOTAL-CUSTOMERS
AC-TOTAL-QUANTITY.

MOVE FUNCTION CURRENT-DATE TO WA-TODAYS-DATE-TIME.
MOVE WA-TODAYS-MONTH TO WA-MONTH.
MOVE WA-TODAYS-DAY TO WA-DAY.
MOVE WA-TODAYS-YEAR TO WA-YEAR.


SORT SORT-FILE
ON ASCENDING KEY SR-COMPANY-NAME
USING ORDERS-REPORT
GIVING SORTED-ORDERS-REPORT.
/
******************************************************************
* *
* REPORT PROCESSING PARAGRAPH *
* *
******************************************************************

B-100-PROCESS-FILE.

OPEN INPUT SORTED-ORDERS-REPORT
OUTPUT NEW-ORDERS-REPORT.

MOVE "N" TO SW-END-OF-FILE.

READ SORTED-ORDERS-REPORT INTO SORTED-ORDERS-RECORD
AT END MOVE "Y" TO SW-END-OF-FILE.

MOVE OR-COMPANY-NAME TO WA-SAVE.

PERFORM B-300-PRINT-HEADINGS.

PERFORM B-200-PROCESS-RECORDS
UNTIL END-OF-FILE.

MOVE AC-TOTAL-CONTRACTS TO SL-TOTAL-CONTRACTS.
MOVE AC-TOTAL-CUSTOMERS TO SL-TOTAL-CUSTOMERS.
MOVE AC-TOTAL-QUANTITY TO SL-TOTAL-QUANTITY.


WRITE LINE-OUT FROM SL-LINE-1
AFTER ADVANCING 3 LINES.
WRITE LINE-OUT FROM SL-LINE-2
AFTER ADVANCING 1 LINE.
WRITE LINE-OUT FROM SL-LINE-3
AFTER ADVANCING 1 LINE.
WRITE LINE-OUT FROM SL-LINE-4
AFTER ADVANCING 2 LINE.
/
******************************************************************
* *
* RECORD PROCESSING PARAGRAPH *
* *
******************************************************************

B-200-PROCESS-RECORDS.

MOVE OR-CUSTOMER-ID TO DL-CUSTOMER-ID.

IF OR-COMPANY-NAME NOT = WA-SAVE
ADD 1 TO AC-TOTAL-CUSTOMERS.

MOVE OR-COMPANY-NAME TO DL-COMPANY-NAME.
MOVE OR-COMPANY-NAME TO WA-SAVE.

MOVE OR-MODEL TO DL-MODEL.

ADD OR-QUANTITY TO AC-TOTAL-QUANTITY.
MOVE OR-QUANTITY TO DL-QUANTITY.

MOVE OR-TERM TO DL-TERM.
MOVE OR-MONTHLY TO DL-MONTHLY.

ADD OR-CONTRACT TO AC-TOTAL-CONTRACTS.
MOVE OR-CONTRACT TO DL-CONTRACT.

WRITE LINE-OUT FROM DETAIL-LINE
AFTER ADVANCING 1 LINE.

READ SORTED-ORDERS-REPORT INTO SORTED-ORDERS-RECORD
AT END MOVE "Y" TO SW-END-OF-FILE.
/
******************************************************************
* *
* PAGE HEADING PARAGRAPH *
* *
******************************************************************

B-300-PRINT-HEADINGS.

WRITE LINE-OUT FROM RH-LINE-1
AFTER ADVANCING 1 LINE.
WRITE LINE-OUT FROM RH-LINE-2
AFTER ADVANCING 1 LINE.
WRITE LINE-OUT FROM RH-LINE-3
AFTER ADVANCING 2 LINES.
WRITE LINE-OUT FROM RH-LINE-4
AFTER ADVANCING 1 LINE.
WRITE LINE-OUT FROM RH-LINE-5
AFTER ADVANCING 1 LINE.

/
******************************************************************
* *
* END OF JOB PARAGRAPH *
* *
******************************************************************

C-100-WRAP-UP.

CLOSE SORTED-ORDERS-REPORT
NEW-ORDERS-REPORT.
DISPLAY " ".
DISPLAY "ORDERS REPORT PROGRAM HAS TERMINATED".
DISPLAY " ".

******************************************************************
* END OF PROGRAM *
******************************************************************

My goodness... if you've gotten this far... thank you SOOO much!!
 
I'm running Windows 98SE, by the way. The .dat file is formatted like such (as pasted from notepad):

12345789 Hilton Hotel Budget 2 6 100 600 12345789 Hilton Hotel Budget

That's streamed with no carriage returns...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top