Set Up the PLIJCLdemo Project

Walks you through the steps required to create the PLIJCLdemo project, add three source files, and define a build configuration.
Create the PLIJCLdemo project
  1. From the main menu in Eclipse, select File > New > Mainframe PL/I Project.
  2. Enter PLIJCLdemo in the Project Name field.
  3. Check Use default location.
  4. Click Finish.

    This adds the project to the Application Explorer view.

Add source files to the PLIJCLdemo project
Here you add two PL/I program files and one JCL job file to the PLIJCLdemo project.
Create the opdemo.pli source file
  1. Right-click the project in the Application Explorer view, and select New > File > PL/I Program.
  2. In the New file name field, enter opdemo.pli, and then click Finish.

    The editor appears with skeleton code for opdemo.pli.

  3. Overwrite the skeleton contents with the following code:
    Note: Make sure the first line of code begins in column 2.
     OPDEMO: PROC(JCLPARM) OPTIONS(MAIN) REORDER;
     
     
     DCL JCLPARM CHAR(20) VARYING;
    
     /*-------------------------------------------------------------------*/
     /*                        F I L E S                                  */
     /*-------------------------------------------------------------------*/
    
      DCL SYSIN FILE RECORD INPUT  ENVIRONMENT(FB RECSIZE(80));
    
      DCL SYSUT1 FILE RECORD INPUT  ENVIRONMENT(FB RECSIZE(80));
    
      DCL SYSUT2 FILE RECORD OUTPUT ENVIRONMENT(FB RECSIZE(80));
      
      DCL SYSPRINT FILE STREAM OUTPUT PRINT ENV (F RECSIZE (132));
    
     /*-------------------------------------------------------------------*/
     /*            S T R U C T U R E S    &    A R R A Y S                */
     /*-------------------------------------------------------------------*/
     /*-------------------------------------------------------------------*/
     /*                E X T E R N A L    E N T R I E S                   */
     /*-------------------------------------------------------------------*/
    
    
     /*-------------------------------------------------------------------*/
     /*                 O T H E R    V A R I A B L E S                    */
     /*-------------------------------------------------------------------*/
    
    
     DCL ACCUMULATOR     FIXED BIN(31) INIT(1);
    
     DCL ASCII_ALPHABET char(38)
       init('!ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ');
    
     DCL chTemp char(1);                                                                       
    
     DCL EBCDIC_ALPHABET char(38) init
       ('5AC1C2C3C4C5C6C7C8C9D1D2D3D4D5D6D7D8D9E2E3E4E5E6E7E8E9'x || 
        'F0F1F2F3F4F5F6F7F8F940'x);
    
     DCL EOF_SYSIN      CHAR(1) INIT('0');
     
     DCL EOF_SYSUT1     CHAR(1) INIT('0');
    
     DCL ITERATIONS     FIXED BIN(31) INIT(0);
    
     DCL JCLTRANS       CHAR(20) VARYING; 
    
     DCL REC_BUFF       char(80);
     
     DCL REPLY_STR      CHAR(120) VARYING;
     
     DCL STATIC_STR     CHAR(200) varying 
       init('Hi Dave - this is your static string');
     
     DCL SYSIN_NUM_RECS PIC '9999';
     
     DCL SYSPRINT_BUFF  CHAR(132);
     
     DCL VAR_NUMERIC    PIC '9999';
                                                                           
     /*-------------------------------------------------------------------*/
     /*              B U I L T I N     F U N C T I O N S                  */
     /*-------------------------------------------------------------------*/
     
     DCL PLIRETC BUILTIN;
     DCL TRANSLATE BUILTIN;
     DCL DELAY   BUILTIN;
     
     
     /*-------------------------------------------------------------------*/
     /*                   M O D U L E     L O G I C                       */
     /*-------------------------------------------------------------------*/
    
    
      on error begin;
        PUT SKIP LIST('On Error Triggered' || oncode());
        goto AFTERON;
      end;
    
     
      on conversion begin;
        PUT SKIP LIST('On Conversion Triggered');
        goto AFTERON;
      end;
    
      ON ENDFILE (SYSIN)
         begin;
           EOF_SYSIN = '1';
           put skip list('SYSIN EOF Reached - Num Recs: ' || 
                         sysin_num_recs);
         end;
    
    
      ON ENDFILE (SYSUT1)
         begin;
           EOF_SYSUT1 = '1';
           put skip list('SYSUT1 EOF Reached');
         end;
    
     SYSPRINT_BUFF = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' || /* 26 */
                     'ABCDEFGHIJKLMNOPQRSTUVWXYZ' || /* 52 */
                     'ABCDEFGHIJKLMNOPQRSTUVWXYZ' || /* 78 */
                     'ABCDEFGHIJKLMNOPQRSTUVWXYZ' || /* 104 */
                     'ABCDEFGHIJKLMNOPQRSTUVWXYZ' || /* 130 */
                     '12';
     open file(sysprint);
     PUT SKIP LIST(SYSPRINT_BUFF);
     
     put skip list('Length of JCLPARM: ' || length(jclparm));
     PUT DATA(JCLPARM);
     PUT SKIP;
    
     if (JCLPARM = 'DISPLAYREPLY') then
       do;
         DISPLAY('STARTING OPDEMO.PLI') REPLY(reply_str);
         put skip list('Reply String: ' || reply_str);
       end;
     else
       do;
       
         /* Read SYSIN to EOF */
         sysin_num_recs = '0';
         open input file(sysin);
         do while(eof_sysin = '0');
             read file(sysin) into (rec_buff);
             if (eof_sysin = '0') then
               sysin_num_recs = sysin_num_recs + 1;
         end;
         close file(sysin);
       
       end;
    
     /***********************************************************/
     /*  Open SYSUT1 and read until EOF translating records and */
     /*  Writing them to SYSUT2                                 */
     /***********************************************************/
     
     open file(sysut1) input;
     open file(sysut2) output;
    
     do while(eof_sysut1 = '0');
        read file(sysut1) into(rec_buff);
        if (eof_sysut1 = '0') then
          do;
            rec_buff = Translate(rec_buff, ascii_alphabet, ebcdic_alphabet);
            write file(sysut2) from(rec_buff);
          end;
     end;
    
     close file(sysut1);
     close file(sysut2);
    
     STARTIT:
    
     PUT SKIP DATA(ACCUMULATOR);
     ACCUMULATOR = ACCUMULATOR + 15;
     PUT SKIP DATA(ACCUMULATOR);
    
     PUT SKIP LIST('Triggering ON Unit');
     VAR_NUMERIC = 'DAVE';
     PUT SKIP DATA(VAR_NUMERIC); 
    
     AFTERON:
     PUT SKIP LIST('SLEEPING for 3 Seconds');
    
     Delay(3000);  /*  Sleep for 3 seconds */
    
     Iterations = Iterations + 1;
    
     /*  Let's run for about 6 seconds */
     If Iterations < 2 then
       goto startit;
    
     END;
  4. Save the file.

    By default, saving a file automatically triggers a build of the project. You can see the progress of the build process in the Eclipse Console view.

Create the opdemo2.pli source file
  1. Right-click the project in the Application Explorer view, and select New > File > PL/I Program.
  2. In the New file name field, enter opdemo2.pli, and then click Finish.

    The editor appears with skeleton code for opdemo2.pli.

  3. Overwrite the skeleton contents with the following code:
    Note: Make sure the first line of code begins in column 2.
     OPDEMO2: PROC(JCLPARM) OPTIONS(MAIN) REORDER;
     
     
     DCL JCLPARM CHAR(20) VARYING;
    
     /*-------------------------------------------------------------------*/
     /*                        F I L E S                                  */
     /*-------------------------------------------------------------------*/
    
      DCL SYSIN FILE RECORD INPUT  ENVIRONMENT(FB RECSIZE(80));
    
      DCL SYSUT1 FILE RECORD INPUT  ENVIRONMENT(FB RECSIZE(80));
    
      DCL SYSUT2 FILE RECORD OUTPUT ENVIRONMENT(FB RECSIZE(80));
      
      DCL SYSPRINT FILE STREAM OUTPUT PRINT ENV (F RECSIZE (132));
    
     /*-------------------------------------------------------------------*/
     /*            S T R U C T U R E S    &    A R R A Y S                */
     /*-------------------------------------------------------------------*/
     /*-------------------------------------------------------------------*/
     /*                E X T E R N A L    E N T R I E S                   */
     /*-------------------------------------------------------------------*/
    
     /*-------------------------------------------------------------------*/
     /*                 O T H E R    V A R I A B L E S                    */
     /*-------------------------------------------------------------------*/
    
    
     DCL ACCUMULATOR     FIXED BIN(31) INIT(1);
    
     DCL ASCII_ALPHABET char(38)
       init('!ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ');
    
     DCL chTemp char(1);                                                                       
    
     DCL EBCDIC_ALPHABET char(38) init
       ('5AC1C2C3C4C5C6C7C8C9D1D2D3D4D5D6D7D8D9E2E3E4E5E6E7E8E9'x || 
        'F0F1F2F3F4F5F6F7F8F940'x);
    
     DCL EOF_SYSIN      CHAR(1) INIT('0');
     
     DCL EOF_SYSUT1     CHAR(1) INIT('0');
    
     DCL ITERATIONS     FIXED BIN(31) INIT(0);
    
     DCL JCLTRANS       CHAR(20) VARYING; 
    
     DCL REC_BUFF       char(80);
     
     DCL REPLY_STR      CHAR(120) varying;
     
     DCL SYSIN_NUM_RECS PIC '9999';
     
     DCL SYSPRINT_BUFF  CHAR(132);
     
     DCL VAR_NUMERIC    PIC '9999';
                                                                           
     /*-------------------------------------------------------------------*/
     /*              B U I L T I N     F U N C T I O N S                  */
     /*-------------------------------------------------------------------*/
     
     DCL DELAY BUILTIN;
     DCL PLIRETC BUILTIN;
     DCL TRANSLATE BUILTIN;
     
     /*-------------------------------------------------------------------*/
     /*                   M O D U L E     L O G I C                       */
     /*-------------------------------------------------------------------*/
    
    
      on error begin;
        PUT SKIP LIST('On Error Triggered');
        goto AFTERON;
      end;
    
     
      on conversion begin;
        PUT SKIP LIST('On Conversion Triggered');
        goto AFTERON;
      end;
    
      ON ENDFILE (SYSIN)
         begin;
           EOF_SYSIN = '1';
           put skip list('SYSIN EOF Reached - Num Recs: ' || 
                         sysin_num_recs);
         end;
    
    
      ON ENDFILE (SYSUT1)
         begin;
           EOF_SYSUT1 = '1';
           put skip list('SYSUT1 EOF Reached');
         end;
    
     SYSPRINT_BUFF = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' || /* 26 */
                     'ABCDEFGHIJKLMNOPQRSTUVWXYZ' || /* 52 */
                     'ABCDEFGHIJKLMNOPQRSTUVWXYZ' || /* 78 */
                     'ABCDEFGHIJKLMNOPQRSTUVWXYZ' || /* 104 */
                     'ABCDEFGHIJKLMNOPQRSTUVWXYZ' || /* 130 */
                     '12';
     open file(sysprint);
     PUT SKIP LIST(SYSPRINT_BUFF);
     
     put skip list('Length of JCLPARM: ' || length(jclparm));
     PUT DATA(JCLPARM); 
     
     PUT SKIP;
    
     if (JCLTRANS = 'DISPLAYREPLY') then
       DISPLAY('STARTING OPDEMO.PLI') REPLY(reply_str);
     else
       do;
       
         /* Read SYSIN to EOF */
         sysin_num_recs = '0';
         open input file(sysin);
         do while(eof_sysin = '0');
             read file(sysin) into (rec_buff);
             if (eof_sysin = '0') then
               sysin_num_recs = sysin_num_recs + 1;
         end;
         close file(sysin);
       
       end;
    
     /***********************************************************/
     /*  Open SYSUT1 and read until EOF translating records and */
     /*  Writing them to SYSUT2                                 */
     /***********************************************************/
     
     open file(sysut1) input;
     open file(sysut2) output;
    
     do while(eof_sysut1 = '0');
        read file(sysut1) into(rec_buff);
        if (eof_sysut1 = '0') then
          do;
            rec_buff = Translate(rec_buff, ascii_alphabet, ebcdic_alphabet);
            write file(sysut2) from(rec_buff);
          end;
     end;
    
     close file(sysut1);
     close file(sysut2);
    
     STARTIT:
    
     PUT SKIP DATA(ACCUMULATOR);
     ACCUMULATOR = ACCUMULATOR + 15;
     PUT SKIP DATA(ACCUMULATOR);
    
     PUT SKIP LIST('Triggering ON Unit');
     VAR_NUMERIC = 'DAVE';
     PUT SKIP DATA(VAR_NUMERIC); 
    
     AFTERON:
     PUT SKIP LIST('SLEEPING for 3 Seconds');
    
     Delay(3000);  /*  Sleep for 3 seconds */
    
     Iterations = Iterations + 1;
    
     /*  Let's run for about 6 seconds */
     If Iterations < 2 then
       goto startit;
    
     END;
  4. Save the file.

    When the project builds, the output folder includes two .dll files, one for each .pli file. This is because the default output type is "All executable native libraries" in the build configuration.

Create the opdemo.jcl JCL file
  1. Right-click the project in the Application Explorer view, and select New > File > JCL file.
  2. In the New file name field, enter opdemo.jcl.
  3. Overwrite the skeleton contents with the following code:
    //OPDEMO  JOB 'OPDEMO',CLASS=A,MSGCLASS=A
    //**************************************************************
    //*  Demonstrates a simple PL/I program running under
    //*  the control of JCL.
    //**************************************************************
    //* Copyright (C) 1985-2017 Micro Focus International Ltd.
    //* All rights reserved.
    //**************************************************************
    //STEP00   EXEC PGM=IEFBR14
    //SYSUT2   DD DSN=OPDEMO.SYSUT2,DISP=(MOD,DELETE,DELETE)
    //*
    //*  Execute the first step with an Open PL/I Binary
    //*
    //STEP10   EXEC PGM=OPDEMO,PARM='HEAP(80M,4M,ANY,KEEP)/NODISPLAYREPLY'
    //SYSUT1   DD *
    INPUT RECORD NUMBER 1
    INPUT RECORD NUMBER 2
    INPUT RECORD NUMBER 3
    /*
    //SYSIN    DD *
    SYSIN RECORD 1
    SYSIN RECORD 2
    SYSIN RECORD 3
    SYSIN RECORD 4
    /*
    //SYSOUT   DD SYSOUT=*
    //SYSPRINT DD SYSOUT=*,DCB=(RECFM=F,LRECL=132),HOLD=Y
    //SYSUT2   DD DSN=OPDEMO.SYSUT2,DISP=(NEW,CATLG),
    //            DCB=(DSORG=PS,LRECL=80,RECFM=FB)
    //*
    //*  Once is fun, twice is a even better
    //*
    //STEP20   EXEC PGM=OPDEMO2,
    //         PARM='HEAP(80M,4M,ANY,KEEP)/SOME STRING HERE'
    //SYSUT1   DD *
    INPUT RECORD NUMBER 3
    INPUT RECORD NUMBER 4
    INPUT RECORD NUMBER 5
    /*
    //SYSIN    DD *
    SYSIN RECORD 1
    /*
    //*SYSOUT   DD SYSOUT=*
    //SYSPRINT DD SYSOUT=*,DCB=(RECFM=F,LRECL=132),HOLD=Y
    //SYSUT2   DD DSN=OPDEMO.SYSUT2,DISP=MOD
    //*
    
  4. Save the file.
Create the PLIJCLbuild build configuration
A build configuration sets the path and location of the program that the JCL and your enterprise server instance are expecting. Other settings required for JCL applications, such as an output type of All executable native libraries and a mainframe system of MVS, are set by default.
  1. Right-click your project in the Application Explorer view and select Properties.
  2. Expand the Micro Focus node and choose Build Configurations.
  3. Click Manage Configurations.
  4. Click the Create a new configuration button .
  5. Select New_Configuration_01 and click the Rename button .
  6. Change the configuration name to PLIJCLbuild.
  7. Click Active to mark this configuration as Active.
  8. Click Finish.
  9. On the Build Configurations page, type PLIJCLbuild.bin into the Output directory name field, and then click Apply.
  10. In the left pane, expand Build Configurations, and then click PL/I Compile Settings.
  11. In the right pane, check Enable configuration specific settings.
  12. In the list of settings, make sure that the value of External vars in data section is set to Yes.
  13. In the left pane, click PL/I Link Settings.
  14. Use the drop-down list to change the value of Platform Target ito 64 Bit.
  15. Click Apply and Close.

    This rebuilds the project.

  16. In the Application Explorer view, expand the PLIJCLbuild.bin node to see the generated output files.