This is the RPG-ILE program for writing a Print Report using O Specs. At the bottom, you will see a sample of the report layout in the spool file.
Columns . . . : 6 76 Edit USER000/QRPGLESRC SEU==> TUTR006 FMT FX FFilename++IPEASF.....L.....A.Device+.Keywords+++++++++++++++++++++++++ *************** Beginning of data ************************************* 0001.00 FCUST IF E DISK 0002.00 * The AS/400 includes a pre-defined printer file named QPRINT 0003.00 * Here, I use indicator 10 as the overflow indicator 0004.00 * That means that *IN10 will be *ON when the printed page 0005.00 * is full. 0006.00 FQPRINT O F 132 PRINTER OFLIND(*In10) 0007.00 *---------------------------------------------------------------- 0008.00 C* Print the heading 0009.00 C Except Headings 0010.00 C* Read the first record 0011.00 C Read CSREC 90 0012.00 C* 0013.00 C DoW *In90 = *Off 0014.00 C* See if the page is full. If so, print the heading. 0015.00 C If *In10 = *On 0016.00 C Except Headings 0017.00 C Eval *In10 = *Off 0018.00 C EndIf 0019.00 C Except Detail 0020.00 C Read CSREC 90 0021.00 C EndDo 0022.00 C* 0023.00 C Eval *InLR = *On 0024.00 C Return 0025.00 *---------------------------------------------------------------- 0026.00 OQPRINT E Headings 2 2 0027.00 O 6 'PAGE' 0028.00 C* PAGE is a system value that will keep track of the page# 0029.00 O Page 10 0030.00 O 47 'CUSTOMER ORDER REPORT' 0031.00 O 65 'DATE' 0032.00 C* UDATE is a system value that is today's date 0033.00 C* The edit code Y will edit the date like xx/xx/xx 0034.00 O Udate Y 75 0035.00 O* 0036.00 O E Headings 1 0037.00 O 61 '# OPEN' 0038.00 O 71 'AMT OPEN' 0039.00 O* 0040.00 O E Headings 1 0041.00 O 17 'CUST #' 0042.00 O 23 'NAME' 0043.00 O 61 'ORDERS' 0044.00 O 70 'ORDERS' 0045.00 O* 0046.00 O E Detail 1 0047.00 O CSNBR 17 0048.00 O CSNAME 49 0049.00 C* The edit code 1 will edit the amount like 1,234.50 0050.00 O CS#OPN 1 60 0051.00 O CS$OPN 1 70 ****************** End of data **************************************** Once you have written the program, compile it using option 14. After you have compiled the program, you want to call it and see what the report looks like. To call the program, simply type on the command line: CALL PGM(USER000/TUTROO5) Next, go to the Work Spool File (WRKSPLF), find the program, and key in a 5 to view the report. This is what the report will look like: PAGE 1 CUSTOMER ORDER REPORT DATE 11/14/02 # OPEN AMT OPEN CUST # NAME ORDERS ORDERS 001002 E LUMPKIN 0 .00 001084 CHISOLM 0 .00 001105 HAGGINS 0 .00 001109 BYRD 0 .00 001168 ROMERO 0 .00 001177 POUNDS 0 .00 001183 HINTON 0 .00 001184 YANCEY 0 .00 001186 MCDOUGLE 0 .00 001202 DAVIS 0 .00 001208 TARVIN 0 .00 001214 GOOSEBERRY 0 .00 001234 REID 0 .00 001239 COLBERT 0 .00 001259 BLACKMON 0 .00 001264 CRANFORD 0 .00 001266 DODSON 0 .00 001269 LENSON 0 .00 001274 JACKSON 0 .00 001284 TAPER 0 .00 001287 WILLIAMS 0 .00 001293 FEAZELL 0 .00 001294 MC CULLUM 0 .00 001301 SMITH 0 .00 001303 MCGHEE 0 .00 001308 WALLACE 0 .00 001318 ROBINSON 0 .00 001321 SPIVEY 0 .00 001322 HILLARD 0 .00 PAGE 2 CUSTOMER ORDER REPORT DATE 11/14/02 # OPEN AMT OPEN CUST # NAME ORDERS ORDERS 001480 BAILEY 0 .00 001485 POLLARD 0 .00 001492 JORDAN 0 .00 001502 EVERETT 0 .00 001504 HIGGINS 0 .00 001509 JONES 0 .00 001523 BENDER 0 .00 001539 BUDD 0 .00 001557 KINSEY 0 .00 001561 PILKINGTON 0 .00 001579 HAWKINS 0 .00 001583 MOBBS 0 .00 001584 SELLERS 0 .00 001587 WALKER 0 .00 001591 SLACK 0 .00 001604 HINKLE 0 .00 001606 ALLEN 0 .00