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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Acceptance to Printout. 2

Status
Not open for further replies.

scurf

Programmer
Feb 5, 2002
19
GB
Good evening chaps and chapesses,

I need to code a program that will read a file from disk called "SALES-FILE.DAT" , the data is already in ascending order of TYPE-CODE and pre-validated and will eventually be sent to the printer.. I am having my usual problem of drawing a structure chart, I have this so far.

______________ SALES PROGRAM_________________
| | |
INITIAL UPDATE PROCESS CLOSE
____PROCESS______ UNTIL END OF FILE FILES
| | |
OPEN READ PRINT
SALES SALES HEADINGS

1) Should my update process be on a separate chart?

The main process required is to Read the field TYPE-CODE of the incoming DATA which is either a "1" or a "2", I need to code a control break when the TYPE-CODE changes from 1 to 2,.
If 1 is read then the field UNIT-PRICE (pic 9(3)v1) needs to be multiplied by the field WEIGHT, When 2 is read then the field UNIT-PRICE needs to be multiplied by the field QUANTITY.

This is only a small part of the program requirement, any help on the structure chart would be great, I am sure that I can code most of the other requirements of the program, but any help would be greatly appreciated.

Cheers all

GAZ

 
Sorry, I have posted this twice by accident...
 
MAINLINE
INITIAL HOUSEKEEPING
READ AND PROCESS UNTIL END OF FILE
CLOSING HOUSEKEEPING

INITIAL HOUSEKEEPING
OPEN FILES
SET UP REPORT HEADERS

READ AND PROCESS
READ FILE
NOT AT END
IF TYPE 1
PROCESS TYPE 1 RECORD
ELSE
PROCESS TYPE 2 RECORD
END-IF
END-READ

ETC....

You DO NOT NEED an initial READ, put it in the PROCESS routine.

Stephen J Spiro
 
Hi GAZ,

Don't let Stephen brow beat you.:) An initial read will make your control break processing SIMPLER. It's one of those "Holy War" subjects.

You can go back to the COBOL General Discussions page and click the FAQ tab. The "How to code control breaks?" FAQ discusses control break processing. It may be helpful.

HTH, Jack.
 
Jack, I'm baffled. :) How does coding an initial read make it simpler?

Stephen J Spiro
 
Hi Stephen,

How would you code a 3-4 level cntl brk report? You show me yours, I'll show you mine. :)

Regards, Jack.
 
Ok, Jack.
Produce a report of
Orders by products for each customer within each store.

Input file is already sequenced.

Working storage has preformatted headers and footers, which need data (Store, customer, and product) at the appropriate level (originally initialized to spaces or somesuch). This example ignores page breaks, which we would probably both handle much the same way. In fact, everything is omitted here except the logic to do the break processing. In the real world, I do not use AT END... NOT AT END... I use FILE STATUS, which enables me to do error handling.

Code:
0000-MAINLINE.
    ---
    PERFORM 1000-READ-AND-RPOCESS 
        UNTIL END-OF-FILE.
    ----

1000-READ-AND-RPOCESS.
    READ INPUT FILE
        AT END
             PERFORM 4100-PRODUCT-FOOTER
             PERFORM 3100-CUSTOMER-FOOTER
             PERFORM 2100-STORE FOOTER
        NOT AT END
             PERFORM 1100-PROCESS.

1100-PROCESS.
    IF (INPUT STORE IS NOT EQUAL TO HEADER-STORE)
        PERFORM 2000-STORE BREAK
    ELSE
        IF (INPUT-CUST IS NOT EQUAL TO HEADER-CUST)
             PERFORM 3000-CUSTOMER-BREAK
         ELSE
             IF (INPUT-PROD IS NOT EQUAL TO HEADER-PROD)
                 PERFORM 4000-PRODUCT BREAK
             END-IF
         END-IF
    END-IF
    PROCESS 5000-TRANSACTION-LINE.

2000-STORE BREAK.
    IF WS-STORE IS NOT EQUAL TO SPACES
        PERFORM 4100-PRODUCT-FOOTER
        PERFORM 3100-CUSTOMER-FOOTER
        PERFORM 2100-STORE-FOOTER.
    PERFORM 2200-STORE-HEADER.
    PERFORM 3200-CUSTOMER-HEADER.
    PERFORM 4200-PRODUCT-HEADER.

2200-STORE-HEADER.
    ---
    MOVE INPUT-STORE TO HEADER-STORE.
    ---

3000-CUSTOMER-BREAK.
    PERFORM 4100-PRODUCT-FOOTER.
    PERFORM 3100-CUSTOMER-FOOTER.
    PERFORM 3200-CUSTOMER-HEADER.
    PERFORM 4200-PRODUCT-HEADER.

3200-CUSTOMER-HEADER.
    ---
    MOVE INPUT-CUSTOMER TO HEADER-CUSTOMER.
    ---


4000-PRODUCT BREAK.
    PERFORM 4100-PRODUCT-FOOTER.
    PERFORM 4200-PRODUCT-HEADER.

4200-PRODUCT-HEADER.
    ---
    MOVE INPUT-PRODUCT TO HEADER-PRODUCT.
    ---

Note that 1100-PROCESS could also be coded this way:
Code:
    EVALUATE FALSE
        WHEN INPUT STORE IS EQUAL TO HEADER-STORE
          PERFORM 2000-STORE BREAK
        WHEN INPUT-CUST IS EQUAL TO HEADER-CUST
            PERFORM 3000-CUSTOMER-BREAK
        WHEN INPUT-PROD IS EQUAL TO HEAD-PROD
            PERFORM 4000-PRODUCT BREAK
    END-EVALUATE
    PROCESS 5000-TRANSACTION-LINE.
But that does not read as good English! Go with EVALUATE TRUE, and leave the NOT in each comparison!

This approach has only one READ, and the READ comes before the processing, instead of after the processing of the previous record. This seems clearer to me. I use the buffer, not WORKING-STORAGE, because there is a LOT of overhead in moving all the records in a file into WORKING-STORAGE. No flags are set. If there is no "natural" place for comparisons (such as in the report header), a WORKING-STORAGE field is easy enough to set up (rather than the whole record). It can be initialized to spaces or any value which the programmer knows can never be in the real data.

Since there is always a "store break" on the first read, 2000-STORE BREAK is the only place where you have to test for "first record". Obviously, footers are not produced on the first read.


It looks easier (less complicated) than what you have in the FAQ, Jack.

This is Structured, Modular programming.
 
Ok Stephen,

The logic is this:

To process the file process all the stores in it.
To process a store process all the customers in it.
To process a customer process all the products in it.
To process a product process all the detail recs in it.

And remember, boys and girls, that when you enter pgraph 1000-... the record has already been read. Stephen, you seem to find this confusing, yet you have no problem with processing footers before headers. Go figure. You'll notice also that the init read facilitates handling the empty input file situation, which you don't address in your code.

You say correctly that "read into" adds overhead to the task. I say it's acceptable if it simplifies the code and reduces the chance of an abend or two.

To paraphrase another sage:

"It looks easier (less complicated) than what you beleive, Steve. :)

P.S. Some of the pnames may be too long; they were used to illustrate the logic.
Code:
**************
0000-MAINLINE.
**************
    PERFORM 7000-READ-INPUT-REC
    IF INPUT-EOF
       MOVE 'NO ACTIVITY FOR THIS PERIOD'
       PERFORM 8000-NO-ACTIVITY-RPT
       STOP RUN
    END-IF  
    PERFORM 1000-PROCESS-STORES-IN-FILE
      UNTIL END-OF-FILE 
     .
****************************
1000-PROCESS-STORES-IN-FILE.
****************************
    PERFORM 2000-STORE-HEADER
    SET RESET-STORE-SW TO TRUE
    PERFORM 1100-PROCESS-ALL-CUSTS-IN-STORE 
      UNTIL STORE-IS-FINISHED
    PERFORM 2100-STORE-FOOTER 
    .
********************************
1100-PROCESS-ALL-CUSTS-IN-STORE.
********************************
    PERFORM 3000-CUSTOMER-HEADER
    SET RESET-CUST-SW TO TRUE
    PERFORM 1200-PROCESS-ALL-PRODUCTS-FOR-CUST 
      UNTIL CUST-IS-FINISHED
    PERFORM 3100-CUSTOMER-FOOTER 
    .
***********************************
1200-PROCESS-ALL-PRODUCTS-FOR-CUST.
***********************************
    PERFORM 4000-PRODUCT-HEADER
    SET RESET-PROD-SW TO TRUE
    PERFORM 1300-PROCESS-ALL-DETAIL-FOR-PRODUCT 
      UNTIL PROD-IS-FINISHED
    PERFORM 4100-PRODUCT-FOOTER
    . 
************************************
1300-PROCESS-ALL-DETAIL-FOR-PRODUCT.
************************************
    Move/total data, etc.    		
    PERFORM 7000-READ-INPUT-REC
    .
2000-STORE-HEADER.
    ---
    MOVE INPUT-STORE TO HEADER-STORE.
    ---
2100-STORE-FOOTER.
    . 
3000-CUSTOMER-HEADER.
    ---
    MOVE INPUT-CUSTOMER TO HEADER-CUSTOMER.
    ---
3100-CUSTOMER-FOOTER.
    . 
4000-PRODUCT-HEADER.
    ---
    MOVE INPUT-PRODUCT TO HEADER-PRODUCT.
    ---
4100-PRODUCT-FOOTER.
    . 
********************
7000-READ-INPUT-REC.
********************
    MOVE CURR-KEY TO PREV-KEY
    READ INPUT-FILE INTO CURR-INPUT-REC
      AT END
         MOVE ALL X'FF' TO CURR-INPUT-REC
         SET INPUT-EOF  TO TRUE
    END-READ
    PERFORM 8010-SET-BREAK-SWITCHES
    .
************************
7010-SET-BREAK-SWITCHES.
************************
    IF CURR-STORE-ID NOT      = PREV-STORE-ID
       SET STORE-IS-FINISHED TO TRUE
    END-IF
    IF CURR-CUST-ID NOT       = PREV-CUST-ID
       SET CUST-IS-FINISHED  TO TRUE
    END-IF
    IF CURR-PROD-ID NOT       = PREV-PROD-ID
       SET PROD-IS-FINISHED  TO TRUE
    END-IF
    .
 
This is much better than what you had in the FAQ. I think you could probably find a way to eliminate the reset switches, which would make it even cleaner.
In the next COBOL Standard, this will be easier. There will be a way to use condition-names for editing: e,g,
Code:
88  CUST-IS-FINISHED  
        VALID WHEN CUST-ID NOT = PREV-CUST-ID.
You do it in the data division, rather than doing a test and setting it in the procedure division. MicroFocus COBOL already implements this, and maybe some others.

"And remember, boys and girls, that when you enter pgraph 1000-... the record has already been read. Stephen, you seem to find this confusing,"
Not confusing, just unnecessary.

"You'll notice also that the init read facilitates handling the empty input file situation, which you don't address in your code. "
I said "In the real world, I do not use AT END... NOT AT END... I use FILE STATUS, which enables me to do error handling. " I only did the break logic in my example.

"you have no problem with processing footers before headers"
On a break, that's exactly what you do. Only on the first record do you not process the footers first (and I put in logic for that.)

I like the way you include the processing for each level inside the next higher level. But I still don't like the two READs.

You ought to look into getting onto the Standards Committee.

Stephen J Spiro









 

"You ought to look into getting onto the Standards Committee."

... so he'll be scarred for life?? X-)

Been there, done that. No T-Shirt, but I do have a copy of the 1985 Standard autographed by Peggy Beard!

B-)


Tom Morrison
 

Hi Stephen,

Whew,you’re a tough sell. The initial read and, by inference, the trailing read in the loop, makes the Cascading Performs (no, not the Flying Wallendas) construct work.

JS wrote:
“you have no problem with processing footers before headers"
SS wrote:
“On a break, that's exactly what you do.”

It only appears that way, Stephen, else the report page would show:
Footings Body Headings
But then maybe I’m picking at as small a nit as you are with my initial read.

With the approach I use, the flow is “Headings Body Footings“, a more natural way of viewing the process. The only fly in the ointment is the trailing read and that can be finessed with a simple comment at the head of the process loop.

What I like about the concept is that it takes the break “logic” out of the flow and presents the processing levels as blocks of code. If the maintainer has a problem with a specific level or needs to change it,
(s)he can go directly to that level without wading thru the break logic.

Secondly, it codifies the control break process so that the wheel doesn’t have to be reinvented with each new program. Perhaps an overstatement, but you get the idea.

I guess we’ll just have to agree to disagree on this one, Stephen.

Regards, Jack.
 
I am sorry, has my thread caused a bit of internal wrangling, I will try to pick a bit from each of you and build some coding that hopefully makes some sense, is it ok to post it here when I am finished and maybe you can pull it apart and assist me, I am only a baby at this game....
Unfortunately I dont work in an area where I am required to design and create programs from spec, I am trying a self-teach method in order to make my way into the business....
 
Scurf, Scurf, the name sounds familiar, oh, now I remember. Weren't you... Sorry about that Scurf, every so often we go off on a tangent, sometimes also a secant or two.

To answer your ques, sure, I for one, would like to see what you come up with. If we behave ourselves we may even be able to help. It can get lonely doing it the way you are, so don't hesitate.

Good luck, Jack.
 
You don't have to apologize that your "thread caused a bit of internal wrangling", scurf. This is a religious matter, and very friendly. Did you see, I even invited the heretic to join the standards committee?

Stephen J Spiro
Member, ANSI COBOL Standards Committee

 
Friendly?!!! That just shows how nasty, low-down these things can get. :)

Jack
 
Wow! I don't think I've been away that long; but things sure have become exciting around here... Are we fighting the crusades all over again?

Don't let these sidebars scare you, Scurf... these are a very helpful and knowledgeable bunch.
 
With all the work we did, Jack, I wondered when we were going to get our stars for "helpful posts"! *LOL*

Stephen
 
I expected gold stars with oak leaf clusters, but what the hey. B-(

Jack
 
I am back again, with my example coding, feel free to rip it to pieces, remeber I am just a baby at the game...
I am sorry it is quite long.........

I will first of all try to explain the program specification.

A wholesaler deals with different types of vegetables.

All sales are recorded on handwritten slips and later transferred to disk. Each computerised sales record is terminated with a newline char and contains the following
Reference number 6 Alphanumeric
Type Code 1 numeric (valus 1 to 6)
Weight 4 numeric
Quantity 4 numeric
Calculation Method 1 numeric (either 1 or 2)
Unit Buying Price 4 numeric(pence- 1 decimal point)
Unit Sale Price 4 numeric (pence - 1 decimal point)

The above is already validated and sorted into ascending type code sequence and saved to disk, The program must produce a sales analysis report for the days transactions.

The report is to print the details of each record and must include the result of both the calculated buying value and sale value. The Unit Buying Price field and the Unit Sale Price field are to be used in calculating these values.
The calculation method field determines how these values will be calculated. ie The Unit price is multiplied by the weight for calc method 1 and is multiplied by the weight for calc method 2, Values are rounded up to the nearest penny.

When a change in the Type Code is detected a control break is generated which results in the printing of the total buying and sales value for that vegetable type. The gross profit is also printed and is calculated by subtracting the buying total from the sale total. These totals are printed in pounds and pence.

Grand totals are required at the end showing the Total Buying Value and Total Sle value for all the records processed. A Grand Total profit is also printed.....

ANYWAY, HERE IS MY CODING SO FAR................
SORRY IF SOME OF THE ALIGNMENT HAS GONE, I AM SURE IT IS STILL READABLE..

IDENTIFICATION DIVISION.
PROGRAM I-D. SALES.

*THIS PROGRAM WILL ACCEPT DATA FROM THE DISK FILE “SALESFILE.DAT” AND READ IT INTO THE *SALES-FILE. THE PROGRAM WILL CARRY OUT CALCULATIONS ON CERTAIN ELEMENTS OF DATA *AND PERFORM CONTROL BREAKS, THE OUTPUT IS A PRINTED REPORT.

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT SALES-FILE ASSIGN TO “SALESFILE.DAT”
ORGANIZATION SEQUENTIAL.
SELECT PRINT-FILE
ASSIGN TO PRINTER.

DATA DIVISION.
FILE SECTION.
FD SALES-FILE.
01 SALES-RECORDS.
03 REF-NUMBER PIC X(6).
03 TYPE-CODE PIC 9.
03 WEIGHT PIC 9(4).
03 QUANTITY PIC 9(4).
03 CALC-METHOD PIC 9.
03 UNIT-BUY-PRICE PIC 9(3)V9.
03 UNIT-SALE-PRICE PIC 9(3)V9.

FD PRINT-FILE.
01 PRINT-REC PIC X(140).

WORKING-STORAGE SECTION.

01 END-FILE-FLAG PIC X VALUE “N”.
88 SALES-EOF VALUE “Y”.
01 W-TYPE-CODE PIC 9.
01 W-BUY-VALUE PIC 9(4)V99.
01 W-SALE-VALUE PIC 9(4)V99.
01 W-TOTAL-BUY-VALUE PIC 9(5)V99.
01 W-TOTAL-SALE-VALUE PIC 9(5)V99.
01 W-PROFIT PIC S9(5)V99.
01 W-GRAND-BUY-VALUE PIC 9(6)V99.
01 W-GRAND-SALE-VALUE PIC 9(6)V99.
01 W-GRAND-PROFIT PIC S9(6)V99.
01 W-BUY-CUMILATIVE-TOTAL PIC 9(4)V99 VALUE 0.
01 W-SALE-CUMILATIVE-TOTAL PIC 9(4)V99 VALUE 0.
01 W-CUMILATIVE-PROFIT PIC S9(6)V99 VALUE 0.
01 W-SALES-VALUE-FOR-ALL-SALES PIC 9(4)V99 VALUE 0.
01 W-BUY-VALUE-FOR-ALL-BUY PIC 9(4)V99 VALUE 0.


01 W-PRINT-HEADING.
03 PIC X(15) VALUE SPACES.
03 PIC X(49) VALUE “MR GREENS (WHOLESALER) – DAILY SALES REPORT”.
03 PIC X(5) VALUE SPACES.

01 W-DATE
03 W-DATE-DAY PIC 99.
03 PIC X VALUE “/”.
03 W-DATE-MONTH PIC 99.
03 PIC X VALUE “/”.
03 W-DATE-YEAR PIC 99.
03 PIC X(18) VALUE SPACES.

03 PIC X(4) VALUE “PAGE”.
03 PIC X VALUE SPACES.
03 W-PAGE-NUMBER PIC ZZ9 VALUE 1.

01 W-PRINT-SUBHEADING.
03 PIC X(54) VALUE SPACES.
03 PIC X(22) VALUE “BUYING”.
03 PIC X(18) VALUE “SALE”.
03 PIC X(13) VALUE “PROFIT”.

01 W-PRINT-SUBHEADING1.
03 PIC X(10) VALUE SPACES.
03 PIC X(11) VALUE “REFERENCE”.
03 PIC X(2) VALUE “TYPE”.
03 PIC X(3) VALUE “WEIGHT”.
03 PIC X(3) VALUE “QTY”.
03 PIC X(2) VALUE “CALC”.
03 PIC X(4) VALUE “PRICE”.
03 PIC X(4) VALUE “VALUE”.
03 PIC X(7) VALUE “PRICE”.
03 PIC X(5) VALUE “VALUE”.

01 W-PRINT-SUBHEADINGS2.
03 PIC X(15) VALUE SPACES.
03 PIC X(14) VALUE “NO”.
03 PIC X(11) VALUE “KILOS”.
03 PIC X(9) VALUE “METH”.
03 PIC X(7) VALUE “P”.
03 PIC X(8) VALUE “£”.
03 PIC X(12) VALUE “P”.
03 PIC X(8) VALUE “£”.

01 W-DETAIL-LINE.
03 PIC X(12) VALUE SPACES.
03 W-OUT-REF-NO PIC X.
03 PIC X(4) VALUE SPACES.
03 W-OUT-TYPE PIC X.
03 PIC X(6) VALUE SPACES.
03 W-OUT-WEIGHT PIC 9(4).
03 PIC X(3) VALUE SPACES.
03 W-OUT-QUANTITY PIC 9(4).
03 PIC X(4) VALUE SPACES.
03 W-OUT-CALC-METHOD PIC 9.
03 PIC X(4) VALUE SPACES.
03 W-OUT-BUY-PRICE PIC 9(3)V9.
03 PIC X(5) VALUE SPACES.
03 W-OUT-BUY-VALUE PIC 9(4)V99.
03 PIC X(7) VALUE SPACES.
03 W-OUT-SALE-PRICE PIC 9(4)V99.
03 PIC X(5) VALUE SPACES.
03 W-OUT-SALE-VALUE PIC 9(4)V99.

*THE NEXT PARAGRAPH WILL DEFINE THE SUB-TOTALS WHEN A CONTROL BREAK IS REACHED, IE. *WHEN THE TYPE-CODE CHANGES.

01 W-DETAIL-LINE-SUB-TOTALS.
03 PIC X(22) VALUE SPACES.
03 W-OUT-TYPE PIC X.
03 PIC X(2) VALUE “TOTALS”.

03 W-VEG-TYPE PIC X(10).
03 PIC X(57) VALUE SPACES.
03 W-OUT-TOTAL-BUY PIC 9(5)V99.
03 PIC X(14) VALUE SPACES.
03 W-OUT-TOTAL-SALE PIC 9(5)V99.
03 PIC X(6) VALUE SPACES.
03 W-OUT-PROFIT PIC S9(5)V99.

01 W-GRAND-TOTALS.
03 PIC X(25) VALUE SPACES.
03 PIC X(31) VALUE “GRAND TOTALS”.
03 PIC X(18) VALUE SPACES.
03 W-GRAND-BUY-VALUE PIC 9(6)V99.
03 PIC X(13) VALUE SPACES.
03 W-GRAND-SALE-VALUE PIC 9(6)V99.
03 PIC X(8) VALUE SPACES.
03 W-GRAND-TOTAL-PROFIT PIC S9(6)V99.

PROCEDURE DIVISION.

OPEN INPUT SALES-FILE
OUTPUT PRINT-FILE
PERFORM NEW-HEADINGS-1
PERFORM INITIAL-PROCESS
PERFORM RESET-CUMILATIVE-TOTALS
PERFORM GRAND-TOTALS
PERFORM CLOSE-FILES
STOP RUN.

* MORE PROCESSES

NEW-HEADINGS-1.
WRITE PRINT-REC FROM W-PRINT-HEADING AFTER PAGE
MOVE DATE TO W-DATE
WRITE PRINT-REC FROM W-PRINT-SUBHEADING
WRITE PRINT-REC FROM W-PRINT-SUBHEADING1
WRITE PRINT-REC FROM W-PRINT-SUBHEADING2

INITIAL-PROCESS.

READ SALES-FILE
AT END MOVE “Y” TO END-FILE-FLAG
END-READ
MOVE TYPE-CODE TO W-TYPE-CODE
PERFORM UNTIL SALES-EOF
MOVE REF-NUMBER TO W-OUT-REF-NO
MOVE TYPE-CODE TO W-OUT-TYPE
MOVE WEIGHT TO W-OUT-WEIGHT
MOVE QUANTITY TO W-OUT-QUANTITY
MOVE CALC-METHOD TO W-OUT-CALC-METHOD
MOVE UNIT-BUY-PRICE TO W-OUT-BUY-PRICE

*USE TYPE-CODE AS THE CONTROL BREAK, TYPE-ODE CORRESPONDS TO THE VEGETABLES SOLD, *WHEN THE TYPE CODE CHANGES THIS INDICATED THE CHANGE IN THE VEGETABLE TYP SOLD.

PERFORM CALCULATION UNTIL TYPE-CODE NOT = W-TYPE-CODE
PERFORM CONTROL-BREAK.

****CALCULATE THE TOTALS IN THE DETAIL LINE, IF THE CALCULATION METHOD IS “1” THEN THE BUY *VALUE AND SALE VALUE ARE CALCULATED BY MULTIPLYING BY THE WEIGHT BY THE UNIT BUY *PRICE AND UNIT SALE PRICE..IF THE METHOD IS “2” THEN THEY ARE MULTIPLIED BY THE QUANTITY.
*A CUMILATIVE FIELD IS ALSO KEPT IN WORKING STORAGE TO KEEP A CUMILATIVE VALUE OF THE *BUY VALUES AND SALE VALUES WHICH NEED TO BE USED TO DISPLAY THE TOTALS WHEN THE *CONTROL BREAK IS REACHED.*****


CALCULATION.
IF CALC-METH = 1 THEN
COMPUTE W-OUT-BUY-VALUE = UNIT-BUY-PRICE * WEIGHT AND
COMPUTE W-OUT-SALE-VALUE = UNIT-SALE-PRICE * WEIGHT
ELSE
COMPUTE W-OUT-BUY-PRICE = UNIT-BUY-PRICE * QUANTITY AND
COMPUTE W-OUT-SALE-PRICE = UNIT-SALE-PRICE * QUANTITY

COMPUTE W-BUY-CUMILATIVE-TOTAL = W-BUY-CUMILATIVE-TOTAL + W-OUT-BUY-PRICE
COMPUTE W-SALE-CUMILATIVE-TOTAL = W-SALE-CUMILATIVE-TOTAL + W-OUT-SALE-PRICE.
COMPUTE W-OUT-PROFIT = W-SALE-CUMILATIVE-TOTAL – W-BUY-CUMILATIVE-TOTAL

COMPUTE W-SALES-VALUE-FOR-ALL-SALES = W-SALES-VALUE-FOR-ALL-SALES + W-SALE-CUMILATIVE-TOTAL
COMPUTE W-BUY-VALUE-FOR-ALL-BUY = W-BUY-VALUE-FOR-ALL-BUY + W-BUY-CUMILATIVE-TOTAL
COMPUTE W-GRAND-VALUE-PROFIT = W-GRAND-VALUE-PROFIT + W-CUMILATIVE-PROFIT

END-IF
CONTROL-BREAK.
MOVE W-TYPE-CODE TO W-OUT-TYPE
IF W-TYPE-CODE = 1 THEN
MOVE “POTATOES” TO W-VEG-TYPE ELSE
IF W-TYPE-CODE = 2 THEN
MOVE “TURNIPS” TO W-VEG-TYPE ELSE
IF W-TYPE-CODE = 3 THEN
MOVE “PEAS” TO W-VEG-TYPE ELSE
IF W-TYPE-CODE = 4 THEN
MOVE “CARROTS” TO W-VEG-TYPE ELSE
IF W-TYPE-CODE = 5 THEN
MOVE “SPROUTS” TO W-VEG-TYPE ELSE
MOVE “ TINNED VEG” TO W-VEG-TYPE
END-IF
END-IF
END-IF
END-IF
END-IF
MOVE W-BUY-CUMILATIVE-TOTAL TO W-OUT-TOTAL-BUY
MOVE W-SALE-CUMILATIVE-TOTAL TO W-OUT-TOTAL-SALE
COMPUTE W-OUT-PROFIT = W-OUT-TOTAL-SALE – W-OUT-TOTAL-BUY

*RESET THE SUB TOTAL VALUES FOR THE NEXT CONTROL BREAK

RESET-CUMILATIVE-TOTALS.

MOVE 0 TO W-BUY-CUMILATIVE-TOTAL
MOVE 0 TO W-SALE-CUMILATIVE-TOTAL
MOVE 0 TO W-CUMILATIVE PROFIT

*MOVE FIGURES TO THE GRAND VALUE ONCE THE FILE REACHES THE END.
GRAND-TOTALS.

AT SALES-EOF
MOVE W-SALES-VALUE-FOR-ALL-SALES TO W-GRAND-SALE-VALUE
MOVE W-BUY-VALUE-FOR-ALL-BUY TO W-GRAND-BUY-VALUE
MOVE W-GRAND-VALUE-PROFIT TO W-GRAND-TOTAL-PROFIT

CLOSE-FILES.

CLOSE SALES-FILE
CLOSE PRINT-FILE


THATS ALL FOLKS
CHEERS GARRY
SAUSAGES@SCURFIELD.FSNET.CO.UK

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top