This is the RPG 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 . . . : 1 71 Edit USER000/QRPGSRC SEU==> TUTR005 FMT FX .....FFilenameIPEAF........L..I........Device+......KExit++Entry+A....U *************** 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 10 PRINTER 0007.00 *---------------------------------------------------------------- 0008.00 C* Print the heading 0009.00 C EXCPTHEADS 0010.00 C* Read the first record 0011.00 C READ CUST 90 0012.00 C* 0013.00 C *IN90 DOWEQ*OFF 0014.00 C* See if the page is full. If so, print the heading. 0015.00 C *IN10 IFEQ *ON 0016.00 C EXCPTHEADS 0017.00 C MOVE *OFF *IN10 0018.00 C ENDIF 0019.00 C* Print the detail 0020.00 C EXCPTDETAIL 0021.00 C READ CUST 90 0022.00 C ENDDO 0023.00 C* 0024.00 C MOVE *ON *INLR 0025.00 C RETRN 0026.00 *---------------------------------------------------------------- 0027.00 OQPRINT E 202 HEADS 0028.00 O 6 'PAGE' 0029.00 C* PAGE is a system value that will keep track of the page# 0030.00 O PAGE 10 0031.00 O 47 'CUSTOMER ORDER REPORT' 0032.00 O 65 'DATE' 0033.00 C* UDATE is a system value that is today's date 0034.00 C* The edit code Y will edit the date like xx/xx/xx 0035.00 O UDATE Y 75 0036.00 O* 0037.00 O E 1 HEADS 0038.00 O 61 '# OPEN' 0039.00 O 71 'AMT OPEN' 0040.00 O* 0041.00 O E 1 HEADS 0042.00 O 17 'CUST #' 0043.00 O 23 'NAME' 0044.00 O 61 'ORDERS' 0045.00 O 70 'ORDERS' 0046.00 O* 0047.00 O E 1 DETAIL 0048.00 O CSNBR 17 0049.00 O CSNAME 49 0050.00 C* The edit code 1 will edit the amount like 1,234.50 0051.00 O CS#OPN1 60 0052.00 O CS$OPN1 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