Ü  Compiler directive

·         Compiler directive is an instruction (directive) given to the compiler, to perform some specific task during compilation or to generate customize compiler listing report after compilation.

·         Compiler directive serve many purposes like it is used to control the heading information in compiler listing, to control the spacing of the compiler listing, to include source statement from other source member, to do a free form calculation in our rpgle program, to control the source records selection/omission based on some condition etc.

·         Compiler directives are:

(1)     /FREE... /END-FREE

(2)      /TITLE

(3)     /EJECT

(4)     /SPACE

(5)     /COPY or /INCLUDE

(6)     /IF……/ELSEIF…. /ELSE…… /ENDIF

(7)     /EOF

 

 

(1) /FREE... /END-FREE (Positions 7-11)

Compiler directive /FREE... /END-FREE is used to do a free-form calculation in our program.

 

Positions Entry Detail:

 

Positions

Positions Entry Detail

7-11

/FREE or /ENDFREE

12-80

Blank

 

Example

 

/FREE
    f8  = %abs (float);        // "float" is now 1.
    i10 = %abs (integer);      // "integer" is now 123.
    p7  = %abs (packed);       // "packed" is now 1234.567.
 /END-FREE

 



 

(2) /TITLE (Positions 7-12)

 

§  Compiler directive /TITLE is used to add heading information in the compiler listing.

§  A program can contain more than one /TITLE statement.

§  Each /TITLE statement provides heading information for the segment of compiler listing until another /TITLE statement is encountered.

§  A /TITLE statement is printed in addition to compiler heading information.

§  Each /TITLE statement is printed on a new page.

§  Positions Entry Detail:

 

Positions

Positions Entry Detail

7-12

/TITLE

13

Blank

14-100

Title information

 

Example

 

Columns . . . :    6 100                                      Browse                  		IROBO1/QRPGLESRC
SEU==>                                                                                         		INZRPG
FMT ** ... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0
*************** Beginning of data ************************************************************************
0001.00  /TITLE this is 1st title                                                                           130119
0002.00 Da                S             10A   inz(*ALL'Z')                                                  130119
0003.00 Db                S             10A   inz(*blanks)                                                  130119
0004.00  /TITLE this is 2nd title                                                                           130119
0005.00 Dc                S             10  0 inz(*zeros)                                                   130119
0006.00 Dd                S             10A   inz                                                           130119
0007.00 De                S             10  0 inz                                                           130119
0008.00  /TITLE this is 3rd title                                                                           130119
0009.00 C     a             DSPLY                                                                           130119
0010.00 C     b             DSPLY                                                                           130119
0011.00 C     c             DSPLY                                                                           130119
0012.00 C     d             DSPLY                                                                           130119
0013.00 C     e             DSPLY                                                                           130119
0014.00 C                   SETON                                        LR                                 130119
****************** End of data ***************************************************************************

 

 

Generated spool file: In the spool file below first title will be printed at the beginning of the source listing and the last title will be repeatedly printed at the beginning of each section (Diagnostic message, Cross reference, External reference, Message summary etc.).

 

					     Display Spooled File
File  . . . . . :   INZRPG                                                                               Page/Line   1/1
Control . . . . .   T                                                                                    Columns     1 - 130
Find  . . . . . .   this is
*...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+....0....+....1....+....2....+....3


this is 1st title
5722WDS V5R3M0  030905 RN        IBM ILE RPG             IROBO1/INZRPG            PUB1       01/19/13 22:54:15        Page      1
Command  . . . . . . . . . . . . :   CRTBNDRPG
Issued by  . . . . . . . . . . :     IROBO
Program  . . . . . . . . . . . . :   INZRPG
Library  . . . . . . . . . . . :     IROBO1
Text 'description' . . . . . . . :   *SRCMBRTXT
Source Member  . . . . . . . . . :   INZRPG
Source File  . . . . . . . . . . :   QRPGLESRC
Library  . . . . . . . . . . . :     IROBO1
CCSID  . . . . . . . . . . . . :     273
Text 'description' . . . . . . . :   inz keyword
Last Change  . . . . . . . . . . :   01/19/13  22:54:11
Generation severity level  . . . :   10
Default activation group . . . . :   *YES
Compiler options . . . . . . . . :   *XREF      *GEN       *NOSECLVL  *SHOWCPY
*EXPDDS    *EXT       *NOSHOWSKP *NOSRCSTMT
*DEBUGIO   *NOEVENTF
Preprocessor options . . . . . . :   *NONE


this is 1st title
5722WDS V5R3M0  030905 RN        IBM ILE RPG             IROBO1/INZRPG            PUB1       01/19/13 22:54:15        Page      2
Line   <---------------------- Source Specifications ----------------------------><---- Comments ----> Do  Page  Change Src Seq
Number ....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+...10 Num Line  Date   Id  Number
S o u r c e   L i s t i n g
1 Da                S             10A   inz(*ALL'Z')                                                        130119     000200
2 Db                S             10A   inz(*blanks)                                                        130119     000300

this is 2nd title
5722WDS V5R3M0  030905 RN        IBM ILE RPG             IROBO1/INZRPG            PUB1       01/19/13 22:54:15        Page      3
Line   <---------------------- Source Specifications ----------------------------><---- Comments ----> Do  Page  Change Src Seq
Number ....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+...10 Num Line  Date   Id  Number
3 Dc                S             10  0 inz(*zeros)                                                         130119     000500
4 Dd                S             10A   inz                                                                 130119     000600
5 De                S             10  0 inz                                                                 130119     000700

this is 3rd title
5722WDS V5R3M0  030905 RN        IBM ILE RPG             IROBO1/INZRPG            PUB1       01/19/13 22:54:15        Page      4
Line   <---------------------- Source Specifications ----------------------------><---- Comments ----> Do  Page  Change Src Seq
Number ....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+...10 Num Line  Date   Id  Number
6 C     a             DSPLY                                                                                 130119     000900
7 C     b             DSPLY                                                                                 130119     001000
8 C     c             DSPLY                                                                                 130119     001100
9 C     d             DSPLY                                                                                 130119     001200
10 C    e             DSPLY                                                                                 130119     001300
11 C                  SETON                                        LR----                                   130119     001400
* * * * *   E N D   O F   S O U R C E   * * * * *


this is 3rd title
5722WDS V5R3M0  030905 RN        IBM ILE RPG             IROBO1/INZRPG            PUB1       01/19/13 22:54:15        Page      5
A d d i t i o n a l   D i a g n o s t i c   M e s s a g e s
Msg id  Sv Number Seq     Message text
* * * * *   E N D   O F   A D D I T I O N A L   D I A G N O S T I C   M E S S A G E S   * * * * *



this is 3rd title
5722WDS V5R3M0  030905 RN        IBM ILE RPG             IROBO1/INZRPG            PUB1       01/19/13 22:54:15        Page      6
C r o s s   R e f e r e n c e
File and Record References:
File              Device             References (D=Defined)
Record
No references in the source.
Global Field References:
Field             Attributes         References (D=Defined M=Modified)
A                 A(10)                   1D      6
B                 A(10)                   2D      7
C                 P(10,0)                 3D      8
D                 A(10)                   4D      9
E                 P(10,0)                 5D     10
Indicator References:
Indicator                            References (D=Defined M=Modified)
LR                                       11D
* * * * *   E N D   O F   C R O S S   R E F E R E N C E   * * * * *



this is 3rd title
5722WDS V5R3M0  030905 RN        IBM ILE RPG             IROBO1/INZRPG            PUB1       01/19/13 22:54:15        Page      7
E x t e r n a l   R e f e r e n c e s
Statically bound procedures:
Procedure                            References
No references in the source.
Imported fields:
Field             Attributes         Defined
No references in the source.
Exported fields:
Field             Attributes         Defined
No references in the source.
* * * * *   E N D   O F   E X T E R N A L   R E F E R E N C E S   * * * * *



this is 3rd title
5722WDS V5R3M0  030905 RN        IBM ILE RPG             IROBO1/INZRPG            PUB1       01/19/13 22:54:15        Page      8
M e s s a g e   S u m m a r y
Msg id  Sv Number Message text
* * * * *   E N D   O F   M E S S A G E   S U M M A R Y   * * * * *



this is 3rd title
5722WDS V5R3M0  030905 RN        IBM ILE RPG             IROBO1/INZRPG            PUB1       01/19/13 22:54:15        Page      9
F i n a l   S u m m a r y
Message Totals:
Information  (00) . . . . . . . :        0
Warning      (10) . . . . . . . :        0
Error        (20) . . . . . . . :        0
Severe Error (30+)  . . . . . . :        0
Total . . . . . . . . . . . . . :        0
Source Totals:
Records . . . . . . . . . . . . :       11
Specifications  . . . . . . . . :       11
Data records  . . . . . . . . . :        0
Comments  . . . . . . . . . . . :        0
* * * * *   E N D   O F   F I N A L   S U M M A R Y   * * * * *




Program INZRPG placed in library IROBO1. 00 highest severity. Created on 01/19/13 at 22:54:16.
* * * * *   E N D   O F   C O M P I L A T I O N * * * * *
                          

 

 



 

(3) /EJECT (Positions 7-12)

 

§  Compiler directive /EJECT is used to make the compiler add new pages on each subsequent source specifications of the compiler listing.

 

§  Positions Entry Detail:

 

Positions

Positions Entry Detail

7-12

/EJECT

13-49

Blank

50-100

Comments

 

Example

 

Columns . . . :    6  76            Edit                        AMIT/QRPGLESRC 
 SEU==>                                                               SFLMSGPGM 
 FMT *   *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+. 
0007.00  *                                                                      
0008.00 C     SFLCLEAR      BEGSR                                               
0008.01 C                   SETON                                        41     
0008.02 C                   WRITE     ACCCTL                                    
0008.03 C                   SETOFF                                       41     
0009.00 C                   ENDSR                                               
0009.01  /EJECT                                                                 
0010.00  *                                                                      
0011.00 C     SFLLOAD       BEGSR                                               
0011.01 C                   EVAL      RRN=0                                     
0011.02 C                   DO        10                                        
0011.03 C                   EVAL      FIELD1='XXXXXXXXXX'                       
0011.04 C                   EVAL      FIELD2='YYYYYYYYYY'                       
0011.05 C                   EVAL      RRN=RRN+1                                 
0011.06 C                   WRITE     ACCSFL                                    
0011.07 C                   ENDDO                                               
0012.00 C                   ENDSR                                               
                                                                                
 F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle       
 F16=Repeat find       F17=Repeat change          F24=More keys    
             

 

 

 

                              Display Spooled File                              
 File  . . . . . :   SFLMSGPGM                        Page/Line   3/49          
 Control . . . . .                                    Columns     1 - 78        
 Find  . . . . . .                                                              
 *...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+... 
     30 C                   SETON                                        41---- 
     31 C                   WRITE     ACCCTL                                    
     32 C                   SETOFF                                       41---- 
     33 C                   ENDSR                                               
    THIS IS THE END OF THE CONTENT...   
                                        
  5722WDS V5R4M0  060210 RN        IBM ILE RPG             AMIT/SFLMSGPGM       
 Line   <---------------------- Source Specifications ------------------------- 
 Number ....1....+....2....+....3....+....4....+....5....+....6....+....7....+. 
     34  *                                                                      
     35 C     SFLLOAD       BEGSR                                               
     36 C                   EVAL      RRN=0                                     
     37 C                   DO        10                                        
     38 C                   EVAL      FIELD1='XXXXXXXXXX'                       
     39 C                   EVAL      FIELD2='YYYYYYYYYY'                       
     40 C                   EVAL      RRN=RRN+1                                 
     41 C                   WRITE     ACCSFL                                    
                                                                        More... 
 F3=Exit   F12=Cancel   F19=Left   F20=Right   F24=More keys         
            

 

 

 


 

(4) /SPACE (Positions 7-12)                   

 

§  Compiler directive /SPACE is used to control line spacing within the source section of the compiler listing.

 

§  Positions Entry Detail:

 

Positions

Positions Entry Detail

7-12

/EJECT

13

Blank

14-16

integer value from 1 through 112 to define the number of lines to space

17-49

Blank

50-100

Comments

 

 

                      

 

(5)/COPY or /INCLUDE

 

§  /COPY, /INCLUDE is used to add source records to the current program from other source members.

§  The /COPY and /INCLUDE directives have the same purpose and the same syntax, but are handled differently by the SQL preprocessor.

§  The /COPY directive is expanded by the preprocessor. The copied file can contain embedded SQL or host variables.

§  The /INCLUDE directive is not expanded by the preprocessor. The included file cannot contain embedded SQL or host variables.

§  Positions Entry Detail:

 

Positions

Positions Entry Detail

7-12

/COPY or /INCLUDE

13

Blank

14-16

integer value from 1 through 112 to define the number of lines to space

17-49

Blank

50-100

Comments

 

 

/COPY and /INCLUDE files can be either physical files or IFS files.

When specifying a physical file, the library, file, and member name, can be in one of these formats:

· libraryname/filename,membername
· filename,membername
· membername

    • A member name must be specified.
    • If a file name is not specified, QRPGLESRC is assumed.
    • If a library is not specified, *LIBL is assumed.

 

EXAMPLE

 

 

Columns . . . :    6  80                     Edit                            AMITCC/QRPGLESRC
SEU==>
FMT H  HKeywords++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*************** Beginning of data *****************************************************
0001.00 HDftActGrp(*No) ActGrp('ACT1')                                                  130124
0002.00 DCALL1            PR                                                            130124
0003.00  *                                                                              130124
0004.00  /COPY AMITCC/QRPGLESRC,E_PSDSCOPY                                              130124
0005.00  *                                                                              130124
0006.00 D@ERR             S             50    INZ(*BLANKS)                              130124
0007.00                                                                                 130121
0008.00 C  N44              CALLP     CALL1                                             130124

---------------------------------------------------------------------------------------- 

 

 

 

OUTPUT

 

When we compile the program then we see that the code is expanded as below in the compiler listing, i.e. the copy book is replaced with the actual source records.

 

3  *
4  /COPY AMITCC/QRPGLESRC,E_PSDSCOPY
*--------------------------------------------------------------------------------------------*
* RPG member name  . . . . . :  E_PSDSCOPY                                                   *
* External name  . . . . . . :  AMITCC/QRPGLESRC(E_PSDSCOPY)                                 *
* Last change  . . . . . . . :  01/24/13  06:07:05                                           *
* Text 'description' . . . . :  COPY BOOK PSDS DATA STRUCTURE                                *
*--------------------------------------------------------------------------------------------*
5+ *
6+DMYPSDS          SDS
7+DPROC_NAME          *PROC
8+ * Procedure name
9+DPGM_STATUS         *STATUS
10+ * Status code
11+D LINE_NUM               21     28
12+ * Source statement line no.
13+ *
14  *

 

 


 

(6) /IF, /ELSEIF, /ELSE, /ENDIF, /DEFINE

 

§  /IF compiler directive is used to do the conditional compilation.

§  If the condition expression is true, source lines following the /IF directive are included in the current source to be read by the compiler. Otherwise, lines are excluded until the next /ELSEIF, /ELSE or /ENDIF in the same /IF group.

§  Positions Entry Detail:

 

Positions

Positions Entry Detail

7-9

/IF

10

Blank

11-80

Condition expression

81-100

Comments

 

 

§  The /ELSEIF compiler directive is used to test a condition expression within /ELSEIF group. The following entries are used for /ELSEIF:

 

 

Positions

Positions Entry Detail

7-13

/ELSEIF

14

Blank

15-80

Condition expression

81-100

Comments

 

 

 

 

§  The /ELSE compiler directive is used to unconditionally select source lines if /IF or /ELSEIF tests falis.

 

 

Positions

Positions Entry Detail

7-11

/ELSE

12-80

Blank

81-100

Comments

 

 

§  The /ENDIF compiler directive is used to end the /IF, /ELSEIF or /ELSE group.

 

 

Positions

Positions Entry Detail

7-12

/ENDIF

13-80

Blank

81-100

Comments

 

 

§  /DEFINE is used to define an element that will be used as a condition element for /IF, /ELSEIF directive.

 

 

EXAMPLE

 

Columns . . . :    6  80                     Browse                          AMITCC/QRPGLESRC
SEU==>                                                                             DEFINE_EX1
FMT H  HKeywords++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*************** Beginning of data ****************************************************
0001.00 HDftActGrp(*No) ActGrp('TEST1')                                                 130124
0002.00  /DEFINE def1                                                                   130125
0003.00 DCALL1            PR                                                            130124
0004.00  *                                                                              130124
0005.00  /IF DEFINED(def1)                                                              130125
0006.00  /COPY AMITCC/QRPGLESRC,E_PSDSCOPY                                              130124
0007.00  /ENDIF                                                                         130125
0008.00  *                                                                              130124
0009.00 D@ERR             S             50    INZ(*BLANKS)                              130124
0010.00                                                                                 130121
0011.00 C  N44              CALLP     CALL1                                             130124
0012.00 C                   SETON                                        LR             130122 


 

Output

 

 

Here, copybook E_PSDSCOPY will be included in our program since we have defined def1.

 


 

 

(7)  /EOF Directive

 

The /EOF directive tells the compiler to ignore the rest of the source lines in the current source member.

 











User Comments:



Subscribe

.  


Copyright © www.go4as400.com, 2013-2023. Copyright notice   Terms of services   Privacy policy