write an output (header, corp and footer)



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

write an output (header, corp and footer)

Postby joan_19 » Fri Dec 28, 2018 10:31 pm

hello!
i recently began learning cobol, and the learning material i received isn't clear on how i should write the header, corp and footer of an output print file. can someone help me, please? thank you.
joan_19
 
Posts: 1
Joined: Fri Dec 28, 2018 10:18 pm
Has thanked: 2 times
Been thanked: 0 time

Re: write an output (header, corp and footer)

Postby NicC » Sat Dec 29, 2018 5:00 pm

By 'corp' do you mean 'body'? Let us assume that you do. Let us also assume that you want the footer only at the end of the report not each page.
You want to produce a report in the following format
header line
body line
body line
:
body line
header line
body line
body line
:
body line
footer


Code a variable to hold your header. If you have to have such things as run date and page number then make that variable a structure.
Code a variable for your body line - this is most likely a structure
Code a variable for your footer. Again make it a structure if it is to hold variable data e.g. number of body lines written
Declare a variable to hold the number of lines to be printed per page
Declare a variable to hold a count of lines written so far - initialise it to a value greater than the number of lines per page

Your process is:
at startup:
fill in header details
write header
set lines printed to 1 (or however heading lines there are)

When printing a record:
print the record
increment the lines printed count
if greater than lines allowed per page
write header
set line count back to 1
at end of input update counts in footer and write the footer variable.

That is a simple process suitable for beginners. Later you will coe across more cmplex header, body lines and end of report lines.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic

These users thanked the author NicC for the post:
joan_19 (Sat Dec 29, 2018 6:23 pm)
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

Re: write an output (header, corp and footer)

Postby NicC » Sat Dec 29, 2018 5:25 pm

Also:
Do not post the same query on multiple forums. It is bad manners and you coud be wasting people's time.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic

These users thanked the author NicC for the post:
joan_19 (Sat Dec 29, 2018 6:23 pm)
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