Link to home
Start Free TrialLog in
Avatar of qsysopr
qsysopr

asked on

cobol control-break question

I have a text file with6 fields
region            pic x 3
section           pic x 3
proj #            pic x 5
type               pic x 15
budget amt    pic 9(9)
actual amt      pic 9(9)

I have to create a report showing the following fields with thier proper
headings.  also I must show a variance (+, -) showing the difference
between budget and actual amts.     I am able to do this,  but at the bottom of the report I must show totals for sections, and totals for regions.
  When I attempt to do this I loose my calculated variance field.  I know
I am doing this program incorrectly and am going nowhere.  if it will
help I can e-mail my .txt file and my code.

thank you.
Avatar of arch_great
arch_great

Keep 2 variables for Regiontot and Section tot (which will become 0 ,when the region changes.... )

Pseudo code (not in COBOL)

mregtot = 0
msectot = 0

AS long as !eof()
    mregion = region
    msection = section
   

    if section changes
        do control break (where U will print that section's total...
    endif    

    if region changes
            do control break (where U will print that region's total...
    endif

     Calculate variance for each detail....

-----------

In Control break  of section and region , reinitialise the respective totals to zero...
 
ASKER CERTIFIED SOLUTION
Avatar of nico5038
nico5038
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I swear I won't cobol, but I am also sure that if I did and init routine I would also run a cleanup routine at the end.

More than likely I would use Eof to process some totalling code, then leaf out to cleanup of files and such.

>       PERFORM PRINT-DETAIL
>       PERFORM READ-NEXT

yah, very nice and crisply done
Sunbow,

Using a 'switch-value' for EOF in a "sortwork-key" offers the advantage that even multiple files can be "levelled" automatically and that those files having EOF are automatically skipped for pocessing by the value of this EOF field!
How is the progress on the report ?
did it work?