Return to the RPG Tips
Here is a boilerplate program that prints GDDM graphics and AFP data on the same page
Here is a boilerplate program that prints GDDM graphics and AFP data on the same page. The "secret" is to use the same printer file in the F spec as in your GDDM calls, and to specify SHARE(*YES) so that the two processes will write to the same "data path." The GDDM books describe the fonts you can use for the GSLSS (Get character set) command. Also, you need to add QGDDM to the library list when compiling and running. <> < > filename="graphics.rpg" H 1 H* Program GRAPHICS H* Print samples of various GDDM routines mixed with regular H* AFP printer file output. H* H* Before compiling, ADDLIBLE QDGGM H* Before running, ADDLIBLE QDGGM and OVRPRTF GRPRTF SHARE(*YES) H* If you forget to SHARE, then you'll get 2 print files... H* H/SPACE 2 F* Conventions used - F* Field names - Names beginning with I are of type INTEGER F* Names beginning with F are of type FLOAT POINT F* Names beginning with C are of type CHARACTER F* Arrays of the above types are specified by F* the addition of the letter A after the field F* type designation. F* In addition, the routine calls to GDDM each F* have their own field name equal to the name of F* the routine being called. F* Examples follow. F* Type Name F* Integer I01 F* Floating F01 F* Character C10 F* Int array IA01 F* Flt array FA01 F* Chr array CA01 F* FGRPRTF O E PRINTER UC F/SPACE 2 E CA03 50 1 E IA01 1 4 9 0 Open options E FA01 1 5 10 2 CA01 10 Pie values I/SPACE 2 I* Integer variables I DS I B 1 40I01 I B 5 80I02 I B 9 120I03 I B 13 160I04 I B 17 200I05 I B 21 240I06 I B 25 280I07 I B 29 320I08 I B 33 360I09 I B 37 400I10 I/SPACE 2 I* Short FP variables I DS I P 1 42F01 I P 5 82F02 I P 9 122F03 I P 13 162F04 I P 17 202F05 I P 21 242F06 I P 25 282F07 I P 29 322F08 I P 33 362F09 I P 37 402F10 I/SPACE I* INT array variables I DS I B 1 160IA01 I/SPACE 2 C* Initialise graphics C CALL 'GDDM' C PARM 'FSINIT 'GPARM 8 C* Prepare printer C CALL 'GDDM' C PARM 'DSOPEN 'GPARM C PARM 2 I01 C PARM 1 I02 C PARM 'IPDS 'C08 8 C PARM 0 I03 C PARM IA01 C PARM 1 I04 C PARM 'GRPRTF 'C10 10 C* Using printer C CALL 'GDDM' C PARM 'DSUSE 'GPARM C PARM 1 I01 C PARM 2 I02 C* Put some text print on printer for testing C OPEN GRPRTF C WRITETEXT C* Put some AFP print on printer for testing C MOVE *ALL'1234'BARCOD C WRITEAFP C* Aspect ratio 1 to 1 C CALL 'GDDM' C PARM 'GSPS 'GPARM C PARM 1 F01 C PARM 1 F02 C/EJECT C* Generate picture C* Picture will be fancy text, a pie chart and a line graph C* Do the fancy text C* SELECT CHAR MODE 3 C CALL 'GDDM' C PARM 'GSCM 'GPARM C PARM 3 I01 C* Character box sixe=20 C CALL 'GDDM' C PARM 'GSCB 'GPARM C PARM 20 F01 C PARM 20 F02 C* LOAD CHAR SET C CALL 'GDDM' C PARM 'GSLSS 'GPARM C PARM 2 I01 C PARM 'ADMUWGEP'C08 C PARM 65 I02 C* SELECT CHAR SET C CALL 'GDDM' C PARM 'GSCS 'GPARM C PARM 65 I01 C* Fancy name C CALL 'GDDM' C PARM 'GSCHAR 'GPARM C PARM 1 F01 C PARM 1 F02 C PARM 5 I01 C PARM 'Fancy' C05 5 C* Do the pie chart C Z-ADD5 NUMSEG 50 # of segments C* SET CHART AREA TO 50% OF PICTURE SPACE C CALL 'GDDM' C PARM 'CHAREA 'GPARM C PARM 0 F01 C PARM .5 F02 C PARM 0 F03 C PARM .5 F04 C* PERCENTAGE PIE CHART C CALL 'GDDM' C PARM 'CHSET 'GPARM C PARM 'PERPIE' C06 6 C* PIE KEY C* Build key text C MOVE *BLANKS SEGKEY 50 C 1 DO NUMSEG X 50 C X MULT 10 Y 50 C SUB 9 Y C MOVEACA01,X CA03,Y C ENDDO C MOVEACA03 SEGKEY C* Set key attributes C CALL 'GDDM' C PARM 'CHKEY 'GPARM C PARM NUMSEG I01 C PARM 10 I02 C PARM SEGKEY C50 50 C* DRAW THE HEADING C MOVEL'Pie Head'PIEHED 8 C CALL 'GDDM' C PARM 'CHHEAD 'GPARM C PARM 8 I01 C PARM PIEHED C08 C* DRAW THE PIE C CALL 'GDDM' C PARM 'CHPIE 'GPARM C PARM 1 I01 C PARM NUMSEG I02 C PARM FA01 C* C* End of picture generation C/EJECT C* Send picture C CALL 'GDDM' C PARM 'FSFRCE 'GPARM C* Terminate processing C CLOSEGRPRTF C CALL 'GDDM' C PARM 'FSTERM 'GPARM C SETON LR C RETRN ** IA01 - Options for DSOPEN 000000000 000000000 000000000 000000000 ** FA01/CA01 Pie chart values (must equal 100) 0000001000Heat 0000002000Power 0000003000Sewage 0000003500Telephone 0000000500Water filename="grprtf.dds" A* CRTPRTF FILE(BUCK/GRPRTF) SRCFILE(BUCK/QDDSSRC) DEVTYPE(*AFPDS) A* PAGESIZE(99 132) LPI(9) CPI(10) OVRFLW(90) RPLUNPRT(*NO) A* CHRID(101 037) SPOOL(*YES) OUTQ(*JOB) FILESEP(0) SCHEDULE(*FILEEND) A* LVLCHK(*NO) SHARE(*NO) TEXT('Graphics/text mixed sample') A* A* Occupies 22 lines A R TEXT TEXT('Plain text section') A SKIPB(3) A 2DATE A 12TIME A 30'Sample text/graphics' A 70'GRAPHICS' A SPACEA(2) A* A 5'CRTPRTF FILE(yourlib/GRPRTF) +' A SPACEA(1) A 5'SRCFILE(yourlib/QDDSSRC) +' A SPACEA(1) A 5'DEVTYPE(*AFPDS) +' A SPACEA(1) A 5'PAGESIZE(99 132) +' A SPACEA(1) A 5'LPI(9) +' A SPACEA(1) A 5'CPI(10) +' A SPACEA(1) A 5'OVRFLW(90) +' A SPACEA(1) A 5'RPLUNPRT(*NO) +' A SPACEA(1) A 5'CHRID(101 037) +' A SPACEA(1) A 5'SPOOL(*YES) +' A SPACEA(1) A 5'OUTQ(*JOB) +' A SPACEA(1) A 5'FILESEP(0) +' A SPACEA(1) A 5'SCHEDULE(*FILEEND) +' A SPACEA(1) A 5'LVLCHK(*NO) +' A SPACEA(1) A 5'SHARE(*NO) +' A SPACEA(1) A 5'PAGRTT(0) +' A SPACEA(1) A 5'TEXT(''Graphics/text mixed sample- A '')' A SPACEA(1) A* Occupies 4 lines A R AFP TEXT('AFP section') A SKIPB(30) A 2'Bar code below' A SPACEA(3) A FONT(762) A BARCOD 11 O 2 A BARCODE(CODE3OF9 2 *NOHRI) A SPACEA(1)
[report a broken link by clicking here]