Now, Get RPG Codes in all three formats only on this website on every RPGLE related programming article.

Fixed, /Free and Fully Free RPG


SPACEB (Space Before)- Printer file keyword in IBM i

This article explains the usage of SPACEB keyword in printer files in IBM i
SPACEB (Space before)- Printer file keyword in IBM i,printer files, prtf,external printer file, external prtf, SPACEB, SPACEB(space before value), spaceb keyword in prtf, spaceb in as400, SPACEB in ibmi,space before keyword in prtf as400,printer, OFLIND, crtprtf, wrkjob, wrksplf, CALL, RPGLE program to print external printer file using SPACEB keyword, ibmi, as400, as400 and sql tricks, as400 tutorial, ibmi tutorial, iseries, systemi, dds prtf, SPACEB vs SPACEA, SPACEA vs SPACEB, difference between SPACEB and SPACEA keyword in PRTF, rpgle, rpgiv, RPGLE free format code for printing PRTF, fully free rpg code for printing prtf, fixed format rpg code for printing prtf
SPACEB (Space Before)- Printer file keyword in IBM i

Introduction to SPACEB keyword in PRTF

SPACEB i.e. space before keyword is used with printer files to provide some lines of spacing before printing some lines. Since, Printer file consists of the records i.e. record format and fields. Therefore, SPACEB keyword can be used at record level or the field level.

The format of the keyword is as follows:

SPACEB(space-before-value)

The parameter value is mandatory and range between 0 to 255. You can specify the SPACEB keyword only once at the record level or once per fields. SPACEB keyword is not valid for records with specified line numbers.

Using SPACEB keyword at record level

  • If this keyword is specified at record format level, then spacing occurs before all lines/fields associated with that record format gets printed.
  • Refer the below External PRTF example using SPACEB keyword at the record level.

         A          R HEADER                    SPACEB(2)             
         A                                     5'FLD1'                
         A                                    +5'FLD2'                
         A          R DETAIL                    SPACEB(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, SPACEB(2) keyword is used at record format level. SPACEB(2) is specified for record format HEADER and DETAIL. Therefore, before 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, SPACEB(2) is specified for record format DETAIL as well. Therefore, 2 lines spacing would be provided before 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==>                                                                                                                      PRTF4A
     BASE    ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0 ...+... 1 ...+... 2   
            -------------------------------------------------- Start of Page 001 ----------------------------------------------------  
    00001 .                                                                                                                            
    00002 .                                                                                                                            
    FLD1        <..>     <..>                                                                                                          
     HEADER     FLD1     FLD2                                                                                                          
    00004 .                                                                                                                            
    FLD1        <........>     <...>                                                                                                   
     DETAIL     XXXXXXXXXX     99999                                                                                                   
    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 SPACEB keyword at field level

  • If this keyword is specified at field level, then spacing occurs before the field gets printed.
  • Refer the below External PRTF example using SPACEB keyword at the field level.

         A          R HEADER                                            
         A                                     5'FLD1'                  
         A                                       SPACEB(2)              
         A                                    +5'FLD2'                  
         A          R DETAIL                    SPACEB(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, SPACEB(2) keyword is used at field level. SPACEB(2) is specified for field heading 'FLD1' which starts printing on 3rd line before that 2 line spacing would be given and then heading 'FLD2' gets printed on the same 3rd line next to FLD1. Again the SPACEB(2) keyword used at record level DETAIL so that DETAIL record format lines would start printing from the 5th line and spacing of 2 lines would be given before 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==>                                                                                                                       PRTF4
     BASE    ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0 ...+... 1 ...+... 2   
            -------------------------------------------------- Start of Page 001 ----------------------------------------------------  
     HEADER                                                                                                                            
    00002 +                                                                                                                            
    FLD1        <..>     <..>                                                                                                          
    00003 +     FLD1     FLD2                                                                                                          
    00004 .                                                                                                                            
    FLD1        <........>     <...>                                                                                                   
     DETAIL     XXXXXXXXXX     99999                                                                                                   
    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 SPACEB either at record level or field level

    Refer the RPGLE code in Fixed, /Free and Fully free RPG from the following link.

    RPGLE program to print the external PRTF demonstrating the use of keyword SPACEA either at record level or field level

    Object creation/Execute program/Browse spool

    Take option 14 on source member to create the PRTF and the 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.

    Post a Comment

    © AS400 and SQL Tricks. All rights reserved. Developed by Jago Desain