Lazy son-of-fifty-fathers that I am, rather than explain life, the Universe, and everything, I wrote a rather trivial sample report program, about which you may ask questions if anything is unclear:
foo35: proc options (main) reorder;
%dcl (true, false) char;
%dcl page_size fixed;
%true = '''1''B';
%false = '''0''B';
%page_size = 60;
dcl tulin file record input,
tulprint file record output
env (recsize(80) fb);
dcl 1 header_1,
2 * char (33) init ((33)' '),
2 * char (39)
init ('AkatsukamiSoft'),
2 * char (5) init ('Page'),
2 h1_page# pic 'zz9';
dcl 1 header_2,
2 * char (33) init ((33)' '),
2 * char (39)
init ('Sample Report'),
2 h2_run_date char (8);
dcl 1 header_3,
2 * char (7) init ('Title'),
2 * char (22) init ('Last Name'),
2 * char (51) init ('First Name');
dcl 1 header_4,
2 * char (7) init ('====='),
2 * char (22) init ((20)'='),
2 * char (51) init ((20)'=');
dcl 1 detail,
2 d1_title char (4),
2 * char (3) init (' '),
2 d1_last_name char (20),
2 * char (2) init (' '),
2 d1_first_name char (20),
2 * char (31) init ((31)' ');
dcl eof_tulin bit init (false),
inrec char (80),
workspace char (80) var,
page# fixed bin (15) init (1),
lineage fixed bin (15) init (99),
p fixed bin (31);
dcl (datetime, index, substr, trim) builtin;
on endfile (tulin) eof_tulin = true;
h2_run_date = datetime('DDMMYYYY');
read file (tulin) into (inrec);
do while (¬eof_tulin);
workspace = trim(inrec);
p = index(workspace,' ');
if (p=0) then do;
d1_title, d1_first_name = ' ';
d1_last_name = workspace || '!';
end;
else do;
d1_title = substr(workspace,1,p-1);
workspace = substr(workspace,p+1);
p = index(workspace,' ');
d1_first_name = substr(workspace,1,p-1);
d1_last_name = substr(workspace,p+1);
end;
if (lineage>page_size) then do;
h1_page# = page#;
page# += page#;
write file (tulprint) from (header_1);
write file (tulprint) from (header_2);
write file (tulprint) from (header_3);
write file (tulprint) from (header_4);
lineage = 1;
end;
write file (tulprint) from (detail);
lineage += 1;
read file (tulin) into (inrec);
end;
end foo35;
With the JCL:
//SHGBTEST JOB ,'This is a test',
// REGION=0K,MSGLEVEL=1,MSGCLASS=1,CLASS=9,SCHENV=JOB@ANY
//*MAIN FAILURE=RESTART,LINES=(999)
//STEPONLY EXEC PGM=POO35
//STEPLIB DD DSN=SHGB.WORK.LOAD,DISP=SHR
//SYSPRINT DD SYSOUT=*
//TULPRINT DD SYSOUT=*
//TULIN DD *
Akatsukami-sama
Sr. Alison Olivera
Dr. Enrico Sorichetti
Mr. Billy Boyo
Ms. Alissa Margulies
it produces the report:
AkatsukamiSoft Page 1
Sample Report 05042012
Title Last Name First Name
===== ==================== ====================
Akatsukami-sama!
Sr. Olivera Alison
Dr. Sorichetti Enrico
Mr. Boyo Billy
Ms. Margulies Alissa
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day