1. Get TK4- MVS Sofware
  2. Get wc3270 Terminal Emulator
  3. Install wc3270 Terminal Emulator
  4. Install and Run MVS 3.8j
  5. Logging In to/Out of MVS 3.8j
  6. Shutting down MVS 3.8j from TSO
  7. Using TSO RFE Application
  8. Adding a User
  9. Creating Datasets
  10. JCL Overview
  11. Your First Cobol Program
  12. Your First Assembler Program
  13. Your First Fortran Program
  14. Your First PL/I Program

Your First PL/I Program

PL/I pronounced P L one, is a language developed by IBM in the mid 1960s. It was designed to be a mathmetical, scientifice, business, and systems programming language. It is still in use today and vendors other than IBM have compilers for it. If you plan on programming with it create a partitioned dataset named learn.pl1.src and create source membere named firstpgm. Let's look at a simple program.


          AVRG: PROC OPTIONS(MAIN);
            DECLARE LOANNAME CHAR(20);
            GET LIST(A,B,C,D,E,LOANNAME);
            SUM = A + B + C + D + E;
            MEAN = SUM /5;
            PUT LIST((10)' ' !! 'NAME IS: ' !! LOANNAME);
            PUT SKIP LIST('AVERAGE IS', MEAN);
            RETURN;
          END AVRG;
        
This statement reads from a file a list of variables. In this case it is reading five variable a, b, c, d, and e followed by reading a string variable. The GET statement has the ability to specify a dataset but this one doesn't which means by default is is reading from the dataset SYSIN.
Line #Description
1In PL/I programs are written as procedures. The name of this procedure is 'AVRG' and its options indicate that this is the MAIN procedure.
2Variables are defined with the DECLARE keyword. This line defines a variable named LOANNAME that is alphanumeric and is 20 characters long.
3
4This statement adds the five variable a, b, c, d, and e together and puts the result into a variable named sum.
5This statement creates a variable 'mean' by dividing 'sum' by 5 (the number of variables added together.
6This statement does a PUT to a dataset. If a dataset is not named it is written to SYSPRINT. The parameters for this put is 10 spaces concatenated with a string (quoted) concatenated with the variable 'LOANNAME'.
7This statement does a PUT to the SYSPRINT dataset. It uses the keyword SKIP to indicate to advance one line then the parameters put out the word 'AVERAGE:', then it puts out the variable mean. Notice that is is not concatenated but there is a comma separating the two fields. This causes a number of spaces to be put between the two fields.
8This statement says RETURN. It causes the program to terminate and return to the calling program.
9This statement tells the compiler that this is the end of the procedure AVRG.

Note that every line is ended with a semi-colon (;).

Embedded Source
JCL Job Stream with embedded source

            //RLAWPL1 JOB  (PL1TEST),CLASS=A,MSGCLASS=H,MSGLEVEL=(1,1)
            //PL1TEST EXEC PL1LFCLG
            //PL1L.SYSLIN DD UNIT=SYSDA
            //PL1L.SYSIN  DD *
             AVRG: PROC OPTIONS(MAIN);
                DECLARE LOANNAME CHAR(20);
                GET LIST(A,B,C,D,E,LOANNAME);
                SUM = A + B + C + D + E;
                MEAN = SUM /5;
                PUT LIST((10)' ' !! 'NAME IS: ' !! LOANNAME);
                PUT SKIP LIST('AVERAGE IS', MEAN);
                RETURN;
             END AVRG;
            /*
            //LKED.SYSLIB DD DSN=SYS1.PL1LIB,DISP=SHR
            //GO.STEPLIB  DD DSN=SYS1.PL1LIB,DISP=SHR
            //GO.SYSIN    DD *
            45 20 60 30 70 'MY HOME LOAN'
            /*
            //
            

Notice the line GO.FT06F001, the 6 indicates that this is the DD line for device 6 in the program.

External Source
JCL Job Stream with external source

            //RLAWPL1 JOB  (PL1TEST),CLASS=A,MSGCLASS=H,MSGLEVEL=(1,1)
            //PL1TEST EXEC PL1LFCLG
            //PL1L.SYSLIN DD UNIT=SYSDA
            //PL1L.SYSIN  DD DSN=LEARN.PL1.SRC(FIRSTPGM)
            //LKED.SYSLIB DD DSN=SYS1.PL1LIB,DISP=SHR
            //GO.STEPLIB  DD DSN=SYS1.PL1LIB,DISP=SHR
            //GO.SYSIN    DD *
            45 20 60 30 70 'MY HOME LOAN'
            /*
            //