Page 1 of 1

write an output (header, corp and footer)

PostPosted: Fri Dec 28, 2018 10:31 pm
by joan_19
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.

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

PostPosted: Sat Dec 29, 2018 5:00 pm
by NicC
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.

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

PostPosted: Sat Dec 29, 2018 5:25 pm
by NicC
Also:
Do not post the same query on multiple forums. It is bad manners and you coud be wasting people's time.