Sunday, December 15, 2013

Day-28.

Introduction To RPG IV:

 Overview:

This module enables the student to understand the concept of RPG IV.
 Outline:
Topics covered,
a.     Introduction to RPG IV
b.     Built -in functions
c.     Date and Time Data Types
 Objective:
By the end of this module, the student should be able to:

a. Understanding Of Basic Concepts RPG IV

b. Built In Function

            c. Date and Time Data Types

Introduction to RPG IV
RPG IV is the latest version of RPG language. RPG IV is a syntax that participates in IBM’s Integrated Language Environment (ILE) architecture or programming model. RPG IV diverges from its predecessor RPG III, in significant ways. This latest release is backward compatible. That means program written before 1995 can easily be converted to RPG IV and subsequently modified without complete program rewrite.

RPG III was criticized as difficult to understand because of its short data names, abbreviated operation codes and rigidly fixed format. The critics contended that the language was showing age in its limited choice of data types (e.g. no direct support date data types) and its inability to handle multidimensional arrays etc.

To address some of these shortcomings in RPG, IBM introduced in 1994, concurrent with the release of Version 3 Release of OS/400, improved version of RPG and named it RPG IV.

RPG IV relaxes many of the strict fixed format requirements imposed by previous RPG versions, allowing free-format expressions and keyword notation in its specifications. Data naming limits have been extended and many other artificial limits have been effectively removed from the language. RPG IV adds several new organizational concepts like a central data definition specification and procedure prototyping.

In 2000, IBM created a new all inclusive eServer family; the AS/400 became the eServer, iSeries 400 (iSeries in short). Recent release of RPG IV has focused on enabling the RPG IV architecture to co-exist with Internet-based applications and object-oriented languages like Java.

·         Summary of RPG III to RPG IV Changes:
o      A source migration tool is provided to convert RPG III source code to RPG IV source code. The default source-file name has changed from QRPGSRC to QRPGLESRC and the record length has been expanded from 92 to 112 bytes. The existing SEU date and sequence number fields remain unchanged. The increase of the source statement length from 80 to 100 characters accommodates the new syntax with longer file and field names as well as the expanded comment length (positions 81 to 100).

o      The new Definition specifications. (P-spec) allow you to define sub-procedures. In RPG terms, sub-procedures are similar to sub-routines except:
§  You can pass parameters to them.
§  They do not use RPG cycle
§  They can be prototyped (which causes the compiler to check parameters for consistency).
§  They allow you to define local variables.
§  They can be invoked in expressions, similar to IBM supplied built-in functions.
§  You can call them outside the source module in which they are defined if they are exported.

·         RPG IV now supports 10-character file, format, field, constant, data structure, key-list, subroutine label and other symbolic names.

·         The underscore(_) is now valid in symbolic name but it cannot be the first character. Thus EMP_NAME is a valid field name but _NAME is not.

·         Array subscripts are specified using parentheses () instead of a comma’,’.
      ARR,X in RPG III becomes ARR(X) in RPG IV.

o      Uppercase and lowercase characters can be used anywhere in an ILE RPG program. The field names EmpName and EmpLoc are now valid. The operation codes ‘CHAIN’, ‘Chain’ all perform the same function. The (ILE RPG compiler converts the lowercase characters to uppercase. Comments, literals (with the exception of hexadecimal literals), compile time array and table data are not translated to uppercase. Currency symbol ($), date and time-edit values on the Control specifications (H-spec), date and time separator characters on the Input specification (I-spec) and comparison characters on Record Identification entries on I-spec are also not converted to uppercase.

o      Blank lines are permitted in RPG IV. Source statements that are blank in positions 6 to 80 are treated as comments. An asterisk (*) in position 7 also forces a statement to be a comment just as it does in RPG III. In general, positions 81 to 100 are treated as comments in source statements except for compile-time table and array data.

o      Freeform mathematical expressions and logical expressions are available. With the EVAL operation you area now able to use natural mathematical expressions as follows:

EVAL                 SLSTOT=SLSAMT1+SLSAMT2

o    Built-in functions are similar to operation codes as they perform operation on given data. However, built-in functions can be embedded into an expression. E.g.
EVAL                 LSTNAME=%SUBST(FULLNAME:16:20)

o      With newer V4R2 built-in functions, you can eliminate resulting indicators on operation such as CHAIN, SETALL or LOOKUP. E.g. you can use the %FOUND function determine if a CHAIN was successful as shown in following statement:
CUST#  CHAIN              CUSTREC
IF                     %FOUND(CUSTMST)

o      Now you have more powerful date manipulation capabilities through date, time and time-stamp data type support including new date and time operation such as Add Duration (ADDDUR) and Subtract Duration (SUBDUR).

o      Many operation code names such as LOKUP, DELET, UPDAT, UNLCK and REDPE have been changed to longer and more meaningful names as LOOKUP, DELETE, UPDATE, UNLOCK and READPE.

Comparison between RPG III and RPG IV.

Sr.No
RPG III
RPG IV
1.
Compilation of source members creates an executable object called *PGM using command CRTXXXPGM (where XXX is a program type)
RPG III
Compile
*PGM
E.g. CRTRPGPGM: RPG program object.
CRTCLPGM: CL program object
Compilation of source member, first creates a non-executable object *MODULE using command CRTXXXMOD. (Where XXX is a program type). Various modules are bound together to create program object *PGM using command CRTPGM. (It is not any particular type of program, just *PGM).
2.
RPG III provides dynamic calls. (Call to external programs are resolved at run time)
RPG IV provides static (Compile time) as well as dynamic (run-time) call.
3.
RPG III supports OPM debugger.
RPG IV supports source-level debugger.
4.
Record Length of the source code=92
Record Length of the source code =112
5
Field names are restricted up to 6 chars.
RPG IV supports 10-character field length.
6.
Constants can be defined up to 256 bytes
Constants can be defined up to 1024 bytes.
7.
Decimal places up to 9 digits
Decimal places up to 30 digits
8
Character variables and array elements are restricted up to 256 bytes
Character variables and array elements are of 32767 bytes
9
Maximum 50 files can be opened.
No limits.
10
Length of Factor 1 and Factor 2=10
Length of Factor 1 and Factor 2=14
11
Opcode length =5
Opcode length =10
12
Fixed format
Free Format only for Factor 2
13
Indicators are compulsory
Not compulsory
14
Variables scope is limited to program only. No concept of Local Variable
Introduces a concept of Local Variables

          Introduction to RPG IV specifications in brief
RPG IV programs are written as fixed-format or free-format specifications. Different specification forms convey different kinds of information to the RPG IV compiler, which translates the program into machine language.

The E specs in RPG III have been removed in RPG IV. The E specs and I specs together are defined by new D specifications. A P spec is one more specs introduced in RPG IV.

7 Specifications

Specification Name

Identifier in 6th position
Header Specifications

H

File Description Specifications

F

Definition Specifications

D

Input Specifications (for program described input files)

I

Calculation Specification

C

Procedure Specification

P

Output Specifications

O


          Specifications in detail
  • H Specification
In ILE RPG III, Header specification is used for writing header information in a program. However, instead of entering values in specific positions (Fixed-format), as in RPG III, ILE RPG uses keywords notations. Many Compile options can be specified through Keywords in H specs. Positions 7 through 80 are used for entering control specification keywords.
o      DATFMT (Date Format): DATEFMT specifies the format of date literals and date fields within the program. This keyword accepts two parameters. I: Date format (Required) and 2: separator character (optional). Default date format is *ISO and the default separator character is (-).
E.g. DATFMT (*JUL)
The possible values of date formats are as below:
§  *MDY=(MM/DD/YY)
§  *DMY=(DD/MM/YY)
§  *YMD=(YY/MM/DD)
§  *JUL=(YY/DD)
§  *USA=(MM/DD/YYYY)
§  *EUR=(DD.MM.YYYY)
§  *JIS=(YYYY-MM-DD)

o      DATEDIT (Date Edit): DATEEDIT specifies the separator character for the Date format used. This keyword accepts 2 parameters 1. Date format 2. Separator Character. (Default is /). We can specify various date separator character as ‘-‘ ‘&’. E. g. DATEDIT (*YMD-)

o      CURSYM (Current Symbol): CURSYM specifies the format of time literals and time fields within the program. The default is *ISO format with default separator as (.). This keyword accepts 2 parameters: 1. Time format (required) and 2: Separator (optional). The possible values are as follows:

§  *ISO=(HH.MM.SS)
§  *HMS=(HH:MM:SS)
§  *USA=(HH:MM: AM or HH:MM: PM)

E.g.TIMFMT (*USA).

F Specification
File Specification is used for declaring files in the program. It also describes how the files will be used within a program. In ILE RPG, F-specs use a combination of fixed notation and keyword notation. The fixed notation portion extends from position 7 to 42. The F-specs of ILE RPG have been modified to accommodate expanded length. The file name is expanded from 8 characters to10 characters and record-length is expanded from 4 characters to 5 characters.
Functions defined in RPG III are defined in terms of keywords in ILE RPG. Some of the examples are as below:

o      RENAME (Old Record Format: New Record Format)-The RENAME keywords allow you to change a record-format name used in an externally described file. Example is as follows:

    FMBMLO2        IF     E    K DISK      RENAME (IPM500BM:IPM50r)

               Here record format IPM500BM is renamed to IPM50R.


o      PREFIX (prefix_string: nbr_of_char_replaced): The PREFIX keyword is used to partially rename the fields in externally described files. Prefix string is the string we want to use as a prefix and nbr_of_char_replaced specifies the number of characters to be replaced.

    FMBMLO2        IF     E    K DISK    PREFIX($L:2)

              Fields of file MBMLO2 now will be starting from $L.


o      SFILE (name_of_subfile: field_RRN): The SFILE keyword identifies any subfiles used in a display file included in a program. This keyword has 2 parameters:

§  Subfile name
§  Field, which stores Relative Record Number.
             FTEMP  CF     E      WORKSTN SFILE(subfile:field_RRN)
 
 

  
o      USROPN: The USPORN keyword specifies that file is User Controlled. When this keyword is used, file must be opened with OPEN operation.

           FITBAL IF     E      K DISK USROPN
 



  • D Specification

  •            It is the new specification introduced by ILE for data definition. D specs can be used to   define:

    o      Standalone fields including arrays and tables
    o      Named Constant
    o      Data Structures and their subfields.

    D specs replace E-specs of RPG III. Following table explains D-Specs Format.

    Statement Position
    Purpose
    Valid Values
    6
    Definition Specification
    D
    7-21
    Name of field, array, table, named constant, data structure or data structure subfield.
    Any valid symbol name
    22
    Data Structure Identification
    Externally described data structures
    Non-externally described data structures
    E
    Blanks
    23
    Type of Data Structure:
    Program Status data structure
    Data Area data Structure
    Non-program status data structure or non data area data structure.
    S
    U
    Blank
    24-25
    Type of Definition:
    Data structure Subfield
    Name constant
    Data Structure
    Standalone field or array
    Prototype
    Procedure Interface
    Blank
    C
    DS
    S
    PP
    PI
    26-32
    From Position/keyword:

    Keywords for file information and program status data structure.
    Blank
    I through 9999999
    PROC, *STATUS
    33-39
    To position/length
    Data structure definition
    Field define LIKE another field
    Absolute end position
    Increase or decrease field size when defining a field LIKE another field
    Blank

    1 through 9999999
    +/-1 through 99999
    40
    Internal type of field, subfield or array element
    Data, Time, Timestamp
    Signed & Unsigned Integer, Floating point
    Packed, Zone, Character
    D,T,Z
    I,U,F
    P,S,A
    41-42
    Decimal Positions
    0 through30
    44-80
    Keywords
    E.g. ALT,DIM,INZ,LIKE
    81-100
    Comments
    Optional


    •  Examples:
    1.Constant
    D CMPNM       C             CONST (‘Midrange Computing’)

    D LWR  C             ‘abcdefghjklmnopqrs-
                               Tuvwxyz’
    D Twenty      C             CONST (20)

    2.Standalone Field
    D $flag       S      2A     INZ (*Blanks)

    D &Name       S             LIKE (PRNAME)




    D Specs permit us to consolidate data definition in a single place in your program.

    • The D spec EXTPGM keyword: The EXTPGM keyword indicates the external name of the program whose prototype is being defined. The name can be a character constant or a character variable. If EXTPGM is not specified, then the compiler assumes that you are defining a prototype for a procedure, and assigns it the external name found in positions 7-21.

    Any parameters defined by a prototype with EXTPGM must be passed by reference; in addition you cannot define a return value. If the keyword EXTPGM is specified on the prototype, the call will be a dynamic external call; otherwise it will be a bound procedure call.

    D*
    DcmdLinAP1    Pr            EXTPGM(‘QUSCMDLM’)
    C*
    C             CAIIP  CmdLinAPI
    C             Eval   Inlr=On


    In the given example, when you perform a call to the CmdLinAPI prototype, the API (built-in system program) QUSCMDLN will actually be called. API QUSCMDLN presents an OS/400 system command line for use within a program.

    ·         I Specification
    In RPG III, I specs are mainly used for field and record information and also defining data structures, data areas and named constant. In ILE RPG, all the data definition is consolidates in D specs at one area of program. Still I specs are used for defining program described files. In ILE RPG, there are many changes to the field entry I Specs:

    o      Expanded File name (up to 10 chars)
    o      Expanded Record length (up to 32766)
    o      External date/time format specifier(for program described file field)
    o      Date/time separator character.

    ·         C Specification
    ILE RPG C Specs provides free-form expression capabilities to some RPG operations. For example with the use of new EVAL operation we can perform free-form arithmetic expressions. We can also perform logical expression such as Conditional Branching and In ILE RPG, FACTOR1, FACTOR2 and RESULT fields have all been increased to 14 WHENEQ, UPDATE, DELETE, UNLOCK, RETURN, READPE, CHECKRE etc)

    Blank lines are allowed and treated as a comment line.

    EVAL Operation:
    Eval Qname = Patext1 + Patext2
    The expression for evaluation can contain the arithmetic operators +(addition), -(subtraction), *(multiplication), /(division) and **(exponentiation) as well as parenthesis, relational symbols(e.g.<,>), logical operators (e.g, AND, OR) and built-in functions.

    Note:In the example given above, + sign indicates Concatenation.

    IF
    If     ($LEN>3)
    Eval   Cnt = $Cnt + 1
    Endif


    ·         P Specification
    ILE RPG introduces concept of subprocedures. P-specs are used to define such Subprocedures and they denote the beginning and the end of the subprocedure. If we are passing any parameters to procedures, such parameter definition (i.e. procedure interface definition) takes place in D Specs.

    When you describe P-specs, you describe prototyped procedures or sub-procedures. P-spec is the simplest ILE RPG specification. The P-specs were introduced when ILE RPG was enhanced to support sub-procedures.

    RPG IV Description

    Specification Position

    6
    Form Type (P)
    7-21
    Sub-procedure Name
    24
    Begin/End Procedure Code
    44-80
    Keywords

    When a sub-procedure is defined, the main source section of the module containing the sub-procedure definition must contain a procedure prototype. Sub-procedure contain the following:
    o      A begin-procedure specification (b in position 24 of a procedure specification)
    o      A procedure-interface definition (if the procedure returns value or any parameters). The procedure interface must match the corresponding prototype.
    o      Other definition specifications of variables, constants and prototypes needed by the sub-procedure. These definitions are local definitions.
    o      Any calculation specification needed to perform the task of the procedure If the sub-procedure returns a value, then a return operation must be coded within the sub-procedure.
    o      An end-procedure specification (c in position 24 of a procedure specification).

    The Procedure-interface definition may be placed anywhere within the definition specifications. But a sub-procedure must be coded in the order stated above.

    Procedure name is required in begin-procedure specification. But the procedure name is optional in the end-procedure specification.

    The P-Spec EXPORT Keyword
    EXPORT is the only keyword for the P-spec. Export is used to indicate that this procedure can be invoked from another module in the program. With the EXPORT keyword specified, the sub-procedure can be bound to and can be called by any program.

    If a module is entirely self-contained, EXPORT keyword is not required. Normally a sub-procedure is to encourage the reuse of code. Defining the sub-procedures outside of mainline code and using the EXPORT keyword enables this use.

    ·         O Specification
    The major differences between RPG III O specs and ILE RPG O specs are changes to:
    o      Accommodates 10 character file and field names.
    o      The continuation of literals (both ‘+’ or ‘-‘) and edit words
    o      Supports for larger space before and after values ( values from 0 to255are supported for space before and space after, skip before and skip after) and
    o      Supports for additional data formats (Z,D,T).

              Date and Time Data Types
    Three data types deal with date and time related information: date, time and timestamp. Date and Time are self-explanatory. A timestamp is a combination of a date and time. RPG supports these data types in calendar-related operations, using certain operation codes and built in functions.
    To define standalone fields with the date/time data types, you specify a D(for dates) T (for times) or Z (for time-stamps) in column 40. Each data type has a default length and display format (*ISO).]

    The default display format for type date (D) is a 10-byte-long field with format yyyy-mm-dd. Time (T) has a default length of 8 bytes, with format hh. mm. ss. The default display format for timestamp (Z) has a length of 26 bytes, with format yyy-mm-dd-hh.mm.ss.mmmmmm.

    The date and time data types allow alternative display formats (with the keyword DATFMT) to the defaults. Date supports eight different formats and Time supports five.
    Following tables list the valid Date and Time formats:

    DATFMT

    Description

    Representation

    Example

    *ISO
    International Standards Org
    yyyy-mm-dd
    9999-12-31
    *USA
    IBM USA standard
    mm/dd/yyy
    12/31/9999
    *EUR
    IBM European standard
    dd.mm.yyy
    31.12.9999
    *JIS
    Japanese Industrial Standard
    yyy-mm-dd
    9999-12-31
    *YMD
    Year/month/day
    Yy/mm/dd
    99/12/31
    *MDY
    Month/day/year
    mm/dd/yy
    12/31/99
    *DMY
    Day/month/year
    Dd/mm/yy
    31/12/99
    *JUL
    Julian
    Yy/ddd
    99/365

    TIMFMT

    Description

    Representation

    Example

    *ISO
    International Standard Org
    hh.mm.ss
    23.59.59
    *USA
    IBM USA standard
    hh.mm.xM
    11.59 PM
    *EUR
    IBM European standard
    hh.mm.ss
    23.59.59
    *JIS
    Japanese Industrial Standard
    hh.mm.ss
    23.59.59
    *HMS
    Hours/minutes/seconds
    hh.mm.ss
    23.59.59

    You can change default display format of date and time fields for a program as a whole by specifying the DATFMT and/or TIMFMT within the Control Specification. The separator is optional. If you specify an ampersand (&) as the separator, a blank is used as the separator character.

    Related OPCODES:
    • ADDDUR
    • SUBDUR
    • EXTRACT

              New and enhanced Opcodes
    The frequency used Opcodes, which are supported only in RPGLE, are as follows:

    • EVAL (Evaluate expression)
    The EVAL operation code evaluates an assignment statement of the form result expression. The expression is evaluated and the result placed in result. Therefore, result cannot be a literal or constant but must be a field name, array name, array element, data structure data structure subfield, or a string using the %SUBST built-in function.


    Columns . . . :    6  76            Edit                          PB01U01S/MYRPGLE
     SEU==>                                                                    LE12
     FMT D  DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++
            *************** Beginning of data *************************************
    0001.00 Dstr1             s             20a                                    
    0001.01 Dstr2             s             20a                                    
    0003.00 C                   eval      str1='Dukestar Technologies'             
    0004.00 c                   EVALR     str2='Dukestar Technologies'             
    0006.00 C     str1          DSPLY                                              
    0006.01 C     str2          DSPLY                                             
    0007.00 C                   eval      *INLR = *on                                
            ****************** End of data ****************************************
                                                                                   
                                                                                                                       
     F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
     F16=Repeat find       F17=Repeat change          F24=More keys                
                                            
                                                                     (C) COPYRIGHT IBM CORP. 1981, 2002.   


    Output of above function EVAL and EVALR is:


                                                                Display Program Messages                            
                                                                                    
     Job 090555/PB01U01SAL/QPADEV0009 started on 04/07/05 at 10:19:10 in subsystem Q  
     DSPLY  Dukestar Technologie                                                   
     DSPLY  ukestar Technologies                                                    

                                                                                                                                                            
                                                                                    
     Press Enter to continue.                                                      
                                                                                   
                                                                    
     F3=Exit   F12=Cancel                                                          
                                                                                    

    Output of EVAL is Dukestar Technologie where s is ignored and EVALR is ukestar Technologies where D is ignored.

    EXTRCT (Extract Date/Time/Timestamp)
    The EXTRCT operation code will return one of:
    o      The year, month or day part of a date or timestamp field.

    o      The hours, minutes or seconds part of a time or timestamp field

    o      The microseconds part of the timestamp field.

    The Date Time or Timestamp from which the information is required is specified in factor 2, followed by the duration code. The entry specified in factor2 can be a field, Factor 1 must be blank.

    The result field can be any numeric or character field, subfield, array/table element. The result field is cleared before the extracted data is assigned. For a character result field, the data is put left adjusted into the result field.


    Columns . . . :    6  76            Edit                          PB01U01S/MYRPGLE
     SEU==>                                                                   BIF51
     FMT D  DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++
            *************** Beginning of data *************************************
    0001.00 DLDT              S               D                                    
    0003.00  *                                                                      
    0004.00 C     *USA          MOVE      *DATE         LDT                        
    0005.00  *extract month from above date                                        
    0006.00 C                   EXTRCT    LDT:*M        LMNTH             2 0      
    0006.01 c     LMNTH         dsply                                              
    0006.02  *extract date from above date                                          
    0007.00 C                   EXTRCT    LDT:*D        LDY               2 0      
    0007.01 c     LDY           dsply                                              
    0007.02  *extract year from above date                                          
    0007.03 C                   EXTRCT    LDT:*Y        LYR               4 0      
    0007.05 c     LYR           dsply                                              
    0008.00 C                   EVAL      *INLR = '1'                              
            ****************** End of data ****************************************
                                                                                   
                                                                                                                                                                  
     F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
     F16=Repeat find       F17=Repeat change          F24=More keys                
                                             (C) COPYRIGHT IBM CORP. 1981, 2002.   

    ·   ADDDUR (ADD Duration)
    The ADDDUR operation adds the duration specified in factor 2 to a date or time and places the resulting Date. Time or Timestamp in the result field.

    Factor 1 is optional and may contain a Date, Time or Timestamp field, subfield, array ,array element, literal or constant. If factor1 contains a field name, array or array element then its data type must be the same data type as the field specified in the result field. If factor 1 is not specified the duration is added to the field specified in the result field.

    Factor 2 is required and contains two subfactors. The first is duration and may be a numeric field, array element or constant with zero decimal positions. If the duration is negative then it is subtracted from the date. The second sub factor must be a valid duration code indicating the type of duration. The duration code must be consistent with the result field data type. You can add a year, month or day duration but not a minute duration to a data field.
    The result field must be a date, time or timestamp data type field, array or array element if the result field is s time field, the result will always be a valid Time. For example adding 59 minutes to 23:59:59 would give 24:58:59. Since this time is not valid, the compiler adjusts it to 00:58:59. If factor 1 is blank, the duration is added to the value in the result field.



    Columns . . . :    6  76            Edit                          PB01U01S/MYRPGLE
     SEU==>                                                                    BIF9
     FMT H  HKeywords++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            *************** Beginning of data *************************************
    0001.00 DLDT              S               D                                    
    0003.00  *                                                                      
    0004.00 C     *USA          MOVE      *DATE         LDT                        
    0005.00  *                                                                     
    0005.01 c     ldt           dsply                                               
    0005.02 c                   adddur    3:*m          ldt                        
    0006.01 c     ldt           dsply                                              
    0006.02 c                   adddur    3:*d          ldt                         
    0006.03 c     ldt           dsply                                              
    0006.04 c                   adddur    3:*y          ldt                        
    0006.05 c     ldt           dsply                                               
    0008.00 C                   EVAL      *INLR = '1'                              
            ****************** End of data ****************************************
                                                                                   
     F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
     F16=Repeat find       F17=Repeat change          F24=More keys                
                                             (C) COPYRIGHT IBM CORP. 1981, 2002.   

    The output of above program is,



                               Display Program Messages                            
                                                                                   
     Job 090555/PB01U01SAL/QPADEV0009 started on 04/07/05 at 10:19:10 in subsystem Q  
     DSPLY  07.04.2005                                                             
     DSPLY  07.07.2005                                                             
     DSPLY  10.07.2005                                                             
     DSPLY  10.07.2008                                      
                                                                                   
     Press Enter to continue.                                                      
                                                                                                                                                                                                 
     F3=Exit   F12=Cancel                                                          


    ·   SUBDUR (Subtract Duration)
    The SUBDUR operation has been provided to:
    o      Subtract a duration to establish a new Date, Time or Timestamp
    o      Calculate a duration.

    The SUBDUR operation can also be used to calculate duration between:
    o      Two dates
    o      A date and a timestamp
    o      Two times
    o      A time and a timestamp
    o      Two timestamps

    Factor 1 is required and must contain a Date, Time or Timestamp field, subfield, array, array element, constant or literal.
    Factor 2 is required and must also contain a Date, Time or Timestamp field, array ,array element, literal or constant. The duration code must be consistent with one of the following:
    o      Factor 1 and factor 2
    o      Years (*Y), Months (*M) and Days (D) if factor 1 and/or factor2 is a Date
    o      Timestamp, *Hours (*H),*Minutes(*MN) and *Seconds(*S) when factor1 and/or factor 2 is a Time or Timestamp.

    The result of the calculation is a complete units; any rounding, which is done, is downwards. The calculation of duration includes microseconds.

    For example, if the actual duration is 384 days, and the result is requested in years, the result will be 1 complete year because there are 1.05 years in 384 days. A duration of 59 minutes requested in hours will result in 0 hours.


    Columns . . . :    6  76            Edit                          PB01U01S/MYRPGLE
     SEU==>                                                                    BIF9
     FMT H  HKeywords++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            *************** Beginning of data *************************************
    0001.00 DLDT              S               D                                     
    0003.00  *                                                                     
    0004.00 C     *USA          MOVE      *DATE         LDT                        
    0005.00  *                                                                      
    0005.01 c     ldt           dsply                                              
    0005.02 c                   subdur    3:*m          ldt                        
    0006.01 c     ldt           dsply                                               
    0006.02 c                   subdur    3:*d          ldt                        
    0006.03 c     ldt           dsply                                              
    0006.04 c                   subdur    3:*y          ldt                        
    0006.05 c     ldt           dsply                                              
    0008.00 C                   EVAL      *INLR = '1'                              
            ****************** End of data ****************************************
                                                                                    
     F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
     F16=Repeat find       F17=Repeat change          F24=More keys                
                                             (C) COPYRIGHT IBM CORP. 1981, 2002.   

    The output of above program is,

                               Display Program Messages                            
                                                                                   
     Job 090555/PB01U01SAL/QPADEV0009 started on 04/07/05 at 10:19:10 in subsystem Q  
     DSPLY  07.04.2005                                                             
     DSPLY  07.01.2005                                                             
     DSPLY  04.01.2005                                                             
     DSPLY  04.01.2002  
                                         
                                                                             
     Press Enter to continue.                                                      
                                                                                                                                                
     F3=Exit   F12=Cancel                                                           
                                                                                   
    • List of Frequently used extended Opcodes
    Sr.no.
    RPGIII
    RPGIV
    1
    REDPE
    READPE
    2
    LOKUP
    LOOKUP
    3
    UPDAT
    UPDATE
    4
    DELET
    DELETE
    5
    UNLCK
    UNLOCK
    6
    SELEC
    SELECT
    7
    WHXX
    WHENXX
    8
    CASXX
    CASEXX
    9
    DEFN
    DEFINE
    10
    RETRN
    RETURN
    11
    CHEKR
    CHECKR
    12
    EXCPT
    EXCEPT
    13
    SETOF
    SETOFF
    14
    OCCUR
    OCCUR


    Built- In Functions:

    RPG IV supports many built-in functions to return file-operation results, simplify complex calculations, perform string operations, and perform data-type conversions. BIF always begin with a % sign. They are coded within free-form expressions. To pass value to a built in function, enclose the values within parentheses immediately following the name of the BIF, separate multiple values with colon (;) separators.


    %ABS (Absolute Value of Expression)
    %ABS (numeric expression)

    %ABS returns the absolute value of the numeric expression specified as the parameter. If the value of the numeric expression is non- negative, the value is returned unchanged. If the value is negative, the value returned is the value of the expression but with the negative sign removed.
    %ABS may be used either in expressions or as parameters to keywords. When used with keywords, the operand must be a numeric literal, a constant name representing a numeric value, or a built-in function with a numeric value known at compile –time.

     Columns . . . :    6  76            Edit                        PB01U01S/MYRPGLE
     SEU==>                                                                      I1
            *************** Beginning of data *************************************
    0001.00 Df8               S              8f   inz(-1)                          
    0002.00 Di10              S             10i 0 inz(-123)                        
    0003.00 Dp7               S              7p 3 inz(-1234.567)                   
    0004.00 C                   eval      f8=%abs(f8)                              
    0004.01  * The value of "f8" is now 1.000000000000+E000                        
    0005.00 C                   eval      i10=%abs(i10-321)                        
    0005.01  * The value of "i10" is now 444.                                      
    0006.00 C                   eval      p7=%abs(p7)                               
    0006.01  * The value of "p7" is now 1234.567.                                  
    0007.00 C                   eval      *inlr=*on                                
            ****************** End of data ****************************************
                                                                                            
                                                                                                                        
                                             (C) COPYRIGHT IBM CORP. 1981, 2002.                                                                            
                                                                                   
    %DEC (Convert to Packed Decimal Format)
    % Dec (numeric expression {:precision: decimal places})

    %DEC converts the value of the numeric expression to decimal (packed) format with precision digits and decimal p[laces decimal positions.

    % DecH
    %DECH (numeric expression: precision: decimal places)

    %DECH is same as the %Dec built-in function, except half-adjust is applied to the value of numeric expression when converting to the desired precision. No message is issued if half adjust cannot be performed.


    Columns . . . :    6  76            Edit                        PB01U01S/MYRPGLE
     SEU==>                                                                      I2
            *************** Beginning of data *************************************
    0001.00 Dp7               S              7p 3 inz(1234.567)                     
    0002.00 Ds9               S              9s 5 inz(73.73442)                    
    0003.00 Df8               S              8f   inz(123.456789)                  
    0003.01 Dres1             S             15p 5                                   
    0003.02 Dres2             S             15p 5                                  
    0003.03 Dres3             S             15p 5                                  
    0004.00 C                   eval      res1=%dec(p7)+0.011                      
    0004.01  * The value of "res1" is now 1234.57800                               
    0005.00 C                   eval      res2=%dec(s9:5:0)                        
    0005.01  * The value of "res2" is now 73.00000                                 
    0006.00 C                   eval      res3=%dech(f8:5:2)                       
    0006.01  * The value of "res3" is now 73.00000                                 
    0007.00 C                   eval      *inlr=*on                                
            ****************** End of data ****************************************
                                                                                   
                                                                                              
                                             (C) COPYRIGHT IBM CORP. 1981, 2002.                                                                                   
                                                          
    %DECPOS (Get Number of decimal Positions)
    %DecPost(numeric expression)

    %DECPOS returns the number of decimal positions in the numeric expression.
                            
    Columns . . . :    6  76            Edit                        PB01U01S/MYRPGLE
     SEU==>                                                                      I3
            *************** Beginning of data *************************************
    0001.00 DP7               S              7P 3 INZ(8236.567)                    
    0002.00 DS9               S              9P 5 INZ(23.73442)                    
    0003.00 DRES1             S              5I 0                                  
    0004.00 DRES2             S              5I 0                                  
    0005.00 DRES3             S              5I 0                                  
    0006.00 C                   EVAL      RES1=%DECPOS(P7)                         
    0006.01  * The value of "RES1" is now 3.                                       
    0007.00 C                   EVAL      RES2=%DECPOS(S9)                          
    0007.01  * The value of "RES2" is now 5.                                       
    0008.00 C                   EVAL      RES3=%DECPOS(P7*S9)                      
    0008.01  * The value of "RES2" is now 8.                                        
    0009.00 C                   EVAL      *INLR=*ON                                
            ****************** End of data ****************************************
                                                                                   
                                                                                                                                                        
                                             (C) COPYRIGHT IBM CORP. 1981, 2002.                                                                                   
                                                                                   

    %EDITC (Edit Value Using an Editcode)
    %EDITC (numeric: edit code)

    %EDITC Returns a character result representing the numeric value edited according to the edit code.

    %EDITC Example:


    Columns . . . :    6  76            Edit                        PB01U01S/MYRPGLE
     SEU==>                                                                      I4
            *************** Beginning of data *************************************
    0001.00 Dmsg              S            100A                                    
    0002.00 Dsalary           S              9P 2 inz(1000)                        
    0002.01  *                                                                     
    0002.02  * If the value of salary is 1000, then the value of salary * 12       
    0002.03  * is 12000.00. The edited version of salary * 12 using the A edit     
    0002.04  * code with floating currency is '$12,000.00'.                        
    0002.05  * The value of msg is 'The annual salary is $12,000.00'               
    0002.06  *                                                                      
    0003.00 C                   eval      msg='The annual salary is'               
    0004.00 C                             +%trim(%editc(salary * 12                
    0005.00 C                             :'A':*CURSYM))                           
    0005.01  *                                                                     
    0005.02  * In the next example, the value of msg is 'The anuual salary is      
    0005.03  * &12,000.00'                                                         
    0005.04  *                                                                      
    0006.00 C                   eval      msg='The annual salary is'               
    0007.00 C                             +%trim(%editc(salary * 12                
    0008.00 C                             :'A':'&'))                               
    0008.01  *                                                                     
    0008.02  * In the next example, the value of msg is 'Salary is                                 
    0008.03  * $*****12,000.00'                                                    
    0008.04  *                                                                     
    0009.00 C                   eval      msg='Salary is $'                        
    0010.00 C                             +%trim(%editc(salary * 12                
    0011.00 C                             :'B': *ASTFILL))                         
    0011.01  *                                                                     
    0011.02  * In the next example, the value of msg is 'The date is               
    0011.03  * 1/14/1999'                                                          
    0012.00 C                   eval      msg='The date is'                        
    0013.00 C                             +%trim(%editc(*date:'Y'))                
    0014.00 C                   eval      *inlr=*on                                
            ****************** End of data *************************************


                                             (C) COPYRIGHT IBM CORP. 1981, 2002.                                                                                   
                                                                                   
    %EDITW (Edit Value Using an Edit Word)
    %EDITW (numeric: editword)
    %EDITW Returns a character result representing the numeric value edited according to the edit word.



     Columns . . . :    6  76            Edit                        PB01U01S/MYRPGLE
     SEU==>                                                                      I5
            *************** Beginning of data *************************************
    0001.00 Damount           S             50A                                    
    0002.00 Dsalary           S              9P 2 inz(2451.53)                     
    0003.00 Deditwd           C                   '$ ,     ,   *Dollars&  &Cents'  
    0003.01  *                                                                     
    0003.02  * If the value of salary is 2451.53, then the edited version of       
    0003.03  * (Salary * 12) is '$***29,418*Dollars 36 Cents'. The value of        
    0003.04  * amount is 'The annual salary is $***29,418*Dollars 36 Cents'        
    0003.05  *                                                                     
    0004.00 C                   eval      amount='The annual salary is'            
    0005.00 C                             +%editw(salary * 12:editwd)              
    0005.01 C     amount        dsply                                              
    0006.00 C                   eval      *inlr=*on                                 
    0007.00  * (In the constant 'edited', ('b' stands for blank spaces))           
            ****************** End of data ****************************************
                                                                                    
                                                                                                                                 
                                             (C) COPYRIGHT IBM CORP. 1981, 2002.                                                                          

    %ELEM( Get Number of Elements)
    %ELEM(table_name)
    %ELEM(array_name)

    %ELEM returns the number of elements in the specified array or table.

    %ELEM Example:
      Columns . . . :    6  76            Edit                        PB01U01S/MYRPGLE
     SEU==>                                                                      I6
            *************** Beginning of data *************************************
    0001.00 Darrld            S             20    DIM(10)                          
    0002.00 Dtable            S             10    DIM(20)ctdata                    
    0003.00 Dnum              S              5P 0                                  
    0003.01  *                                                                      
    0003.02  * like_array will be defined with a dimension of 10.                  
    0003.03  * array_dims will be defined with a value of 10.                      
    0003.04  *                                                                      
    0004.00 Dlike_array       S                   like(arrld)dim(%elem(arrld))     
    0005.00 Darray_dims       C                   const(%elem(arrld))              
    0005.01  *                                                                     
    0005.02  * In the following examples num will be equal to 10, 20, and 30.      
    0005.03  *                                                                     
    0006.00 C                   eval      num=%elem(arrld)                         
    0007.00 C                   eval      num=%elem(table)                         
    0008.00 C                   eval      *inlr=*on                                
            ****************** End of data ****************************************
                                                                                    
                                                                                                                                                          
                                             (C) COPYRIGHT IBM CORP. 1981, 2002.                                                                                   
                                                                                    
                                                                                    
    %FLOAT (Convert to Floating Format)
    %FLOAT (numeric expression)
    %FLOAT converts the value of the numeric expression to float format. This built- in function may only be used in expressions.

    Columns . . . :    6  76            Edit                        PB01U01S/MYRPGLE
     SEU==>                                                                      I7
            *************** Beginning of data *************************************
    0001.00 Dp1               s             15p 0 inz(1)                           
    0002.00 Dp2               s             25p13 inz(3)                           
    0003.00 Dres1             s             15p 5                                   
    0004.00 Dres2             s             15p 5                                  
    0005.00 Dres3             s             15p 5                                  
    0006.00 C                   eval      res1=p1/p2                                
    0006.01  * The value of 'res1' will be 0.33300                                 
    0007.00 C                   eval      res2=%float(p1)/p2                       
    0007.01  * The value of 'res2' will be 0.33333                                 
    0008.00 C                   eval      res3=%float(p1/p2)                       
    0008.01  * The value of 'res3' will be 0.33333                                 
    0009.00 C                   eval      *inlr=*on                                
            ****************** End of data ****************************************
                                                                                   
                                                                                                                                                
                                             (C) COPYRIGHT IBM CORP. 1981, 2002.                                                                                    
                                                                                   
                                                                                                                                                          
     %INT (convert to integer)
    %INT (numeric expression)
    %INT converts the value of the numeric expression to integer. Any decimal digits are truncated. This built – in function may only be used in expressions. %INT can be used to truncate the decimal positions from a float or decimal value allowing it to be used as an array index.

    %INTH
    %INTH (numeric expression)
    %INTH IS same as %Int, except half-adjust is applied to the value of the numeric expression when converting to integer type.



    Columns . . . :    6  76            Edit                        PB01U01S/MYRPGLE
     SEU==>                                                                      I8
            *************** Beginning of data *************************************
    0001.00 Dp6               s              5p 0                                  
    0002.00 Dp7               s              7p 3 inz(1234.567)                    
    0003.00 Ds9               s              9s 5 inz(73.73442)                    
    0004.00 Df8               s              8f   inz(123.789)                     
    0005.00 Dres1             s             15p 5                                  
    0006.00 Dres2             s             15p 5                                  
    0007.00 Dres3             s             15p 5                                  
    0008.00 Darray            s              1a   dim(200)                         
    0009.00 Da                s              1a                                    
    0010.00 C                   eval      p6=%int(p7)                              
    0011.00  * The value of "p6" is now 1234.                                      
    0012.00 C                   eval      res1=%int(p7)+0.011                      
    0012.01  * The value of "res1" is now 1234.01100                               
    0014.00 c                   eval      res2=%int(s9)                            
    0014.01  * The value of "res2" is now 73.00000.                                 
    0016.00 C                   eval      res3=%int(f8)                            
    0016.01  * The value of "res3" is now 124.00000.                               
    0018.00 C                   eval      a=array(%inth(f8))                        
    0018.01  * %INT and %INTH can be used as array indexes.                        
    0019.00 C                   eval      *inlr=*on      
            ****************** End of data ****************************************                                                     
                                                                        
                                                                                                                                        
                                                                              (C) COPYRIGHT IBM CORP. 1981, 2002.                           
                                                                                  
    %LEN (Get Length)
    %LEN(expression)

    Columns . . . :    6  76            Edit                                                              PB01U01S/MYRPGLE
     SEU==>                                                                      I9                                                                               
            *************** Beginning of data *************************************
    0001.00 Dnum1             s              7p 2                                  
    0002.00 Dnum2             s              5s 1                                  
    0003.00 Dnum3             s              5i 0 inz(2)                            
    0004.00 Dchr1             s             10a   inz('Toronto ')                  
    0005.00 Dchr2             s             10a   inz('Munich ')                   
    0006.00 Dptr              s               *                                     
    0006.01  * Numeric expressions :                                               
    0007.00 C                   eval      num1=%len(num1)                          
    0009.00 C                   eval      num1=%decpos(num2)                       
    0011.00 C                   eval      num1=%len(num1*num2)                     
    0013.00 C                   eval      num1=%decpos(num1*num2)                  
    0013.01  * Character expressions :                                             
    0015.00 C                   eval      num1=%len(chr1)                          
    0017.00 C                   eval      num1=%len(chr1+chr2)                     
    0019.00 C                   eval      num1=%len(%trim(chr1))                   
    0021.00 C                   eval      num1=%len(%subst(chr1:1:num3)            
    0022.00 C                             +''+%trim(chr2))                         
    0024.00 C                   eval      *inlr=*on                                
    0025.00  * %len and %decpos can be useful with other built-in functions :      
    0026.00  * defloating point data types                                         
                                             (C) COPYRIGHT IBM CORP. 1981, 2002.   

    %LEN Can be used to get the length of a variable expression or to set the current length of a variable-length field.

    %SCAN (Scan for Characters)
    % SCAN (search argument : source string {:start})

    Columns . . . :    6  76        Edit                          PB01U01S/MYRPGLE
     SEU==>                                                                   I10
            *************** Beginning of data *************************************
    0001.00 Dsource           s            15a   inz('Dr. Doolittle')             
    0002.00 Dpos                s              5u 0                                   
    0003.00 C                   eval      pos=%scan('oo':source)                   
    0004.00 C     pos           dsply                                              
    0004.01  * After the EVAL, pos = 6 because 'oo' begins at position 6 in        
    0004.02  * 'Dr. Doolittle'                                                     
    0005.00 C                   eval      pos=%scan('D':source:2)                  
    0006.00 C     pos           dsply                                               
    0006.01  * After the EVAL, pos = 5 because the first 'D' found starting from   
    0006.02  * position 2 is in position 5.                                        
    0007.00 C                   eval      pos=%scan('abc':source)                  
    0008.00 C     pos           dsply                                              
    0008.01  * After the EVAL, pos = 0 because 'abc' is not found in               
    0008.02  * 'Dr. Doolittle'                                                     
    0009.00 C                   eval      pos=%scan('Dr':source:2)                 
    0010.00 C     pos           dsply                                              
    0010.01  * After the EVAL, pos = 0 because 'Dr' is not found in                
    0010.02  * 'Dr. Doolittle', if the search starts at position 2.                
    0011.00 C                   eval      *inlr=*on                                
            ****************** End of data *******************************
                                        
                                         
                                                   (C) COPYRIGHT IBM CORP. 1981, 2002                                           

    %Scan returns the first position of the search argument in the source string, or 0 if it was not found. If the start position is specified, the search begins at the starting position.

    %SIZE (Get Size in Bytes)
    %SIZE (variable)
    %SIZE (literal)
    %SIZE (array)
    %SIZE (table)

    % SIZE Returns the number of bytes occupied by the constant or field. The agreement may be a literal, a named constant, a data structure subfield, a field an array or a table name. It cannot, however, contain an expression.

    Columns . . . :    6  76            Edit                         PB01U01S/MYRPGLE
     SEU==>                                                                     I11
            *************** Beginning of data *************************************
    0001.00 Darr1             s             10    dim(4)                           
    0002.00 Dtable1           s              5    dim(20)                          
    0003.00 Dfield1           s             10                                      
    0004.00 Dfield2           s              9b 0                                  
    0005.00 Dfield3           s              5p 2                                  
    0006.00 Dnum              s              5p 0                                   
    0007.00 Dcity             s             40a   inz('North York')                
    0007.01  *                                                                     
    0007.02  *                  calculation                                        
    0008.00 C                   eval      num=%size(field1)                        
    0010.00 C                   eval      num=%size('HH')                          
    0012.00 C                   eval      num=%size(123.4)                         
    0014.00 C                   eval      num=%size(-03.00)                        
    0016.00 C                   eval      num=%size(ARR1)                          
    0018.00 C                   eval      num=%size(ARR1:*ALL)                     
    0020.00 C                   eval      num=%size(TABLE1)                        
    0022.00 C                   eval      num=%size(TABLE1:*ALL)                   
    0024.00 C                   eval      num=%size(field2)                        
    0026.00 C                   eval      num=%size(field3)                        
    0028.00 C                   eval      num=%size(CITY)
    0030.00 c                   eval      *inlr=*on                                
            ****************** End of data ****************************************
                                                                                   
                                                                                                                                                                       
                                             (C) COPYRIGHT IBM CORP. 1981, 2002.                                                

      
    %SUBST (get Substring)
    %SUBST(string start{:length})

    %SUBST returns a portion of argument string. The start parameter represents the starting position of the sub string. The length parameter represents the length of substring. If it is not specified, the length of the string parameter less starts value plus one.

    Columns . . . :    6  76            Edit                         PB01U01S/MYRPGLE
     SEU==>                                                                     I12
            *************** Beginning of data *************************************
    0001.00 DMSG              S             50A                                    
    0001.01  *                                                                     
    0002.00 C                   EVAL      MSG = 'THE VALUE OF %SUBST IS : '        
    0003.00 C                             + %SUBST('HELLO WORLD':5+2)              
    0004.00 C     MSG           DSPLY                                              
    0004.01  *                                                                     
    0004.02 C                   EVAL      MSG = 'THE VALUE OF %SUBST IS : '        
    0004.03 C                             + %SUBST('HELLO WORLD':5+2:10-7)         
    0004.04 C     MSG           DSPLY                                              
    0004.05  *                                                                      
    0004.06 C                   EVAL      MSG = 'THE VALUE OF %SUBST IS : '        
    0004.07 C                             + %SUBST('ABCD'+'EFGH':5:3)              
    0004.08 C     MSG           DSPLY                                               
    0004.09  *                                                                     
    0005.00 C                   EVAL      *INLR=*ON                                
            ****************** End of data ****************************************
                                                                                   
                                                                                                    
                                             (C) COPYRIGHT IBM CORP. 1981, 2002.   


    %TRIM (trim Blanks at Edges)
    %TRIM (string)

    %TRIM Returns a string without leading and trailing spaces.

    %TRIML (trim Leading Blanks)
    %TRIML (string)

    %TRIML returns a string without leading spaces.

    %TRIMR (Trim Trailing Blanks)
    % TRIMR (string)

    %TRIMR returns a string without trailing spaces.

    Columns . . . :    6  76            Edit                         PB01U01S/MYRPGLE
     SEU==>                                                                     I13
            *************** Beginning of data *************************************

    0001.00 DLOCATION         S             16A                                     
    0001.01 DNAME             S             20A                                    
    0002.00  *                                                                     
    0003.00  * LOCATION WILL HAVE THE VALUE 'TORONTO' ONTARIO'.                     
    0004.00  *                                                                     
    0005.00 C                   EVAL      LOCATION = %TRIM('  TORONTO, ONTARIO  ') 
    0006.00  *                                                                     
    0007.00  * NAME WILL HAVE THE VALUE 'CHRIS SMITH'.                             
    0008.00  *                                                                     
    0009.00 C                   MOVE(P)   'CHRIS'       FIRSTNAME        10        
    0010.00 C                   MOVE(P)   'SMITH'       LASTNAME         10        
    0011.00 C                   EVAL      NAME =%TRIM(FIRSTNAME)+' '+%TRIM(LASTNAME
    0011.01  *                                                                     
    0011.02  * LOCATION WILL HAVE THE VALUE 'TORONTO' ONTARIO'.                    
    0011.03  *                                                                     
    0011.04 C                   EVAL      LOCATION = %TRIML('    TORONTO, ONTARIO  
    0011.05  *                                                                      
    0011.06  * LOCATION WILL HAVE THE VALUE 'TORONTO' ONTARIO'.                    
    0011.07  *                                                                     
    0011.08 C                   EVAL      LOCATION = %TRIMR('  TORONTO, ONTARIO  ')
    0013.00 C                   EVAL      *INLR=*ON                                
            ****************** End of data ****************************************
                                                                                    
                                                                                                                                    
                                         (C) COPYRIGHT IBM CORP. 1981, 2002.   


    Converting RPG III programs to RPG IV programs
    The process is carried out through the use of RPG/400 source member of a specified source physical file to the ILE RPG/400 format. CVTRPGSRC converts each source member on a line-by- line basis. The conversion tool presumes that the RPG source code is free of any compile error. Before you run the CVTRPGSRC command, there are few things you should understand and that you need to do:

    ·         The CVTRPGSRC command operates on the source physical file member.

    ·         Create a source file to receive the ILE RPG source members. The name IBM uses for ILE RPG source members is QRPGLESRC. The record length of the QRPGLESRC source file should be 112 bytes long. The basic format of an RPG IV statement is:

    o    1-12: sequence number and date.

    o    13-92: the executable portion of the RPG IV source code.

    o    93-112: the comments section of RPG IV source.

    ·         Make sure the source files containing your RPG/400 source members contain only RPG member types and no non-RPG “un-typed” source member. As CVTRPGSRC attempts to convert source member with a blank member type, you could end up wasting time.

    o    FROMFILE: Specifies the name of the source file that contains the RPG III or RPG/400 source code to be converted and the library where the source file is stored. This is a required parameter; there is no default file name.

    o    FROMMBR: Specifies the name(s) of the member to be converted. This is a required parameter; there is no default name.

    o    TOFILE: Specifies the name of the source file that contains converted source member and the library where the converted source file is stored. The converted source file must exist and should have a should have a record length of 112 characters.

    o    TOMBR: Specifies the name(s) of the converted source member(s) in the converted source file. If the value specified on the FROMMBR. Parameter is *ALL or generic*, then TOMBR must be equal to *FROMMBR.

    o    CVTRPT: Specifies whether or not a conversation report is printed.

       §  *Yes: The conversion report is printed.
       §  *No: The conversion report is not printed.

    Summary
    The CVTRPGSRC tool is by no means the most exciting part of ILE RPG, but it is probably the first step that many will take when they enter the new world of ILE.






    No comments:

    Post a Comment