SPACEA (Space After)- Printer file keyword in IBM i |
Introduction to SPACEA keyword in PRTF
SPACEA i.e. space after keyword is used with printer files to provide some lines of spacing after printing some lines. Since, Printer file consists of the records i.e. record format and fields. Therefore, SPACEA keyword can be used at record level or the field level.
The format of the keyword is as follows:
SPACEA(space-after-value)
The parameter value is mandatory and range between 0 to 255. You can specify the SPACEA keyword only once at the record level or once per fields. SPACEA keyword is not valid for records with specified line numbers.
Using SPACEA keyword at record level
Refer the below External PRTF example using SPACEA keyword at the record level.
A R HEADER SPACEA(2) A 5'FLD1' A +5'FLD2' A R DETAIL SPACEA(2) A PFLD1 10A 5 A PFLD2 5S 0 +5 A R FOOTER A 62 20'---END OF REPORT---'
In the above DDS PRTF code, SPACEA(2) keyword is used at record format level. SPACEA(2) is specified for record format HEADER and DETAIL. Therefore, after printing all the lines associated with HEADER record format 2 line spacing would be provided and then the next record format DETAIL lines gets printed. Since, SPACEA(2) is specified for record format DETAIL as well. Therefore, 2 lines spacing would be provided after printing all the lines in DETAIL record format.
Let's see the design of the PRTF for above DDS PRTF source using option 19 on the external prtf dds source member.
Columns . . . : 1 121 Design Report EASYCLASS1/PRTF RLU==> PRTF3A BASE ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0 ...+... 1 ...+... 2 -------------------------------------------------- Start of Page 001 ---------------------------------------------------- FLD1 <..> <..> HEADER FLD1 FLD2 00002 + 00003 + FLD1 <........> <...> DETAIL XXXXXXXXXX 99999 00005 + 00006 + 00007 . 00008 . 00009 . 00010 . 00011 . 00012 . 00013 . 00014 . 00015 . 00016 . 00017 . 00018 . 00019 . 00020 . 00021 . 00022 . 00023 . 00024 . 00025 . 00026 . 00027 . 00028 . 00029 . 00030 . 00031 . 00032 . 00033 . 00034 . 00035 . 00036 . 00037 . 00038 . 00039 . 00040 . 00041 . 00042 . 00043 . 00044 . 00045 . 00046 . 00047 . 00048 . 00049 . 00050 . 00051 . 00052 . 00053 . 00054 . 00055 . 00056 . 00057 . 00058 . 00059 . 00060 . 00061 . FLD1 <.................> FOOTER ---END OF REPORT--- ---------------------------------------------------- End of Report ------------------------------------------------------
Using SPACEA keyword at field level
Refer the below External PRTF example using SPACEA keyword at the field level.
A R HEADER A 5'FLD1' A SPACEA(2) A +5'FLD2' A R DETAIL SPACEA(2) A PFLD1 10A 5 A PFLD2 5S 0 +5 A R FOOTER A 62 20'---END OF REPORT---'
In the above DDS PRTF code, SPACEA(2) keyword is used at field level. SPACEA(2) is specified for field heading 'FLD1' which starts printing on 1st line and after that 2 line spacing would be given and then heading 'FLD2' gets printed on 3rd line. Again the SPACEA(2) keyword used at record level DETAIL so that DETAIL record format lines would start printing from the same 3rd line and spacing of 2 lines would be given after printing each line of DETAIL record format.
Let's see the design of the PRTF for above DDS PRTF source using option 19 on the external prtf dds source member.
Columns . . . : 1 121 Design Report EASYCLASS1/PRTF RLU==> PRTF3 BASE ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0 ...+... 1 ...+... 2 -------------------------------------------------- Start of Page 001 ---------------------------------------------------- FLD1 <..> HEADER FLD1 00002 + FLD1 <..> 00003 + FLD2 FLD1 <........> <...> DETAIL XXXXXXXXXX 99999 00005 + 00006 + 00007 . 00008 . 00009 . 00010 . 00011 . 00012 . 00013 . 00014 . 00015 . 00016 . 00017 . 00018 . 00019 . 00020 . 00021 . 00022 . 00023 . 00024 . 00025 . 00026 . 00027 . 00028 . 00029 . 00030 . 00031 . 00032 . 00033 . 00034 . 00035 . 00036 . 00037 . 00038 . 00039 . 00040 . 00041 . 00042 . 00043 . 00044 . 00045 . 00046 . 00047 . 00048 . 00049 . 00050 . 00051 . 00052 . 00053 . 00054 . 00055 . 00056 . 00057 . 00058 . 00059 . 00060 . 00061 . FLD1 <.................> FOOTER ---END OF REPORT--- ---------------------------------------------------- End of Report ------------------------------------------------------
RPGLE program to print the external PRTF demonstrating the use of keyword SPACEA either at record level or field level
FPF1 IF E K DISK FPRTF3A O E PRINTER OFLIND(*IN01) C WRITE HEADER C *LOVAL SETLL PF1 C READ PF1 C DOW NOT%EOF(PF1) C IF *IN01 = *ON C WRITE HEADER C EVAL *IN01 = *OFF C ENDIF C EVAL PFLD1 = FLD1 C EVAL PFLD2 = FLD2 C WRITE DETAIL C READ PF1 C ENDDO C WRITE FOOTER C EVAL *INLR = *ON C RETURN
FPF1 IF E K DISK FPRTF3A O E PRINTER OFLIND(*IN01) /Free WRITE HEADER; setll *loval PF1; read PF1; dow not%eof(pf1); if *in01 = *ON; WRITE HEADER; *IN01 = *OFF; endif; PFLD1 = FLD1; PFLD2 = FLD2; WRITE DETAIL; read PF1; enddo; WRITE FOOTER; *inlr = *ON; return; /End-Free
**FREE DCL-F PF1 DISK KEYED USAGE(*INPUT); DCL-F PRTF3A PRINTER USAGE(*OUTPUT) OFLIND(*IN01); WRITE HEADER; setll *loval PF1; read PF1; dow not%eof(pf1); if *in01 = *ON; WRITE HEADER; *IN01 = *OFF; endif; PFLD1 = FLD1; PFLD2 = FLD2; WRITE DETAIL; read PF1; enddo; WRITE FOOTER; *inlr = *ON; return;
Object creation/Execute program/Browse spool
Take option 14 on source member to create the PRTF and teh RPGLE program or you can run command CRTPRTF to create the PRTF object and CRTBNDRPG command to create the RPGLE object.
Call the program using CALL command from the IBM i command line. The program will print the spool file and that can be either browse using WRKJOB then option 4 or using WRKSPLF command.