Note: See the AS/400 Web Pages Index at WebPages.htm.

                                  FastStart.htm Rev. 05

Re: How to create, compile, and run AS/400 RPG programs

I have read through 30+ IBM AS/400 reference and
programming manuals, plus several AS/400 reference
textbooks. And not one of these references explains,
in a few simple steps, how to compile and run an RPG
program! Every presentation, although thorough, is 
like "chasing a rabbit" - with chapters on AS/400 CL
commands, RPG syntax, creating files, creating members,
compiling members, running programs - scattered over
hundreds and hundreds of pages......

So, I have created what may be the one and only
simplified 19 step procedure in existence - to 
create and run a (fully procedural) RPG program
- that reads a sequential disk input file - and 
produces a simple output report.

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

Re: How to create (a) an RPG program, (b) a data file, 
    and run (a) the RPG program with (b) the data file
    as a sequential input file - in 19 easy steps:

Notes:

a. See IBM 5250 terminal simulator software info in section E.
b. See Keyboard Layout info in section F.
c. See Screen Colors info in section G.
d. See SEU commands info in section H.
e. See User Profile info in section I.
f. See MYOUTQ output queue info in section J.

A. Connect and Sign On

   1. On your PC, connect to your Internet ISP.

   2. Run an IBM 5250 terminal simulator program, to connect
      from your PC, via the Internet, to the AS/400.

      Run C:\MOCHAW32\MTN5250.EXE
      o Click on File, Connect.
      o Choose the AS/400 Host: Such as GCIBM2.GC.MARICOPA.EDU.
      o Optional: Click on Advanced, Use Port 23, Click on Ok.
      o Click on Ok.

   3. AS/400 Sign On screen.
      o Enter your Userid: ASxxx
      o Enter your Pwd:    xxxxxx
      o Press the Enter key.
      
B. Create an RPG IV LE source program ASxxx/QRPGSRC/RPG001, compile it, and run it.

   1. Create the source physical file ASxxx/QRPGSRC.
      CRTSRCPF FILE(ASxxx/QRPGSRC) TEXT('RPG source 1')

   2. Create the RPG IV LE source member ASxxx/QRPGSRC/RPG001.
      WRKMBRPDM ASxxx/QRPGSRC
      F6 = Create
      Source Member: RPG001
      Source Type:   RPGLE
      Source Desc:   RPG source program 001
      Press the Enter key
      [SEU Started]
      F3 = Exit (from SEU)
      Exit: Change/create member = Y (yes)

   3. Update the RPG IV LE source member ASxxx/QRPGSRC/RPG001.
      a. STRSEU ASxxx/QRPGSRC F4
         Source Member: RPG001
         [Enter 29 source program lines/statements - See below]
         F3 = Exit (from SEU)
         Exit: Change/create member = Y (yes)
         or
      b. STRSEU SRCFILE(ASxxx/QRPGSRC) SRCMBR(RPG001)
         [Enter 29 source program lines/statements - See below]
         F3 = Exit (from SEU)
         Exit: Change/create member = Y (yes)

         Source Program lines:
         Columns . . . :    6  76                       ASxxx/QRPGSRC 
         SEU==>                                                RPG001 
  FMT *   *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+
         *************** Beginning of data **************************
 0001.00 F* RPG001  BY R.P. GIVLE  REV. 04  01/23/2003
 0002.00 FEMPPF1    IF   F    8        DISK
 0003.00 FQPRINT    O    F  132        PRINTER OFLIND(*INOF)
 0004.00 DCOUNT1           S              4  0 INZ(0)
 0005.00 IEMPPF1    NS
 0006.00 I                                  1    3  NUM1
 0007.00 I                                  4    6  CHAR1
 0008.00 I                                  7    8  NUM2
 0009.00 C                   EXCEPT    HEADERA
 0010.00 C                   EVAL      COUNT1 = 0
 0011.00 C                   READ      EMPPF1
 0012.00 C                   DOW       NOT %EOF
 0013.00 C                   EVAL      COUNT1 = COUNT1 + 1
 0014.00 C                   EXCEPT    DETAILA
 0015.00 C                   READ      EMPPF1
 0016.00 C                   ENDDO
 0017.00 C                   EXCEPT    TOTALA
 0018.00 C                   EVAL      *INLR = *ON
 0019.00 C                   RETURN
 0020.00 OQPRINT    E            HEADERA        2  2
 0021.00 O                       UDATE         Y     60
 0022.00 O          E            DETAILA        2  2
 0023.00 O                                           15 'NUM/CHR/NUM'
 0024.00 O                       NUM1                20
 0025.00 O                       CHAR1               25
 0026.00 O                       NUM2                30
 0027.00 O          E            TOTALA         2
 0028.00 O                                           10 'TOTAL: '
 0029.00 O                       COUNT1              20
         ****************** End of data *****************************

         F3=Exit F5=Refresh F9=Retrieve F10=Cursor F11=Toggle F12=Cancel
         F16=Repeat find    F24=More keys

         Note: This simple RPG IV LE program does not use the DDS
               external file definition, created in steps C. 3./4.
               below, for the input file specs for file EMPPF1.

   4. Compile the RPG IV LE source member ASxxx/QRPGSRC/RPG001.
      WRKMBRPDM ASxxx/QRPGSRC
      [Scroll down to the entry for RPG001]
      14 (compile) [=CRTBNDPRG]
      F3 = Exit

      DSPMSG [To view system message for compilation completed]
             [Latest message is at top of the queue]

   5. View compiled output report for RPG IV LE source member ASxxx/QRPGSRC/RPG001.
      WRKOUTQ OUTQ(ASxxx/MYOUTQ)
             [To view output queue]
             [Latest entry RPG001 is at bottom of the queue]

             [5 = To display the compilation output report]
             [Use PageUp and PageDown to scroll vertically]
             [Control *BOT = scroll to bottom of report]
             [Control *TOP = scroll to top    of report]
             [Find Severe Error F16]
             [Find Message Totals: F16]
             [Find highest severity F16]
             F3 = Exit

   6. View the object file entry for RPG IV LE source member ASxxx/QRPGSRC/RPG001.

       If the compilation was successful, object file ASxxx/RPG001
       with Type *PGM was added to your library ASxxx.

       DSPLIB ASxxx [To view the new object file entry ASxxx/RPG001 *PGM]
                    [in your library ASxxx]

    **************************************************************
    * Note: Complete Steps C./D. Create a DDS source member and  *
    *       data file - Before performing steps 7. and 8. below. *
    **************************************************************

   7. Run object program ASxxx/RPG001 (input file ASxxx/EMPPF1; output file QPRINT).

      CALL ASxxx/RPG001

      DSPMSG [To view system message for execution completed]
             [Latest message is at top of the queue]

   8. View execution output report for object program ASxxx/RPG001.
      WRKOUTQ OUTQ(ASxxx/MYOUTQ)
             [To view output queue]
             [Latest entry QPRINT is at bottom of the queue]

             [5 = To display the execution output report]
             [Use PageUp and PageDown to scroll vertically]
             [Control *BOT = scroll to bottom of report]
             [Control *TOP = scroll to top    of report]
             F3 = Exit

      The ASxxx/RPG001 execution output report looks like this:

      File  . . . . . :   QPRINT                     Page/Line   1/2
      Control . . . . .                              Columns     1 - 78
      Find  . . . . . .

      *...+....1....+....2....+....3....+....4....+....5....+....6....+
                                                           1/23/03
          NUM/CHR/NUM  001  AaA   11
          NUM/CHR/NUM  002  BbB   22
          NUM/CHR/NUM  003  CcC   33
          NUM/CHR/NUM  004  DdD   44
          NUM/CHR/NUM  005  EeE   55
         TOTAL:       0005

C. Create/compile a DDS source member ASxxx/QDDSSRC/EMPPF1.

   1. Create the DDS source physical file ASxxx/QDDSSRC.
      CRTSRCPF FILE(ASxxx/QDDSSRC) TEXT('DDS source 1')

   2. Create the DDS source member ASxxx/QDDSSRC/EMPPF1.
      WRKMBRPDM ASxxx/QDDSSRC
      F6 = Create
      Source file:   QDDSSRC
       Library:      ASxxx
      Source member: EMPPF1
      Source Type:   PF
      Source Desc:   DDS Employee PF Source 1
      Press the Enter key
      [SEU Started]
      F3 = Exit (from SEU)
      Exit: Change/create member = Y (yes)

   3. Update the DDS source member ASxxx/QDDSSRC/EMPPF1.
      a. STRSEU ASxxx/QDDSSRC F4
         Source Member: EMPPF1
         [Enter the 4 DDS source member lines - See below]
         F3 = Exit (from SEU)
         Exit: Change/create member = Y (yes)
         or
      b. STRSEU SRCFILE(ASxxx/QDDSSRC) SRCMBR(EMPPF1)
         [Enter the 4 DDS source member lines - See below]
         F3 = Exit (from SEU)
         Exit: Change/create member = Y (yes)

         Source member lines:
         Columns . . . :    1  71                       ASxxx/QDDSSRC
         SEU==>                                                EMPPF1
         ... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+
 FMT PF..A..........T.Name++++++RLen++TDpB......Functions++++++++++++
         *************** Beginning of data **************************
 0001.00 A          R EMPPF1R
 0002.00 A            FLDNUM1        3S 0
 0003.00 A            FLDALPHA2      3
 0004.00 A            FLDNUM3        2S 0
         ****************** End of data *****************************

         F3=Exit F5=Refresh F9=Retrieve F10=Cursor F11=Toggle F12=Cancel
         F16=Repeat find    F24=More keys

   4. Compile the DDS source member ASxxx/QDDSSRC/EMPPF1.
      WRKMBRPDM ASxxx/QDDSSRC
      [Scroll down to the entry for EMPPF1]
      14 (compile)
      F3 = Exit

      DSPMSG [To view system message for compilation completed]
             [Latest message is at top of the queue]

   5. View compiled output report for DDS source member ASxxx/QDDSSRC/EMPPF1.
      WRKOUTQ OUTQ(ASxxx/MYOUTQ)
             [To view output queue]
             [Latest entry EMPPF1 is at bottom of the queue]

             [5 = To display the compilation output report]
             [Use PageUp and PageDown to scroll vertically]
             [Control *BOT = scroll to bottom of report]
             [Control *TOP = scroll to top    of report]
             [Find Severe Error F16]
             [Find Message Totals: F16]
             [Find highest severity F16]
             F3 = Exit

   6. View the object physical file entry for DDS source member ASxxx/QDDSSRC/EMPPF1.

       If the compilation was successful, object physical file ASxxx/EMPPF1
       with Type *FILE was added to your library ASxxx.

       DSPLIB ASxxx [To view the new object physical file entry ASxxx/EMPPF1 *FILE]
                    [in your library ASxxx]

D. Store data records in the object physical file ASxxx/EMPPF1.

   Here, each data record consists of eight characters:
   o 3 digits
   o 3 alpha characters
   o 2 digits

   1. Use DFU to enter 5 data records into object physical file ASxxx/EMPPF1.
      STRDFU
      5. Update data using temporary program.
         Data file   EMPPF1
          Library    ASxxx
         Member      *FIRST

      a. Enter: FLDNUM1:   001   (3 digits)
                FLDALPHA2: AaA   (3 chars) 
                FLDNUM3:   11    (2 digits)
                F9 = Insert

      b. Enter: FLDNUM1:   002   (3 digits)
                FLDALPHA2: BbB   (3 chars) 
                FLDNUM3:   22    (2 digits)
                F9 = Insert

      c. Enter: FLDNUM1:   003   (3 digits)
                FLDALPHA2: CcC   (3 chars) 
                FLDNUM3:   33    (2 digits)
                F9 = Insert

      d. Enter: FLDNUM1:   004   (3 digits)
                FLDALPHA2: DdD   (3 chars) 
                FLDNUM3:   44    (2 digits)
                F9 = Insert

      e. Enter: FLDNUM1:   005   (3 digits)
                FLDALPHA2: EeE   (3 chars) 
                FLDNUM3:   55    (2 digits)
                F9 = Insert
                F3 = Exit

      f. Exit:  Y (yes)

   2. Display the data records from object physical file ASxxx/EMPPF1.
      DSPPFM FILE(ASxxx/EMPPF1)

      Note: We are displaying the first member, EMPPF1,
            of the object physical file, ASxxx/EMPPF1.

      You should see these 5 data records, with 8 characters each:

      001AaA11
      002BbB22
      003CcC33
      004DdD44
      005EeE55

 Six Appendix sections will be added here, as follows:

 E. IBM 5250 terminal simulator software info.
 F. Keyboard Layout info.
 G. Screen Colors info.
 H. SEU commands info.
 I. User Profile info.
 J. MYOUTQ output queue info.

 Note: Will you please send corrections, and suggestions for the
       improvement of this initial AS/400 documentation, to me at
       patmoss@patmoss.com. Thank You!