Here are a few examples of RPG/ILE program code. Some of the examples contain other elements; for example, if the application is a utility then I will usually execute the program from a command. If I write a command, then I will usually include a validity checking program and a panel group to contain help text. Therefore what you see here will be the entire group of programs that make up a small application process.

RTVPRTFA Retrieve Print File Attributes (CMD, CLP, RPG)
PGPDCRYPT Decrypt a PGP encrypted file (CMD, FTP, CLP)
Embedded SQL Example of using embedded SQL over large file
Interactive RPG/IV Example of RPG/IV subfile interactive program
 
 
   
RTVPRTFA
Retrieve Print File Attributes

/******************************************************************************/

/* COMMAND NAME:    RTVPRTFA                                                  */

/* COMMAND PROCESS: RTVPRTFAR                                                 */

/* DATE CREATED:    04/16/2003                                                */

/* WRITTEN BY:      Tony Davis (T. Davis Consulting Inc.)                     */

/* FUNCTION:        Retrieve print file attributes of a spooled file          */

/* -------------------------------------------------------------------------- */

/* COMPILE:         Command must be compiled with these options:              */

/*                  -------------------------------------------               */

/*                  PGM(*LIBL/RTVPRTFA)                                       */

/*                  ALLOW(*IPGM *BPGM)                                        */

/******************************************************************************/

 

             CMD        PROMPT('Retrieve Print File Attributes')

 

             PARM       KWD(SPFILE) TYPE(*CHAR) LEN(10) MIN(1) +

                          PROMPT('Spooled file')

             PARM       KWD(JOB) TYPE(JOBLIST) DFT(*) SNGVAL((*)) +

                          PROMPT('Job name')

             PARM       KWD(SPLNBR) TYPE(*DEC) LEN(6) DFT(*ONLY) +

                          RANGE(1 999999) SPCVAL((*LAST -1) (*ONLY +

                          0)) PROMPT('Spooled File number')

 

             PARM       KWD(NBROFPAGES) TYPE(*CHAR) LEN(10) +

                          RTNVAL(*YES) MIN(0) PROMPT('CL var for +

                          NBROFPAGES (10)')

 

             PARM       KWD(NBROFPAGEX) TYPE(*CHAR) LEN(10) +

                          RTNVAL(*YES) MIN(0) PROMPT('CL var for +

                          NBROFPAGEX (10)')

 

             PARM       KWD(SIZEOFFILE) TYPE(*CHAR) LEN(10) +

                          RTNVAL(*YES) MIN(0) PROMPT('CL var for +

                          SIZEOFFILE (10)')

 

             PARM       KWD(SIZEOFFILX) TYPE(*CHAR) LEN(10) +

                          RTNVAL(*YES) MIN(0) PROMPT('CL var for +

                          SIZEOFFILX (10)')

 

             PARM       KWD(HOLDOUTQ) TYPE(*CHAR) LEN(10) +

                          RTNVAL(*YES) MIN(0) PROMPT('CL var for +

                          HOLDOUTQ (10)')

 

             PARM       KWD(OUTQNAME) TYPE(*CHAR) LEN(10) +

                          RTNVAL(*YES) MIN(0) PROMPT('CL var for +

                          OUTQNAME (10)')

 

             PARM       KWD(OUTQLIBL) TYPE(*CHAR) LEN(10) +

                          RTNVAL(*YES) MIN(0) PROMPT('CL var for +

                          OUTQLIBL (10)')

 

             PARM       KWD(DATEOFFILE) TYPE(*CHAR) LEN(7) +

                          RTNVAL(*YES) MIN(0) PROMPT('CL var for +

                          DATEOFFILE (8)')

 

             PARM       KWD(SYSTEMNAME) TYPE(*CHAR) LEN(8) +

                          RTNVAL(*YES) MIN(0) PROMPT('CL var for +

                          SYSTEMNAME (8)')

 

             PARM       KWD(USERNAME) TYPE(*CHAR) LEN(10) +

                          RTNVAL(*YES) MIN(0) PROMPT('CL var for +

                          USERNAME (10)')

 

 JOBLIST:    QUAL       TYPE(*NAME) LEN(10) DFT(*JOB) SPCVAL((*JOB))

             QUAL       TYPE(*CHAR) LEN(10) PROMPT('User')

             QUAL       TYPE(*CHAR) LEN(6) RANGE('000001' '999999') +

                          PROMPT('Number')

 

/**************************************************************************/

/* Program name:     RTVPRTFAC  -   RETRIEVE PRINT FILE ATTRIBUTES        */

/* Date created:     April 18, 2003                                       */

/* Original author:  Tony Davis (T. Davis Consulting Inc.)                */

/* Description:      command processor program for command RTVPRTFA       */

/**************************************************************************/

 

             PGM        PARM(&SPLFILNAME &SPLJOBNAME &SPLFILNUM +

                          &ATTNBRPAGA &ATTNBRPAGX &ATTSPLSIZA +

                          &ATTSPLSIZX &ATTHOLD &ATTOUTA &ATTOUTQLIB +

                          &ATTDATE &ATTSYSTEM &ATTUSER)

 

             DCL        VAR(&SPLFILNAME) TYPE(*CHAR) LEN(10)

             DCL        VAR(&SPLJOBNAME) TYPE(*CHAR) LEN(26)

             DCL        VAR(&SPLFILNUM)  TYPE(*DEC)  LEN(6 0)

             DCL        VAR(&ATTSPLSIZA) TYPE(*CHAR) LEN(10)

             DCL        VAR(&ATTSPLSIZX) TYPE(*CHAR) LEN(10)

             DCL        VAR(&ATTNBRPAGA) TYPE(*CHAR) LEN(10)

             DCL        VAR(&ATTNBRPAGX) TYPE(*CHAR) LEN(10)

             DCL        VAR(&ATTHOLD)    TYPE(*CHAR) LEN(10)

             DCL        VAR(&ATTOUTA)    TYPE(*CHAR) LEN(10)

             DCL        VAR(&ATTOUTQLIB) TYPE(*CHAR) LEN(10)

             DCL        VAR(&ATTDATE)    TYPE(*CHAR) LEN(8)

             DCL        VAR(&ATTSYSTEM)  TYPE(*CHAR) LEN(10)

             DCL        VAR(&ATTUSER)    TYPE(*CHAR) LEN(10)

             DCL        VAR(&SPLNBR)     TYPE(*CHAR) LEN(6)

 

             DCL        VAR(&FLD1) TYPE(*CHAR) LEN(10)

             DCL        VAR(&FLD2) TYPE(*CHAR) LEN(10)

             DCL        VAR(&FLD3) TYPE(*CHAR) LEN(10)

             DCL        VAR(&FLD4) TYPE(*CHAR) LEN(10)

 

             MONMSG     MSGID(CEE9901)

 

             IF         COND(&SPLFILNUM *EQ -1) THEN(CHGVAR +

                          VAR(&SPLNBR) VALUE('*LAST'))

 

             IF         COND(&SPLFILNUM *EQ 0) THEN(CHGVAR +

                          VAR(&SPLNBR) VALUE('*ONLY'))

 

             IF         COND(&SPLNBR *EQ ' ') THEN(CHGVAR +

                          VAR(&SPLNBR) VALUE(&SPLFILNUM))

 

/* set return values to something to prevent pointer error */

 

             CALL       PGM(RTVPRTFAR) PARM(&SPLFILNAME &SPLJOBNAME +

                          &SPLNBR &ATTSPLSIZA &ATTSPLSIZX +

                          &ATTNBRPAGA &ATTNBRPAGX &ATTHOLD &ATTOUTA +

                          &ATTOUTQLIB &ATTDATE &ATTSYSTEM &ATTUSER)

 

             ENDPGM

     ‚**************************************************************************

     ‚* Program name:     RTVPRTFAR                                            *

     ‚* Called from:      RTVPRTFAC (CPP for command RTVPRTFA)                 *

     ‚* Date created:     April 18, 2003                                       *

     ‚* Original author:  Tony Davis (T. Davis Consulting Inc.)                *

     ‚* Description:      RETRIEVE PRINT FILE ATTRIBUTES                       *

     ‚**************************************************************************

 

     H DATFMT(*ISO) DATEDIT(*YMD)

      

      * Retrieve Spool File Attributes

     d QUSRSPLA        pr                  Extpgm('QUSRSPLA')

     d  Spl_Attrib_DS             32767a   varying

     d  Receiver_Len                 10i 0 const

     d  Format_Name                   8a   const

     d  Qual_Job_Name                26a   const

     d  Int_JobID                    16a   const

     d  Int_SpoolID                  16a   const

     d  Spl_File_Name                10a   const

     d  Spl_File_Numb                10i 0 const

     d  Error_DS                    272a   options(*nopass)

 

 

      * Qualified Spool File Job Name

     d spl_jobname_ds  ds            26

     d  spl_jname                    10a

     d  spl_uname                    10a

     d  spl_jnumber                   6a

 

      * List Spooled Files

     d QUSLSPL         pr                  Extpgm('QUSLSPL')

     d  Space_Name                   20a   const

     d  Format_Name                   8a   const

     d  User_Name                    10a   const

     d  Qual_Outq                    20a   const

     d  Form_Type                    10a   const

     d  User_Spec_Dta                10a   const

     d  Error_DS                    272a

     d  Qual_Job_Name                26a   const

     d  Key_Array                    20    const

     d  Key_Count                    10i 0 const

 

     d Key_Count       c                   5

 

      *********************************************************************

      * Spool File Attributes (retrieved from QUSRSPLA API)               *

      *********************************************************************

     d spl_attrib_ds   ds          3780    based(attr_ptr)

     d  attr_retrn                   10i 0

     d  attr_avail                   10i 0

     d  attr_uname            59     68a

     d  attr_usrdta           99    108a

     d  attr_hold            129    138a

     d  attr_nbr_page        149    152i 0

     d  attr_outq            191    200a

     d  attr_outqlib         201    210a

     d  attr_date            211    217a

     d  attr_system         3421   3428a

     d  attr_user           3437   3446a

     d  attr_spl_size       3777   3780i 0

 

      *********************************************************************

      * Return Parameters                                                 *

      *********************************************************************

     d attr_nbr_pag_a  s             10

     d attr_nbr_pag_x  s             10

     d attr_spl_siz_a  s             10

     d attr_spl_siz_x  s             10

     d attr_hold_a     s             10

     d attr_outq_a     s             10

     d attr_outqlib_a  s             10

     d attr_date_a     s              8

     d attr_system_a   s              8

     d attr_user_a     s              8

 

      * date spooled file opened - from API

     d attr_date_ds    ds             7

     d  date_cent                     1a

     d  date_year                     2a

     d  date_month                    2a

     d  date_day                      2a

 

      *********************************************************************

      * VARIABLES                                                         *

      *********************************************************************

     d attr_fmtname    s              8a   inz('SPLA0200')

     d attr_data_str   s          32767a   inz varying

     d attr_ptr        s               *   inz

     d cmd_length      s             15p 5 inz

     d cmd_string      s           1024a   inz

     d length          s             10i 0 inz

     d int_job_id      s             16a   inz

     d int_spl_id      s             16a   inz

     d spl_filname     s             10a

     d spl_filnum_a    s              6a

     d spl_filnum      s             10i 0

     d nbrparms        s             10s 0

 

      *********************************************************************

      * POINTERS TO PARAMETERS, needed in order to test for *NULL value   *

      * passed from command (when using RTNVAL(*YES) in the command) if   *

      * a parameter is not selected, then *NULL pointer is delivered to   *

      * the command processor, and %parms is not sufficient to determine  *

      * whether or not that parameter is OK to address.                   *

      *********************************************************************

     d PtrParm4        s               *   inz

     d PtrParm5        s               *   inz

     d PtrParm6        s               *   inz

     d PtrParm7        s               *   inz

     d PtrParm8        s               *   inz

     d PtrParm9        s               *   inz

     d PtrParm10       s               *   inz

     d PtrParm11       s               *   inz

     d PtrParm12       s               *   inz

     d PtrParm13       s               *   inz

 

      *********************************************************************

      *                                                                   *

      *                        - Begin Program -                          *

      *                                                                   *

      *********************************************************************

 

     c     *entry        plist

01   c                   parm                    spl_filname

02   c                   parm                    spl_jobname_ds

03   c                   parm                    spl_filnum_a

04   c                   parm                    attr_spl_siz_a

05   c                   parm                    attr_spl_siz_x

06   c                   parm                    attr_nbr_pag_a

07   c                   parm                    attr_nbr_pag_x

08   c                   parm                    attr_hold_a

09   c                   parm                    attr_outq_a

10   c                   parm                    attr_outqlib_a

11   c                   parm                    attr_date_a

12   c                   parm                    attr_system_a

13   c                   parm                    attr_user_a

 

     c                   eval      nbrparms = %parms

 

     c                   select

     c                   when      spl_filnum_a = '*LAST'

     c                   eval      spl_filnum = -1

 

     c                   when      spl_filnum_a = '*ONLY'

     c                   eval      spl_filnum = 0

 

     c                   other

     c                   move      spl_filnum_a  spl_filnum

     c                   endsl

 

      * Do 1st pass to determine how much data is available to be returned

     c                   eval      %len(attr_data_str)=8

     c                   eval      length=%len(attr_data_str)

 

     c                   callp     qusrspla(

     c                                      attr_data_str:

     c                                      length:

     c                                      attr_fmtname:

     c                                      spl_jobname_ds:

     c                                      int_job_id:

     c                                      int_spl_id:

     c                                      spl_filname:

     c                                      spl_filnum)

 

      * Set attribute data structure to address of data string

     c                   eval      attr_ptr=%addr(attr_data_str)

 

      * Do second pass to retrieve all spool file attributes

     c                   eval      %len(attr_data_str)=attr_avail

     c                   eval      length=%len(attr_data_str)

 

     c                   callp     qusrspla(

     c                                      attr_data_str:

     c                                      length:

     c                                      attr_fmtname:

     c                                      spl_jobname_ds:

     c                                      int_job_id:

     c                                      int_spl_id:

     c                                      spl_filname:

     c                                      spl_filnum)

 

      *********************************************************************

      *                                                                   *

      *                      - Return Paramaters -                        *

      *                                                                   *

      *********************************************************************

 

      * set address of parameter to variable/pointer

     c                   eval      PtrParm4  = %addr(attr_spl_siz_a)

     c                   eval      PtrParm5  = %addr(attr_spl_siz_x)

     c                   eval      PtrParm6  = %addr(attr_nbr_pag_a)

     c                   eval      PtrParm7  = %addr(attr_nbr_pag_x)

     c                   eval      PtrParm8  = %addr(attr_hold_a)

     c                   eval      PtrParm9  = %addr(attr_outq_a)

     c                   eval      PtrParm10 = %addr(attr_outqlib_a)

     c                   eval      PtrParm11 = %addr(attr_date_a)

     c                   eval      PtrParm12 = %addr(attr_system_a)

     c                   eval      PtrParm13 = %addr(attr_user_a)

 

      * size of spooled file (left justified)

     c                   if        %parms >= 4 and PtrParm4 <> *NULL

     c                   move      attr_spl_size attr_spl_siz_a

     c                   if        %parms >= 5 and PtrParm5 <> *NULL

     c     '0':' '       xlate     attr_spl_siz_aattr_spl_siz_x

     c                   eval      attr_spl_siz_x = %triml(attr_spl_siz_x)

     c                   end

     c                   end

 

      * number of pages in spool file (left justified)

     c                   if        %parms >= 6 and PtrParm6 <> *NULL

     c                   move      attr_nbr_page attr_nbr_pag_a

     c                   if        %parms >= 7 and PtrParm7 <> *NULL

     c     '0':' '       xlate     attr_nbr_pag_aattr_nbr_pag_x

     c                   eval      attr_nbr_pag_x = %triml(attr_nbr_pag_x)

     c                   end

     c                   end

 

      * hold spooled file

     c                   if        %parms >= 8 and PtrParm8 <> *NULL

     c                   eval      attr_hold_a = attr_hold

     c                   end

 

      * output queue name

     c                   if        %parms >= 9 and PtrParm9 <> *NULL

     c                   eval      attr_outq_a = attr_outq

     c                   end

 

      * output queue library name

     c                   if        %parms >= 10 and PtrParm10 <> *NULL

     c                   eval      attr_outqlib_a = attr_outqlib

     c                   end

 

      * date

     c                   if        %parms >= 11 and PtrParm11 <> *NULL

     c                   eval      attr_date_ds = attr_date

     c                   eval      attr_date_a =

     c                             ('20' + date_year   +

     c                                     date_month  +

     c                                     date_day)

     c                   end

 

      * system name

     c                   if        %parms >= 12 and PtrParm12 <> *NULL

     c                   eval      attr_system_a = attr_system

     c                   end

 

      * user

     c                   if        %parms >= 13 and PtrParm13 <> *NULL

     c                   eval      attr_user_a = attr_user

     c                   end

 

      * End of program

     c                   return

 

PGPDCRYPT
Decrypt a PGP encrypted file

/*********************************************************************/

/* Command name:   PGPDCRYPT                                         */

/* Date created:   09/11/2001                                        */

/* Written by:     Tony Davis (T. Davis Consulting Inc.)             */

/* Function:       Decrypt a PGP-encrypted file via FTP from AS/400  */

/*                                                                   */

/* Note:           COMPILE COMMAND WITH THE FOLLOWING INCLUDED:      */

/*********************************************************************/

 

             CMD        PROMPT('Decrypt a PGP-encrypted file')

 

             PARM       KWD(PASSWORD) TYPE(*PNAME) LEN(30) MIN(1) +

                          ALWVAR(*YES) CASE(*MIXED) DSPINPUT(*NO) +

                          PROMPT('Password' 1)

 

             PARM       KWD(IPADDRESS) TYPE(*CHAR) LEN(30) MIN(1) +

                          ALWVAR(*YES) FILE(*UPD) PROMPT('IP +

                          Address or Host name' 2)

 

             PARM       KWD(ACCOUNT) TYPE(*CHAR) LEN(20) MIN(1) +

                          ALWVAR(*YES) FILE(*UPD) CASE(*MIXED) +

                          PROMPT('User Account' 3)

 

             PARM       KWD(PATH) TYPE(*CHAR) LEN(50) MIN(0) +

                          ALWVAR(*YES) FILE(*UPD) PROMPT('Directory +

                          name' 4)

 

             PARM       KWD(FILENAME) TYPE(*CHAR) LEN(50) MIN(0) +

                          ALWVAR(*YES) FILE(*UPD) CASE(*MIXED) +

                          PROMPT('File name' 5)

 

/*********************************************************************/

/* Program Name:  PGPDCRYPTV                                         */

/* Date Created:  September 11, 2001                                 */

/* Written by:    Tony Davis (T. Davis Consulting Inc.)              */

/* Function:      Review FTP message log and report errors if found  */

/*********************************************************************/

 

             PGM        PARM(&FTPERROR &FTPERRMSG)

             DCL        VAR(&FTPERROR   )   TYPE(*CHAR) LEN(3)

             DCL        VAR(&FTPERRMSG  )   TYPE(*CHAR) LEN(75)

             DCL        VAR(&RETURNCODE )   TYPE(*CHAR) LEN(4)

 

             DCLF       FILE(QFTPSRC)

             OVRDBF     FILE(QFTPSRC) TOFILE(QTEMP/PGPFTPSRC) +

                          MBR(MESSAGES)

 

 RCVF:       RCVF

             MONMSG     MSGID(CPF0864) EXEC(GOTO CMDLBL(EOJ))

 

             CHGVAR     VAR(&RETURNCODE) VALUE(%SST(&SRCDTA 1 4))

 

/*-------------------------------------------------------------------*/

/* Check EXEC command successful MESSAGE                             */

/*-------------------------------------------------------------------*/

 

             IF         COND(&RETURNCODE *EQ '200 ') THEN(SNDPGMMSG +

                          MSGID(CPF9898) MSGF(QCPFMSG) +

                          MSGDTA(&SRCDTA) TOPGMQ(*PRV) MSGTYPE(*DIAG))

 

/*-------------------------------------------------------------------*/

/* Check all return codes for ERROR conditions                       */

/*-------------------------------------------------------------------*/

 

             IF         COND((&RETURNCODE *EQ '425 ') *OR +

                             (&RETURNCODE *EQ '426 ') *OR +

                             (&RETURNCODE *EQ '450 ') *OR +

                             (&RETURNCODE *EQ '451 ') *OR +

                             (&RETURNCODE *EQ '452 ') *OR +

                             (&RETURNCODE *EQ '500 ') *OR +

                             (&RETURNCODE *EQ '501 ') *OR +

                             (&RETURNCODE *EQ '502 ') *OR +

                             (&RETURNCODE *EQ '503 ') *OR +

                             (&RETURNCODE *EQ '504 ') *OR +

                             (&RETURNCODE *EQ '530 ') *OR +

                             (&RETURNCODE *EQ '532 ') *OR +

                             (&RETURNCODE *EQ '550 ') *OR +

                             (&RETURNCODE *EQ '551 ') *OR +

                             (&RETURNCODE *EQ '552 ') *OR +

                             (&RETURNCODE *EQ '553 '))  THEN(DO)

 

             CHGVAR     VAR(&FTPERROR) VALUE(%SST(&RETURNCODE 1 3))

             CHGVAR     VAR(&FTPERRMSG) VALUE(%SST(&SRCDTA 4 75))

             GOTO       CMDLBL(ERROREXIT)

             ENDDO

 

             GOTO       CMDLBL(RCVF) /* Get another message record */

 

/*-------------------------------------------------------------------*/

/* A error was found. Send escape message.                           */

/*-------------------------------------------------------------------*/

 

 ERROREXIT:  SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('PGP +

                          decryption routine failed. See message +

                          log') TOPGMQ(*PRV) MSGTYPE(*DIAG)

             SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) TOPGMQ(*PRV) +

                          MSGTYPE(*ESCAPE)

             RCVMSG     MSGQ(*PGMQ) MSGTYPE(*LAST) RMV(*YES)

 

 EOJ:        ENDPGM

.**********************************************************************

.* Panel Group name:  PGPDCRYPT                                       *

.* Date Created:      September 13, 2001                              *

.* Written by:        Tony Davis (T. Davis Consulting Inc.)           *

.* Function:          Panel group help text for command PGPDCRYPT     *

.**********************************************************************

:PNLGRP.

.**********************************************************************

:HELP NAME='PGPDCRYPT'.

Decrypt a PGP-encrypted file

:XH1.

.**********************************************************************

.* OVERVIEW of the command

.**********************************************************************

OVERVIEW

:P.

The PGPDCRYPT command will execute PGP decryption on an FTP server

using the FTP quote subcommand. A subcommand text file member is

created dynamically in file QTEMP/PGPFTPSRC member COMMANDS, with

FTP messaging being logged to file QTEMP/PGPFTPSRC member MESSAGES.

PGP will create a new file in the same directory specified, with the

extension of '.pgp' dropped. The actual command that is executed to

perform the PBP decryption is

QUOTE SITE EXEX c:\pgp\pgp.exe <filename>, where <filename> is the

name of the file that is entered into this command.

:P.

:XH1.

:EHELP.

.**********************************************************************

.* PASSWORD parameter

.**********************************************************************

:HELP NAME='PGPDCRYPT/PASSWORD'.

Password (PASSWORD) parameter

:XH1.

Password (PASSWORD) parameter

:P.

This is a required parameter, and is also non-display.

The value used here will be used as access to the FTP server; i.e.,

the password of the account specified in the user account parameter.

If the FTP server allows anonymous log ins, and anonymous will be

used as the user account name, then enter an email address as the

password.

:p.

:EHELP.

.**********************************************************************

.* IPADDRESS parameter

.**********************************************************************

:HELP NAME='PGPDCRYPT/IPADDRESS'.

IP address or Host Name (IPADDRESS) parameter

:XH1.

IP address or Host Name (IPADDRESS) parameter

:P.

This is a required parameter. Enter either an IP address or the

host name of the FTP server that you are attempting to access.

If using a host name, then that name must be defined in the host

table entries defined on the AS/400.

:p.

:EHELP.

.**********************************************************************

.* ACCOUNT parameter

.**********************************************************************

:HELP NAME='PGPDCRYPT/ACCOUNT'.

User Account (ACCOUNT) parameter

:XH1.

User Account (ACCOUNT) parameter

:P.

This is a required parameter. The value used here will be used to

access the FTP server. This must be the name of the account that is

set up on the FTP server being accessed.

:p.

:EHELP.

.**********************************************************************

.* PATH parameter

.**********************************************************************

:HELP NAME='PGPDCRYPT/PATH'.

Path (PATH) parameter

:XH1.

Path (PATH) parameter

:P.

This is the directory path that contains the file to be decrypted,

and also the directory that will contain the new file created after

decryption runs. If the file already exists, then it WILL NOT BE

overlayed.

:p.

:EHELP.

.**********************************************************************

.* FILENAME parameter

.**********************************************************************

:HELP NAME='PGPDCRYPT/FILENAME'.

Filename (FILENAME) parameter

:XH1.

Filename (FILENAME) parameter

:P.

This is the name of the file to be decrypted. The file name must have

the extension of '.pgp', in addition to any standard extension. For

example, if ohs0906.asc.pgp needs decryption, then file ohs0906.asc

will be created in the same directory specified.

:p.

:EHELP.

.********************************************************************

:EPNLGRP.

/*********************************************************************/

/* Program Name:  PGPDCRYPT                                          */

/* Date Created:  September 11, 2001                                 */

/* Written by:    Tony Davis (T. Davis Consulting Inc.)              */

/* Command:       CPP for command PGPDCRYPT                          */

/* Function:      Decrypt a PGP-encrypted file using FTP from AS/400 */

/*********************************************************************/

 

             PGM        PARM(&PASSWORD &IPADDRESS &ACCOUNT +

                          &DIRECTORY &FILENAME)

 

             DCL        VAR(&PASSWORD   )   TYPE(*CHAR) LEN(30)

             DCL        VAR(&IPADDRESS  )   TYPE(*CHAR) LEN(30)

             DCL        VAR(&ACCOUNT    )   TYPE(*CHAR) LEN(20)

             DCL        VAR(&DIRECTORY  )   TYPE(*CHAR) LEN(50)

             DCL        VAR(&FILENAME   )   TYPE(*CHAR) LEN(50)

 

             DCL        VAR(&MESSAGE    )   TYPE(*CHAR) LEN(512)

             DCL        VAR(&JOBMSG     )   TYPE(*CHAR) LEN(28)

             DCL        VAR(&JOB        )   TYPE(*CHAR) LEN(10)

             DCL        VAR(&USER       )   TYPE(*CHAR) LEN(10)

             DCL        VAR(&NBR        )   TYPE(*CHAR) LEN(6)

             DCL        VAR(&ERRORSW    )   TYPE(*LGL)

             DCL        VAR(&MSGID      )   TYPE(*CHAR) LEN(7)

             DCL        VAR(&MSG        )   TYPE(*CHAR) LEN(512)

             DCL        VAR(&MSGDTA     )   TYPE(*CHAR) LEN(512)

             DCL        VAR(&MSGF       )   TYPE(*CHAR) LEN(10)

             DCL        VAR(&MSGFLIB    )   TYPE(*CHAR) LEN(10)

             DCL        VAR(&KEYVAR     )   TYPE(*CHAR) LEN(4)

             DCL        VAR(&KEYVAR2    )   TYPE(*CHAR) LEN(4)

             DCL        VAR(&RTNTYPE    )   TYPE(*CHAR) LEN(2)

             DCL        VAR(&RTPARM     )   TYPE(*CHAR) LEN(1)

             DCL        VAR(&JOBUSER    )   TYPE(*CHAR) LEN(10)

             DCL        VAR(&JOBNAME    )   TYPE(*CHAR) LEN(10)

             DCL        VAR(&JOBNBR     )   TYPE(*CHAR) LEN(6)

             DCL        VAR(&FTPERROR   )   TYPE(*CHAR) LEN(3)

             DCL        VAR(&FTPERRMSG  )   TYPE(*CHAR) LEN(75)

 

             MONMSG     MSGID(CPF0000 CPA0000 MCH0000) EXEC(GOTO +

                          CMDLBL(STDERR1)) /* Global error monitor +

                          - standard error routine. */

 

/*------------------------------------------------------------------*/

/* Create a source physical file for FTP MESSAGES output            */

/*------------------------------------------------------------------*/

 

             CHKOBJ     OBJ(QTEMP/PGPFTPSRC) OBJTYPE(*FILE)

             MONMSG     MSGID(CPF9801) EXEC(CRTSRCPF +

                          FILE(QTEMP/PGPFTPSRC) RCDLEN(92))

 

             CHKOBJ     OBJ(QTEMP/PGPFTPSRC) OBJTYPE(*FILE) +

                          MBR(MESSAGES)

             MONMSG     MSGID(CPF9815) EXEC(ADDPFM +

                          FILE(QTEMP/PGPFTPSRC) MBR(MESSAGES) +

                          SRCTYPE(TXT)) /* Source member to contain +

                          FTP messages */

 

             CHKOBJ     OBJ(QTEMP/PGPFTPSRC) OBJTYPE(*FILE) +

                          MBR(COMMANDS)

             MONMSG     MSGID(CPF9815) EXEC(ADDPFM +

                          FILE(QTEMP/PGPFTPSRC) MBR(COMMANDS) +

                          SRCTYPE(TXT)) /* Source member to contain +

                          FTP subcommands */

 

             CLRPFM     FILE(QTEMP/PGPFTPSRC) MBR(MESSAGES)

             CLRPFM     FILE(QTEMP/PGPFTPSRC) MBR(COMMANDS)

 

/*------------------------------------------------------------------*/

/* Call program to build FTP sub-commands text file                 */

/*------------------------------------------------------------------*/

 

             OVRDBF     FILE(QFTPSRC) TOFILE(QTEMP/PGPFTPSRC) +

                          MBR(COMMANDS)

             OVRDBF     FILE(QFTPSRCX) TOFILE(QTEMP/PGPFTPSRC) +

                          MBR(COMMANDS)

 

             CALL       PGM(PGPDCRYPTR) PARM(&RTPARM &PASSWORD +

                          &IPADDRESS &ACCOUNT &DIRECTORY &FILENAME)

 

/*------------------------------------------------------------------*/

/* Execute FTP sub-commands                                         */

/*------------------------------------------------------------------*/

 

             OVRDBF     FILE(INPUT) TOFILE(QTEMP/PGPFTPSRC) +

                          MBR(COMMANDS)

 

             OVRDBF     FILE(OUTPUT) TOFILE(QTEMP/PGPFTPSRC) +

                          MBR(MESSAGES)

 

             FTP        RMTSYS(&IPADDRESS) /* Executes subcommands */

 

             DLTOVR     FILE(INPUT)

             DLTOVR     FILE(OUTPUT)

 

/*------------------------------------------------------------------*/

/* Call program that will read through the message file member, and */

/* determine if any errors were found.                              */

/*------------------------------------------------------------------*/

 

             CALL       PGM(PGPDCRYPTE) PARM(&FTPERROR &FTPERRMSG)

 

/*------------------------------------------------------------------*/

/* END OF PROGRAM                                                   */

/*------------------------------------------------------------------*/

 

 EXIT:       RETURN

 

/*-------------------------------------------------------------------*/

/* STANDARD ERROR ROUTINE                                            */

/*-------------------------------------------------------------------*/

 

 STDERR1:

 

             IF         COND(&ERRORSW) THEN(SNDPGMMSG MSGID(CPF9999) +

                          MSGF(QCPFMSG) MSGTYPE(*ESCAPE))

             CHGVAR     VAR(&ERRORSW) VALUE('1')

             RCVMSG     MSGTYPE(*EXCP) RMV(*NO) KEYVAR(&KEYVAR)

 

 STDERR2:    RCVMSG     MSGTYPE(*PRV) MSGKEY(&KEYVAR) RMV(*NO) +

                          KEYVAR(&KEYVAR2) MSG(&MSG) +

                          MSGDTA(&MSGDTA) MSGID(&MSGID) +

                          RTNTYPE(&RTNTYPE) MSGF(&MSGF) +

                          SNDMSGFLIB(&MSGFLIB)

 

             IF         COND(&RTNTYPE *NE '02') THEN(GOTO +

                          CMDLBL(STDERR3))

 

             IF         COND(&MSGID *NE ' ') THEN(SNDPGMMSG +

                          MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) +

                          MSGDTA(&MSGDTA) MSGTYPE(*DIAG))

 

             IF         COND(&MSGID *EQ ' ') THEN(SNDPGMMSG +

                          MSG(&MSG) MSGTYPE(*DIAG))

 

             RMVMSG     MSGKEY(&KEYVAR2)

 

 STDERR3:    RCVMSG     MSGKEY(&KEYVAR) MSGDTA(&MSGDTA) +

                          MSGID(&MSGID) MSGF(&MSGF) +

                          SNDMSGFLIB(&MSGFLIB)

 

             SNDPGMMSG  MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) +

                          MSGDTA(&MSGDTA) MSGTYPE(*ESCAPE)

 

 EOJ:        ENDPGM

    

     F*****************************************************************

     F*

     F*  Program ID          -    PGPDCRYPTR

     F*  Application ID      -    PGPDCRYPTR

     F*  Application Name    -    Decrypt PGP-encrypted file

     F*  Date Generated      -    Sep 12, 2001

     F*

     F*****************************************************************

     F*  Files Usage

     F*

     F*  QFTPSRC     - (I/DISK   ) Source file template

     F*  QFTPSRCX    - (U/DISK   ) Source file template

     F*

     F*****************************************************************

     F*  Function Of Subroutines

     F*

     F* SMAIN - Main flow of the program.

     F* SEND - END of program.

     F* SMSG - Error messages to job log.

     F* S001   - WRITE D.QFTPSRC,F.QFTPSRC

     F* SEXCP - Dummy EXCPT(s) and Read(s)

     F* SFERR - File Exception Handler

     F* SMVTOF - Move Fields From Work Area To File(s)

     F*

     F*****************************************************************

     F*            F i l e     S p e c i f i c a t i o n

     F*****************************************************************

     FQFTPSRC IF  E           K        DISK

     F            QFTPSRC                           KRENAMEFMT001

     F                                              KINFDS FIDS01

     F                                              KINFSR SFERR

     FQFTPSRCXO   E                    DISK

     F                                              KINFDS FIDS02

     F            QFTPSRC                           KRENAMEFMT002

     F                                              KINFSR SFERR

     F*

     I*****************************************************************

     I*            I n p u t    S p e c i f i c a t i o n

     I*****************************************************************

     IFIDS01      DS

     I                                     *STATUS  STS01

     I                                    B 397 4000REC01

     IFIDS02      DS

     I                                     *STATUS  STS02

     I                                    B 397 4000REC02

     I*

     I* DATE6

     I*

     IDATE6       DS

     I                                        1   60RN0005

     I                                        1   20DATEYY

     I                                        3   40DATEMM

     I                                        5   60DATEDD

     I*

     I* Named constants

     I*

     I              'quote site exec'     C         C0001

     I*

     I* Named constants

     I*

     I              'c:\pgp\pgp.exe '     C         C0002

     I*

     I* Date Manipulation Data Struct.

     I*

     I            DS

     I                                        1   80X1CDAT

     I                                        1   60X1DATE

     I                                        1   20X12

     I                                        3   40X34

     I                                        5   60X56

     I                                        7   80X78

     I*

     C*****************************************************************

     C*            P a r a m e t e r     L i s t

     C*****************************************************************

     C*

     C           *ENTRY    PLIST

     C                     PARM           RTPARM  1

     C                     PARM           PRM003 30

     C                     PARM           PRM002 30

     C                     PARM           PRM001 20

     C                     PARM           PATH   50

     C                     PARM           FNAME  50

     C*

     C           PMSGCL    PLIST

     C                     PARM           MSGACT  1

     C                     PARM           MSGID   7

     C                     PARM           MSGF   10

     C                     PARM           MSGFL  10

     C                     PARM           MSGDTA132

     C*****************************************************************

     C*        V a r i a b l e s     D e c l a r a t i o n

     C*****************************************************************

     C           LRFLAG    IFNE 'N'

     C           *LIKE     DEFN SRCDAT    WRCDAT           Source date

     C           *LIKE     DEFN SRCDTA    WRCDTA           Source data

     C           *LIKE     DEFN SRCSEQ    WRCSEQ           Source sequence

     C           *LIKE     DEFN REC01     HRC01

     C           *LIKE     DEFN SRCSEQ    HRCSEQ

     C                     MOVE *BLANKS   AARG1 256        Alpha argument1

     C                     MOVE *ZEROS    NARG3  309       Numeric argumnt

     C                     MOVE *ZEROS    C1      30       Numeric wrk fld

     C                     MOVE *BLANKS   AARG2 256        Alpha argument2

     C                     MOVE *BLANKS   ARSLT 256        Alpha result

     C                     MOVE *ZEROS    NARG1  309       Numer argument1

     C                     MOVE *ZEROS    NRSLT  309       Numeric result

     C                     MOVE *BLANKS   DATFMT  3        Date format

     C                     MOVE *ZEROS    SVDAT   60       Save date

     C                     MOVE *ZEROS    SVYY    20       Save year

     C                     MOVE *ZEROS    SVMM    20       Save month

     C                     MOVE *ZEROS    SVDD    20       Save days

     C                     MOVE *ZEROS    SVDAYS  30       Save days

     C                     MOVE *ZEROS    SVLEAP  10       If leap year

     C                     MOVE *ZEROS    FEB     20       NOD in feb/Leap

     C                     MOVE *ZEROS    SVCY    40       Save days

     C                     MOVE *ZEROS    SVCC    20       Save century

     C                     MOVE 1         CHKVAR  10       Perform Valid.

     C                     MOVE *BLANKS   BIBTDT 20

     C                     MOVE *BLANKS   BICTDC 20

     C                     MOVE *BLANKS   BICTDT 20

     C                     MOVE *ZEROS    RN0001 156       billing admin fee

     C                     MOVE *BLANKS   BILBDT 20

     C                     MOVE *ZEROS    RN0002 156       BILERFL

     C                     MOVE *ZEROS    RN0003 156       enrollment fee

     C                     MOVE *BLANKS   RN0004 20        Orig database code

     C                     MOVE *BLANKS   CD     20

     C                     MOVE *BLANKS   CLOSE  20

     C                     MOVE *BLANKS   CMD08  20

     C                     MOVE *BLANKS   DIR    20

     C                     MOVE *ZEROS    EDTDAT 156

     C                     MOVE *ZEROS    RN0006  52       billing admin fee

     C                     MOVE *BLANKS   OPEN   20

     C                     MOVE *BLANKS   PGP    20

     C                     MOVE *BLANKS   QUIT   20

     C                     MOVE *BLANKS   QUOTE  30

     C                     MOVE *BLANKS   SAVGRP  6

     C                     MOVE *BLANKS   SCRDTA 20

     C                     MOVE *BLANKS   RN0007 40        SRVFILE

     C                     MOVE *BLANKS   RN0008 20        CMD04

     C                     MOVE *BLANKS   RN0009 20        CMD03

     C                     MOVE *ZEROS    LCK01   10       File lock flag

     C                     MOVE *ZEROS    LCK02   10       File lock flag

     C                     MOVE *ZEROS    RN0005           Init DS/*DTA flds

     C                     MOVE *ZEROS    DATEYY           Init DS/*DTA flds

     C                     MOVE *ZEROS    DATEMM           Init DS/*DTA flds

     C                     MOVE *ZEROS    DATEDD           Init DS/*DTA flds

     C                     MOVE 'N'       IOFLAG  1

     C                     MOVE *BLANKS   SWRD01  1        RD STS

     C                     MOVE *BLANKS   ARSLT0256

     C                     MOVE *ZEROS    X1CDAT           Init DS/*DTA flds

     C                     MOVE 'N'       MSGFLG  1        Display Msg Flg

     C                     MOVE *ZEROS    UERCNT  10

     C                     MOVE *BLANKS   URSUME  6

     C                     Z-ADD*ZEROS    WCNTR   30       COUNTER

     C                     Z-ADD*ZEROS    WGETR   30       COUNTER

     C                     Z-ADD*ZEROS    WFILE#  20       FILE#

     C                     END

     C                     MOVE *BLANK    LRFLAG  1

     C*

     C/EJECT

     C*****************************************************************

     C*        M a i n l i n e      R o u t i n e

     C*****************************************************************

     C                     EXSR SMAIN

     C*

     C/EJECT

     C*****************************************************************

     C* SMAIN - Main flow of the program.

     C*****************************************************************

     C           SMAIN     BEGSR

     C*

     C* Define sub-command COMMANDS

     C* OPEN = 'open'

     C                     MOVE *BLANKS   OPEN

     C                     MOVEL'open'    OPEN

     C* CLOSE = 'close'

     C                     MOVE *BLANKS   CLOSE

     C                     MOVEL'close'   CLOSE

     C* VERBOSE = 'verbose'

     C                     MOVE *BLANKS   RN0009

     C                     MOVEL'verbose' RN0009

     C* USER = 'user'

     C                     MOVE *BLANKS   RN0008

     C                     MOVEL'user'    RN0008

     C* CD = 'cd'

     C                     MOVE *BLANKS   CD

     C                     MOVEL'cd'      CD

     C* QUOTE = 'quote site exec'

     C                     MOVE *BLANKS   QUOTE

     C                     MOVELC0001     QUOTE

     C* PGP = 'c:\pgp\pgp.exe '

     C                     MOVE *BLANKS   PGP

     C                     MOVELC0002     PGP

     C* QUIT = 'quit'

     C                     MOVE *BLANKS   QUIT

     C                     MOVEL'quit'    QUIT

     C* DIR = 'dir'

     C                     MOVE *BLANKS   DIR

     C                     MOVEL'dir'     DIR

     C*                                                               *

     C* CLOSE subcommand

     C* SRCDTA = *BLANKS

     C                     MOVEL*BLANKS   WRCDTA

     C* SRCDTA = close

     C                     MOVE *BLANKS   WRCDTA

     C                     MOVELCLOSE     WRCDTA

     C* WRITE D.QFTPSRC,F.QFTPSRC

     C*

     C                     EXSR S001

     C*                                                               *

     C* VERBOSE

     C* SRCDTA = *BLANKS

     C                     MOVEL*BLANKS   WRCDTA

     C* SRCDTA = verbose

     C                     MOVE *BLANKS   WRCDTA

     C                     MOVELRN0009    WRCDTA

     C* WRITE D.QFTPSRC,F.QFTPSRC

     C*

     C                     EXSR S001

     C* WRITE D.QFTPSRC,F.QFTPSRC

     C*

     C                     EXSR S001

     C*                                                               *

     C* OPEN the FTP connection

     C* SRCDTA = *BLANKS

     C                     MOVEL*BLANKS   WRCDTA

     C* SRCDTA = %BCT(open,IPADDRESS,1)

     C*  Concatenate with blanks inserted

     C                     Z-ADD1         C1

     C           OPEN      CAT  PRM002:C1 ARSLT0    P

     C                     MOVE *BLANKS   WRCDTA

     C                     MOVELARSLT0    WRCDTA

     C* WRITE D.QFTPSRC,F.QFTPSRC

     C*

     C                     EXSR S001

     C*                                                               *

     C* USER & PASSWORD

     C* SRCDTA = *BLANKS

     C                     MOVEL*BLANKS   WRCDTA

     C* SRCDTA = %BCT(user,ACCOUNT,1)

     C*  Concatenate with blanks inserted

     C                     Z-ADD1         C1

     C           RN0008    CAT  PRM001:C1 ARSLT0    P

     C                     MOVE *BLANKS   WRCDTA

     C                     MOVELARSLT0    WRCDTA

     C* SRCDTA = %BCT(SRCDTA,PASSWORD,1)

     C*  Concatenate with blanks inserted

     C                     Z-ADD1         C1

     C           WRCDTA    CAT  PRM003:C1 ARSLT0    P

     C                     MOVE *BLANKS   WRCDTA

     C                     MOVELARSLT0    WRCDTA

     C* WRITE D.QFTPSRC,F.QFTPSRC

     C*

     C                     EXSR S001

     C*                                                               *

     C* DIRECTORY listing of root diretory

     C* SRCDTA = *BLANKS

     C                     MOVEL*BLANKS   WRCDTA

     C* SRCDTA = dir

     C                     MOVE *BLANKS   WRCDTA

     C                     MOVELDIR       WRCDTA

     C* WRITE D.QFTPSRC,F.QFTPSRC

     C*

     C                     EXSR S001

     C*                                                               *

     C* CHANGE DIRECTORY

     C* SRCDTA = *BLANKS

     C                     MOVEL*BLANKS   WRCDTA

     C* SRCDTA = %BCT(cd,path,1)

     C*  Concatenate with blanks inserted

     C                     Z-ADD1         C1

     C           CD        CAT  PATH:C1   ARSLT0    P

     C                     MOVE *BLANKS   WRCDTA

     C                     MOVELARSLT0    WRCDTA

     C* WRITE D.QFTPSRC,F.QFTPSRC

     C*

     C                     EXSR S001

     C*                                                               *

     C* DIRECTORY listing of input directory

     C* SRCDTA = *BLANKS

     C                     MOVEL*BLANKS   WRCDTA

     C* SRCDTA = dir

     C                     MOVE *BLANKS   WRCDTA

     C                     MOVELDIR       WRCDTA

     C* WRITE D.QFTPSRC,F.QFTPSRC

     C*

     C                     EXSR S001

     C*                                                               *

     C* QUOTE string will contain PGP decryption

     C* SRCDTA = *BLANKS

     C                     MOVEL*BLANKS   WRCDTA

     C* SRCDTA = %BCT(quote,pgp,1)

     C*  Concatenate with blanks inserted

     C                     Z-ADD1         C1

     C           QUOTE     CAT  PGP:C1    ARSLT0    P

     C                     MOVE *BLANKS   WRCDTA

     C                     MOVELARSLT0    WRCDTA

     C* SRCDTA = %BCT(srcdta,fname,1)

     C*  Concatenate with blanks inserted

     C                     Z-ADD1         C1

     C           WRCDTA    CAT  FNAME:C1  ARSLT0    P

     C                     MOVE *BLANKS   WRCDTA

     C                     MOVELARSLT0    WRCDTA

     C* WRITE D.QFTPSRC,F.QFTPSRC

     C*

     C                     EXSR S001

     C*                                                               *

     C* CLOSE subcommand

     C* SRCDTA = *BLANKS

     C                     MOVEL*BLANKS   WRCDTA

     C* SRCDTA = close

     C                     MOVE *BLANKS   WRCDTA

     C                     MOVELCLOSE     WRCDTA

     C* WRITE D.QFTPSRC,F.QFTPSRC

     C*

     C                     EXSR S001

     C*                                                               *

     C* QUIT subcommand

     C* SRCDTA = *BLANKS

     C                     MOVEL*BLANKS   WRCDTA

     C* SRCDTA = quit

     C                     MOVE *BLANKS   WRCDTA

     C                     MOVELQUIT      WRCDTA

     C* WRITE D.QFTPSRC,F.QFTPSRC

     C*

     C                     EXSR S001

     C*                                                               *

     C                     EXSR SEND

     C                     ENDSR

     C/EJECT

     C*****************************************************************

     C* SEND - END of program.

     C*****************************************************************

     C           SEND      BEGSR

     C*

     C           LRFLAG    IFEQ 'Y'

     C           LRFLAG    OREQ *BLANK

     C                     MOVE '1'       *INLR

     C                     END                             LRFLAG EQ 'Y'

     C                     RETRN

     C                     ENDSR

     C/EJECT

     C*****************************************************************

     C* SMSG - Error messages to job log.

     C*        calls message handling program to add error

     C*        messages to job log or extract message from message file

     C*****************************************************************

     C           SMSG      BEGSR

     C*

     C                     CALL 'CLMSG'   PMSGCL

     C                     ENDSR

     C/EJECT

     C**************************************************************************

     C* S001   - WRITE D.QFTPSRC,F.QFTPSRC

     C**************************************************************************

     C           S001      BEGSR

     C                     Z-ADD1         WFILE#           SET FILE#

     C                     EXSR SMVTOF                     MOVE FLD TO FILE

     C                     Z-ADD2         WFILE#           SET FILE#

     C                     WRITEFMT002                 90  ADD REC TO QFTPSRC

     C                     Z-ADDSTS02     STS01            SYNC STATUS

     C*

     C           *IN90     IFEQ *ZERO                      RECORD ADDED

     C                     Z-ADDREC02     REC01

     C                     Z-ADD1         WFILE#           SET FILE#

     C                     ELSE

     C                     END                             END-STATUS

     C                     ENDSR

     C*

     C/EJECT

     C*****************************************************************

     C* SEXCP - Dummy EXCPT(s) and Read(s)

     C*****************************************************************

     C           SEXCP     BEGSR

     C                     READ QFTPSRC                  90

     C                     ENDSR

     C/EJECT

     C*****************************************************************

     C* SFERR - File Exception Handler

     C*****************************************************************

     C           SFERR     BEGSR

     C                     MOVE 'Y'       MSGFLG           MSG FLAG ON

     C           WFILE#    IFEQ 1                          QFTPSRC

     C           STS01     IFEQ 1218                       LOCK(SYS)

     C                     Z-ADD1122      STS01            ASSET LOCK STATUS

     C                     ELSE

     C           STS01     IFEQ 1211                       CLOSED FILE

     C                     ELSE

     C                     Z-ADD1121      STS01            TRIGGER TO EXEC NEXT

     C                     END

     C                     END

     C                     END

     C           WFILE#    IFEQ 2                          QFTPSRCX

     C           STS02     IFEQ 1218                       LOCK(SYS)

     C                     Z-ADD1122      STS02            ASSET LOCK STATUS

     C                     ELSE

     C           STS02     IFEQ 1211                       CLOSED FILE

     C                     ELSE

     C                     Z-ADD1121      STS02            TRIGGER TO EXEC NEXT

     C                     END

     C                     END

     C                     END

     C                     ENDSR

     C/EJECT

     C*****************************************************************

     C* SMVTOF - Move Fields From Work Area To File(s)

     C*****************************************************************

     C           SMVTOF    BEGSR

     C*          ------------------------------------------------------

     C*          | Move Fields From Work Area To File - QFTPSRC

     C*          ------------------------------------------------------

     C           WFILE#    IFEQ 01

     C                     Z-ADDWRCDAT    SRCDAT           Source date

     C                     MOVELWRCDTA    SRCDTA           Source data

     C                     Z-ADDWRCSEQ    SRCSEQ           Source sequence

     C                     END

     C                     ENDSR

Embedded SQL
Example of embedded SQL in RPG/IV

     H DATFMT(*ISO) DATEDIT(*YMD)

     H COPYRIGHT('(C) Copyright Manheim Auctions - 2003')

     H**************************************************************************

     H* Program name:     MAFDLRS1                                             *

     H* Date created:     February 17, 2003                                    *

     H* Original author:  TPD                                                  *

     H* Description:      Extract prospect data from master transaction file   *

     H*                   for use in MAFS prospect reports                     *

     H**************************************************************************

     D*

     D* Work fields

     D ALL             S              1A

     D FROM            S              8

     D THRU            S              8

     D Fdate           S              8P 0

     D Tdate           S              8P 0

     D Counter         S              9P 0

     D CounterP        S              9P 0 INZ(4)

     D Command         S             80A   INZ(' ')

     D MAFS_Only       S              1A

     D Non_MAFS_Only   S              1A

     D*

     D A1              S              4A

     D A2              S              4A

     D A3              S              4A

     D A4              S              4A

     D A5              S              4A

     D A6              S              4A

     D A7              S              4A

     D A8              S              4A

     D A9              S              4A

     D A0              S              4A

     D*

     D AUC1            S              4A

     D AUC2            S              4A

     D AUC3            S              4A

     D AUC4            S              4A

     D AUC5            S              4A

     D AUC6            S              4A

     D AUC7            S              4A

     D AUC8            S              4A

     D AUC9            S              4A

     D AUC10           S              4A

     D*

     D X               S              3P 0

     D Y               S              3P 0

     D NUM@            S              3  0

     D SIZE            S             15  5

     D Limit_UFP       S              9A

     D Limit_GROSSf    S             11A

     D Limit_GROSSt    S             11A

     D LIMITSTATE      S              4A

     D LIMITCITY       S             30A

     D LIMITTYPE       S              1A

     D*

     D LUFP            S              9A

     D LGROSSf         S             11A

     D LGROSSt         S             11A

     D LSTATE          S              4A

     D LCITY           S             30A

     D LFTYPE          S              1A

     D*

     D CMD             S             80A   DIM(8)  INZ(' ')

     D*

     D CMD1            C                   'CLRPFM QTEMP/ZZMAFDLRU'

     D CMD2            C                   'CLRPFM QTEMP/ZZMAFDLR1'

     D CMD3            C                   'CLRPFM QTEMP/ZZMAFDLR2'

     D CMD4            C                   'CLRPFM QTEMP/ZZMAFDLR3'

     D CMD5            C                   'CLRPFM QTEMP/ZZMAFDLRP'

     D*

     D OVR1            C                   'OVRDBF ZZMAFDLRU QTEMP/ZZMAFDLRU'

     D OVR2            C                   'OVRDBF ZZMAFDLR1 QTEMP/ZZMAFDLR1'

     D OVR3            C                   'OVRDBF ZZMAFDLR2 QTEMP/ZZMAFDLR2'

     D OVR4            C                   'OVRDBF ZZMAFDLR3 QTEMP/ZZMAFDLR3'

     D OVR5            C                   'OVRDBF ZZMAFDLRP QTEMP/ZZMAFDLRP'

     D*

     D*-------------------------------------------------------------------------

     D* Program Status Data Structure

     D*-------------------------------------------------------------------------

     DPSDS            SDS

     D PGMNAM            *PROC

     D PARMS             *PARMS

     D MSGID                  40     46

     D MSGTXT                 91    170

     D JOBNAM                244    253

     D USRPRF                254    263

     D JOBNBR                264    269  0

     D*

     C/EJECT

     C*

     C*

     ‚**************************************************************************

     ‚* extract UNITS FLOORED from master transaction file PFMSTTRN            *

     ‚**************************************************************************

     C*

     C                   IF        ALL = 'Y'

     C*

     C/EXEC SQL

     C+  INSERT INTO QTEMP/ZZMAFDLR1

     C+  SELECT SBUYER, SAUCI, (0)CARS, (0)GROSS,

     C+     COUNT(*)UFP, SUM(SSLEPR)UFP$, (0)ARB#, (0)NSF#,

     C+     SHWPD, SFLRTY

     C+     FROM PFMSTTRN

     C+     WHERE  SDTESL BETWEEN :Fdate AND :Tdate

     C+            AND SCODE='SF' AND SHWPD='G'

     C+     GROUP BY SBUYER, SAUCI, SHWPD, SFLRTY

     C+     ORDER BY SBUYER, SAUCI, SHWPD, SFLRTY

     C/END-EXEC

     C*

     C                   else

     C*

     C/EXEC SQL

     C+  INSERT INTO QTEMP/ZZMAFDLR1

     C+  SELECT SBUYER, SAUCI, (0)CARS, (0)GROSS,

     C+     COUNT(*)UFP, SUM(SSLEPR)UFP$, (0)ARB#, (0)NSF#,

     C+     SHWPD, SFLRTY

     C+     FROM PFMSTTRN

     C+     WHERE  SDTESL BETWEEN :Fdate AND :Tdate

     C+            AND SCODE='SF' AND SHWPD='G'

     C+            AND (SAUCI = :AUC1 or SAUCI = :AUC2 or

     C+                 SAUCI = :AUC3 or SAUCI = :AUC4 or

     C+                 SAUCI = :AUC5 or SAUCI = :AUC6 or

     C+                 SAUCI = :AUC7 or SAUCI = :AUC8 or

     C+                 SAUCI = :AUC9 or SAUCI = :AUC10)

     C+     GROUP BY SBUYER, SAUCI, SHWPD, SFLRTY

     C+     ORDER BY SBUYER, SAUCI, SHWPD, SFLRTY

     C/END-EXEC

     C*

     C                   EndIF

     C*

     ‚**************************************************************************

     ‚* join work file with FLOOR PLAN Description file

     ‚**************************************************************************

     C*

     C                   IF        LIMITTYPE = *blanks

     C*

     C/EXEC SQL

     C+  INSERT INTO QTEMP/ZZMAFDLRP

     C+  SELECT SBUYER, SAUCI, CARS, GROSS, UFP, UFP$, ARB#, NSF#,

     C+     CASE WHEN FCODE IS NULL THEN SHWPD ELSE FCODE END FCODE,

     C+     CASE WHEN FTYPE IS NULL THEN ' ' ELSE FTYPE END FTYPE,

     C+     CASE WHEN FPLAN IS NULL THEN 'Other' ELSE FPLAN END FPLAN

     C+  FROM QTEMP/ZZMAFDLR1

     C+  LEFT JOIN PFFLRPLN ON SHWPD=FCODE AND SFLRTY=FTYPE

     C+  WHERE RPTFLG<>'N'

     C/END-EXEC

     C*

     C                   else

     C*

     C/EXEC SQL

     C+  INSERT INTO QTEMP/ZZMAFDLRP

     C+  SELECT SBUYER, SAUCI, CARS, GROSS, UFP, UFP$, ARB#, NSF#,

     C+     CASE WHEN FCODE IS NULL THEN SHWPD ELSE FCODE END FCODE,

     C+     CASE WHEN FTYPE IS NULL THEN ' ' ELSE FTYPE END FTYPE,

     C+     CASE WHEN FPLAN IS NULL THEN 'Other' ELSE FPLAN END FPLAN

     C+  FROM QTEMP/ZZMAFDLR1

     C+  LEFT JOIN PFFLRPLN ON SHWPD=FCODE AND SFLRTY=FTYPE

     C+  WHERE SFLRTY=:LIMITTYPE

     C/END-EXEC

     C*

     C                   EndIF

     C*

     ‚**************************************************************************

     ‚* extract TOTAL VOLUME from master transaction file PFMSTTRN             *

     ‚**************************************************************************

     C*

     C                   IF        ALL = 'Y'

     C*

     C/EXEC SQL

     C+  INSERT INTO QTEMP/ZZMAFDLRP

     C+  SELECT SBUYER, SAUCI, COUNT(*)CARS, SUM(SSLEPR)GROSS,

     C+    (0)UFP, (0)UFP$,

     C+    SUM(CASE WHEN SDTEAB<>0 THEN 1 ELSE 0 END) ARB#,

     C+    SUM(CASE WHEN SDTERT<>0 THEN 1 ELSE 0 END) NSF#,

     C+    SHWPD, SFLRTY, ('TOTAL VOLUME')FPLAN

     C+    FROM PFMSTTRN

     C+    WHERE (SDTESL BETWEEN :Fdate AND :Tdate

     C+           AND SCODE='SF'

     C+           AND SBUYER<>0)

     C+     GROUP BY SBUYER, SAUCI, SHWPD, SFLRTY

     C+     ORDER BY SBUYER, SAUCI, SHWPD, SFLRTY

     C/END-EXEC

     C*

     C                   else

     C*

     C/EXEC SQL

     C+  INSERT INTO QTEMP/ZZMAFDLRP

     C+  SELECT SBUYER, SAUCI, COUNT(*)CARS, SUM(SSLEPR)GROSS,

     C+    (0)UFP, (0)UFP$,

     C+    SUM(CASE WHEN SDTEAB<>0 THEN 1 ELSE 0 END) ARB#,

     C+    SUM(CASE WHEN SDTERT<>0 THEN 1 ELSE 0 END) NSF#,

     C+    SHWPD, SFLRTY, ('TOTAL VOLUME')FPLAN

     C+    FROM PFMSTTRN

     C+    WHERE (SDTESL BETWEEN :Fdate AND :Tdate

     C+           AND SCODE='SF'

     C+           AND SBUYER<>0)

     C+           AND (SAUCI = :AUC1 or SAUCI = :AUC2 or

     C+                SAUCI = :AUC3 or SAUCI = :AUC4 or

     C+                SAUCI = :AUC5 or SAUCI = :AUC6 or

     C+                SAUCI = :AUC7 or SAUCI = :AUC8 or

     C+                SAUCI = :AUC9 or SAUCI = :AUC10)

     C+     GROUP BY SBUYER, SAUCI, SHWPD, SFLRTY

     C+     ORDER BY SBUYER, SAUCI, SHWPD, SFLRTY

     C/END-EXEC

     C*

     C                   EndIF

     C*

     ‚**************************************************************************

     ‚* joins to get UNIVERSAL# and registration date                          *

     ‚**************************************************************************

     C*

     C/EXEC SQL

     C+ INSERT INTO QTEMP/ZZMAFDLRU

     C+  SELECT XUNIV#, SBUYER, SAUCI, CARS, GROSS,

     C+    UFP, UFP$, ARB#, NSF#, DREGDT,

     C+    CASE WHEN DGROUP='FLR' THEN 'Y' ELSE 'N' END MAFFLG

     C+  FROM QTEMP/ZZMAFDLRP, PFDLRALL

     C+    LEFT JOIN PFMSTXREF ON SAUCI=XAUCID AND SBUYER=XADLR#

     C+    WHERE SAUCI=DAUCID AND SBUYER=DDLR# AND DSIG#=0

     C+  ORDER BY XUNIV#

     C/END-EXEC

     C*

     ‚**************************************************************************

     ‚* Summarize by dealer/auction & join PFDLRALL to get registration date   *

     ‚**************************************************************************

     C*

     C/EXEC SQL

     C+ INSERT INTO QTEMP/ZZMAFDLR2

     C+ SELECT XUNIV#, SAUCI, MIN(DREGDT) DREGDT,

     C+        SUM(CARS) CARS, SUM(GROSS) GROSS,

     C+        SUM(UFP) UFP, SUM(UFP$) UFP$,

     C+        SUM(ARB#) ARB#, SUM(NSF#) NSF#

     C+ FROM QTEMP/ZZMAFDLRU

     C+ WHERE MAFFLG<>'Y'

     C+        GROUP BY XUNIV#, SAUCI

     C+        ORDER BY XUNIV#, SAUCI

     C/END-EXEC

     C*

     ‚**************************************************************************

     ‚* join summarized file to PFUDLR to get address information              *

     ‚**************************************************************************

     C*

     C/EXEC SQL

     C+ INSERT INTO QTEMP/ZZMAFDLR3

     C+ SELECT UDPROV, UDCITY, XUNIV#, SAUCI, CARS,

     C+        GROSS, UFP, UFP$, ARB#, NSF#, DREGDT, UDDLR#U,

     C+        UDDEALN, UDADDR, UDDADD2, UDZIP, UDCNTRY,

     C+        UDDTEL1, UDDTEL2, UDDTEL3

     C+   FROM QTEMP/ZZMAFDLR2, PFUDLR

     C+        WHERE XUNIV#=UDDLR#U

     C+        ORDER BY UDPROV, UDCITY, XUNIV#, SAUCI

     C/END-EXEC

     C*

     C* END-OF-PROGRAM                                                         *

     C*

     C                   Eval      *INLR = *ON

     C                   Return

     C/EJECT

     C*

     ‚**************************************************************************

     ‚*                                                                        *

     ‚*                     Initialization subroutine                          *

     ‚*                                                                        *

     ‚**************************************************************************

     C*

     C     *INZSR        BEGSR

     C*

     C     *ENTRY        Plist

01   C                   Parm                    FROM

02   C                   Parm                    THRU

03   C                   Parm                    ALL

04   C                   Parm                    A1

05   C                   Parm                    A2

06   C                   Parm                    A3

07   C                   Parm                    A4

08   C                   Parm                    A5

09   C                   Parm                    A6

10   C                   Parm                    A7

11   C                   Parm                    A8

12   C                   Parm                    A9

13   C                   Parm                    A0

14   C                   Parm                    LIMITSTATE

15   C                   Parm                    LIMITCITY

16   C                   Parm                    Limit_UFP

17   C                   Parm                    Limit_GROSSf

18   C                   Parm                    Limit_GROSSt

19   C                   Parm                    LIMITTYPE

     C*

     C     PLIST1        PLIST

01   C                   Parm                    FROM

02   C                   Parm                    THRU

03   C                   Parm                    ALL

04   C                   Parm                    AUC1

05   C                   Parm                    AUC2

06   C                   Parm                    AUC3

07   C                   Parm                    AUC4

08   C                   Parm                    AUC5

09   C                   Parm                    AUC6

10   C                   Parm                    AUC7

11   C                   Parm                    AUC8

12   C                   Parm                    AUC9

13   C                   Parm                    AUC10

14   C                   Parm                    LSTATE

15   C                   Parm                    LCITY

16   C                   Parm                    LUFP

17   C                   Parm                    LGROSSF

18   C                   Parm                    LGROSST

19   C                   Parm                    LFTYPE

     C*

     C                   MOVE      FROM          FDATE

     C                   MOVE      THRU          TDATE

     C

     C*

     C                   IF        %parms >= 4

     C                   EVAL      AUC1    = A1

     C                   END

     C*

     C                   IF        %parms >= 5

     C                   EVAL      AUC2    = A2

     C                   END

     C*

     C                   IF        %parms >= 6

     C                   EVAL      AUC3    = A3

     C                   END

     C*

     C                   IF        %parms >= 7

     C                   EVAL      AUC4    = A4

     C                   END

     C*

     C                   IF        %parms >= 8

     C                   EVAL      AUC5    = A5

     C                   END

     C*

     C                   IF        %parms >= 9

     C                   EVAL      AUC6    = A6

     C                   END

     C*

     C                   IF        %parms >= 10

     C                   EVAL      AUC7    = A7

     C                   END

     C*

     C                   IF        %parms >= 11

     C                   EVAL      AUC8    = A8

     C                   END

     C*

     C                   IF        %parms >= 12

     C                   EVAL      AUC9    = A9

     C                   END

     C*

     C                   IF        %parms >= 13

     C                   EVAL      AUC10   = A0

     C                   END

     C*

     C                   IF        %parms >= 14

     C                   EVAL      LSTATE = LIMITSTATE

     C                   END

     C*

     C                   IF        %parms >= 15

     C                   EVAL      LCITY = LIMITCITY

     C                   END

     C*

     C                   IF        %parms >= 16

     C                   EVAL      LUFP = Limit_UFP

     C                   END

     C*

     C                   IF        %parms >= 17

     C                   EVAL      LGROSSF = Limit_GROSSf

     C                   END

     C*

     C                   IF        %parms >= 18

     C                   EVAL      LGROSST = Limit_GROSSt

     C                   END

     C*

     C                   IF        %parms >= 19

     C                   EVAL      LFTYPE = LIMITTYPE

     C                   END

     C*

     C                   MOVE      FROM          Fdate

     C                   MOVE      THRU          Tdate

     C*

     C* future use, add to parm list if this becomes a requirement

     C*

     C                   MOVE      'N'           MAFS_Only

     C                   MOVE      'N'           Non_MAFS_Only

     C*

     ‚**************************************************************************

     ‚* create work files

     ‚**************************************************************************

     C*

     ‚* ZZMAFDLR1, contains detail transactions from PFMSTTRN

     C/EXEC SQL

     C+ CREATE TABLE QTEMP/ZZMAFDLR1

     C+  (SBUYER   NUMERIC(7),

     C+   SAUCI    CHARACTER(4)  NOT NULL WITH DEFAULT,

     C+   CARS     NUMERIC(9)    NOT NULL WITH DEFAULT,

     C+   GROSS    NUMERIC(15)   NOT NULL WITH DEFAULT,

     C+   UFP      NUMERIC(9)    NOT NULL WITH DEFAULT,

     C+   UFP$     NUMERIC(15)   NOT NULL WITH DEFAULT,

     C+   ARB#     NUMERIC(9)    NOT NULL WITH DEFAULT,

     C+   NSF#     NUMERIC(9)    NOT NULL WITH DEFAULT,

     C+   SHWPD    CHARACTER(1)  NOT NULL WITH DEFAULT,

     C+   SFLRTY   CHARACTER(1)  NOT NULL WITH DEFAULT)

     C/END-EXEC

     C*

     ‚* ZZMAFDLRP, work file extract with floor plan description added

     C/EXEC SQL

     C+ CREATE TABLE QTEMP/ZZMAFDLRP

     C+  (SBUYER   NUMERIC(7),

     C+   SAUCI    CHARACTER(4)  NOT NULL WITH DEFAULT,

     C+   CARS     NUMERIC(9)    NOT NULL WITH DEFAULT,

     C+   GROSS    NUMERIC(15)   NOT NULL WITH DEFAULT,

     C+   UFP      NUMERIC(9)    NOT NULL WITH DEFAULT,

     C+   UFP$     NUMERIC(15)   NOT NULL WITH DEFAULT,

     C+   ARB#     NUMERIC(9)    NOT NULL WITH DEFAULT,

     C+   NSF#     NUMERIC(9)    NOT NULL WITH DEFAULT,

     C+   FCODE    CHARACTER(1)  NOT NULL WITH DEFAULT,

     C+   FTYPE    CHARACTER(1)  NOT NULL WITH DEFAULT,

     C+   FPLAN    CHARACTER(50) NOT NULL WITH DEFAULT)

     C/END-EXEC

     C*

     ‚* ZZMAFDLR2, summarized data from work file universal dealer number

     C/EXEC SQL

     C+ CREATE TABLE QTEMP/ZZMAFDLR2

     C+  (XUNIV#   NUMERIC(7),

     C+   SAUCI    CHARACTER(4)  NOT NULL WITH DEFAULT,

     C+   DREGDT   NUMERIC(8)    NOT NULL WITH DEFAULT,

     C+   CARS     NUMERIC(9)    NOT NULL WITH DEFAULT,

     C+   GROSS    NUMERIC(15)   NOT NULL WITH DEFAULT,

     C+   UFP      NUMERIC(9)    NOT NULL WITH DEFAULT,

     C+   UFP$     NUMERIC(15)   NOT NULL WITH DEFAULT,

     C+   ARB#     NUMERIC(9)    NOT NULL WITH DEFAULT,

     C+   NSF#     NUMERIC(9)    NOT NULL WITH DEFAULT)

     C/END-EXEC

     C*

     C*

     ‚* ZZMAFDLR3, summarized data from work file universal dealer number

     C/EXEC SQL

     C+ CREATE TABLE QTEMP/ZZMAFDLR3

     C+  (UDPROV   CHARACTER(4)    NOT NULL WITH DEFAULT,

     C+   UDCITY   CHARACTER(20)   NOT NULL WITH DEFAULT,

     C+   XUNIV#   NUMERIC(7)      NOT NULL WITH DEFAULT,

     C+   SAUCI    CHARACTER(4)    NOT NULL WITH DEFAULT,

     C+   CARS     NUMERIC(9)      NOT NULL WITH DEFAULT,

     C+   GROSS    NUMERIC(15)     NOT NULL WITH DEFAULT,

     C+   UFP      NUMERIC(9)      NOT NULL WITH DEFAULT,

     C+   UFP$     NUMERIC(15)     NOT NULL WITH DEFAULT,

     C+   ARB#     NUMERIC(9)      NOT NULL WITH DEFAULT,

     C+   NSF#     NUMERIC(9)      NOT NULL WITH DEFAULT,

     C+   DREGDT   NUMERIC(8)      NOT NULL WITH DEFAULT,

     C+   UDDLR#U  NUMERIC(7)      NOT NULL WITH DEFAULT,

     C+   UDDEALN  CHARACTER(48)   NOT NULL WITH DEFAULT,

     C+   UDADDR   CHARACTER(40)   NOT NULL WITH DEFAULT,

     C+   UDDADD2  CHARACTER(40)   NOT NULL WITH DEFAULT,

     C+   UDZIP    CHARACTER(9)    NOT NULL WITH DEFAULT,

     C+   UDCNTRY  CHARACTER(20)   NOT NULL WITH DEFAULT,

     C+   UDDTEL1  NUMERIC(3)      NOT NULL WITH DEFAULT,

     C+   UDDTEL2  NUMERIC(3)      NOT NULL WITH DEFAULT,

     C+   UDDTEL3  NUMERIC(4)      NOT NULL WITH DEFAULT)

     C/END-EXEC

     C*

     ‚* ZZMAFDLRU, contains work file data joined to universal dealer number

     C/EXEC SQL

     C+ CREATE TABLE QTEMP/ZZMAFDLRU

     C+  (XUNIV#   NUMERIC(7),

     C+   SBUYER   NUMERIC(7)    NOT NULL WITH DEFAULT,

     C+   SAUCI    CHARACTER(4)  NOT NULL WITH DEFAULT,

     C+   CARS     NUMERIC(9)    NOT NULL WITH DEFAULT,

     C+   GROSS    NUMERIC(15)   NOT NULL WITH DEFAULT,

     C+   UFP      NUMERIC(9)    NOT NULL WITH DEFAULT,

     C+   UFP$     NUMERIC(15)   NOT NULL WITH DEFAULT,

     C+   ARB#     NUMERIC(9)    NOT NULL WITH DEFAULT,

     C+   NSF#     NUMERIC(9)    NOT NULL WITH DEFAULT,

     C+   DREGDT   NUMERIC(8)    NOT NULL WITH DEFAULT,

     C+   MAFFLG   CHARACTER(1)  NOT NULL WITH DEFAULT)

     C/END-EXEC

     C*

     C/EJECT

     C*

     ‚**************************************************************************

     ‚* clear work files and override database file to QTEMP version           *

     ‚**************************************************************************

     C*

     C* CLRPFM work files

     C*

     C                   EVAL      CMD(1) = CMD1

     C                   EVAL      CMD(2) = CMD2

     C                   EVAL      CMD(3) = CMD3

     C                   EVAL      CMD(4) = CMD4

     C                   EVAL      CMD(5) = CMD5

     C*

     C     1             DO        5             X

     C                   EVAL      Command = CMD(X)

     C                   CALL      'QCMDEXC'

     C                   PARM                    Command

     C                   PARM      80            SIZE

     C                   EndDO

     C*

     C* OVRDBF work files

     C*

     C                   EVAL      CMD(1) = OVR1

     C                   EVAL      CMD(2) = OVR2

     C                   EVAL      CMD(3) = OVR3

     C                   EVAL      CMD(4) = OVR4

     C                   EVAL      CMD(5) = OVR5

     C*

     C     1             DO        5             X

     C                   EVAL      Command = CMD(X)

     C                   CALL      'QCMDEXC'

     C                   PARM                    Command

     C                   PARM      80            SIZE

     C                   EndDO

     C*

     C* end of initialization subroutine

     C*

     C                   ENDSR

     C*

     C/EJECT

     C*

Interactive RPG/IV
Example of RPG/IV interactive subfile program

š   š ********************************************************************

š   š *  Program name.......: IS3010R                                    *

š   š *  Program description: Map CONVERTER UPLOAD file to CVUPGIPG      *

š   š *  Date written.......: 11/30/2004   Tony P. Davis                 *

š   š *------------------------------------------------------------------*

š   š *  NOTE:  Library OUTFILES must be in your library list in order   *

š   š *         to compile this program. This is necessary for files     *

š   š *         CVUPGIDG and EQPMSTR.                                    *

š   š *------------------------------------------------------------------*

š   š *  Indicators:                                                     *

š   š *  -----------                                                     *

š   š *  IN01 - command key HELP                                         *

š   š *  IN03 - command key EXIT                                         *

š   š *  IN05 - command key SET POSITION OF MAC ADDRESS                  *

š   š *  IN06 - command key SET POSITION OF SERIAL NUMBER                *

š   š *  IN10 - command key CONTINUE UPDATE PROCESS                      *

š   š *  IN12 - command key CANCEL or RETURN to previous screen          *

š   š *  IN17 - command key DISPLAY TOP OF SUBFILE                       *

š   š *  IN18 - command key DISPLAY BOTTOM OF SUBFILE                    *

š   š *  IN19 - command key MOVE WINDOW/POSITION LEFT                    *

š   š *  IN20 - command key MOVE WINDOW/POSITION RIGHT                   *

š   š *  IN23 - command key DELETE record in error (one or all)          *

š   š *  IN39 - VLDCMDKEY                                                *

š   š *  IN61 - ROLLUP                                                   *

š   š *  IN63 - SFLDSPCTL (N63=SFLCLR)                                   *

š   š *  IN64 - SFLDSP                                                   *

š   š *  IN66 - SFLINZ                                                   *

š   š *  IN68 - SFLEND(*MORE)                                            *

š   š *  IN71 - Display F23=Delete All instead of F23=Delete on err scrn *

š   š *  IN72 - Disallows F05 again if errors are already loaded/display *

š   š *  IN73 - Disallows F23 if no errors were found                    *

š   š *  IN74 - File EQPMSTR is also being built                         *

š   š *  IN84 - F23 not allowed unless cursor is within subfile range    *

š   š *  IN85 - F23 not allowed unless record cursor is on is in error   *

š   š *  IN86 - Warning message the errors may exist in input file       *

š   š *  IN88 - Dislay MAC address in reverse image if it is error       *

š   š *  IN89 - Dislay SERIAL number in reverse image if it is error     *

š   š *  IN90 - Error if F10 attempted and NO DATA is in file            *

š   š *  IN92 - End of record is already shown (on using F20)            *

š   š *  IN93 - Error if user attempts F5 or F6 without positioning csr  *

š   š *  IN94 - Attempt to use F5 not valid if cursor not in position    *

š   š *  IN95 - Error if F10 attempted with first setting start/end pos  *

š   š *  IN96 - Error if from or to positions are not valid              *

š   š *  IN97 - Error if from or to positions overlap                    *

š   š *------------------------------------------------------------------*

š   š *  Program maintenance information:                                *

š   š *  -------------------------------                                 *

š   š *  Fix Date  Inits   Description                                   *

š   š ********************************************************************

 

    FGENEQP1   UF   E             DISK    INFDS(FILE01DS) INFSR(*PSSR)

    FAGLOCNM0  IF   E           K DISK

    FEQPMSTR   IF A E             DISK    INFDS(FILE03DS) INFSR(*PSSR) USROPN

    FCVUPGIDG  IF A E             DISK    INFDS(FILE02DS) INFSR(*PSSR) USROPN

    F                                     RENAME(CVUPGIDG:CVREC)

    FIS3010D   CF   E             WORKSTN SFILE(SFLDATA:RRN01)

    F                                     SFILE(SFLDATA2:RRN02)

    F                                     INFDS(FILEWKDS)

 

š    D* Miscellaneous definiations

    D rulers          S             78    DIM(3) CTDATA

    D window          S              3S 0

    D record_count    S             11S 0

    D delete_count    S             11S 0

    D x               S             11S 0

    D pos             S             11S 0

    D len             S             11S 0

    D clear_inds      S              9A   INZ('000000000')                     error inds (90-98)

    D rollup1_val     S              9S 0 INZ(14)                              SFLROLVAL

    D skipped         S              1A

    D copy_complete   S              1A

    D copy_cancel     S              1A

    D Save_Header     S            183A

    D arg             S              1A

    D string          S             32A

    D returncode      S             10A

    D valerrors       S              1A

    D parseerrors     S              1A

    D parseerror      S              1A

    D SQL_statement   S             80A

    D SQL_file        S             10A

    D keys01          S             36A   INZ('F3=Exit F5=SQL F10=Start -

    D                                     F12=Cancel')

    D keys02          S             36A   INZ('Upload to CONVERTER FI-

    D                                      in progress')

    D xxfiled         S             10A

    D xxlibld         S             10A

 

š    D* COX Extended Programs Control Data Area (location)

    D EXTDTA          DS           256

    D  SITEID               254    256

 

š    D* Speical characters array list

    D spec_chars_x    S              7S 0 INZ(29)

    D spec_chars_ary  S              1A   DIM(29)

    D spec_chars      S             29A   INZ('!@#$%’&*()_-<>?/:;"-

    D                                     ,_¬}¦|\~`')

 

š    D* Output format for file GENEQP1

    D outrecord       DS

    D  out_rectype            1      1

    D  out_macaddres         39     62

    D  out_srlnumber         63     93

 

š    D* INFDS for file GENEQP1

    D file01ds        DS

    D  filestat01       *STATUS

    D  filerreclg           125    126B 0

    D  filercdn01           156    159B 0

    D  filename01            83     92

    D  liblname01            93    102

    D  filerelr01           397    400B 0

 

š    D* INFDS for file CVUPGIDG

    D file02ds        DS

    D  filestat02       *STATUS

    D  filercdn02           156    159B 0

    D  filename02            83     92

    D  liblname02            93    102

 

š    D* INFDS for file EQPMSTR

    D file03ds        DS

    D  filestat03       *STATUS

    D  filercdn03           156    159B 0

    D  filename03            83     92

    D  liblname03            93    102

 

š    D* INFDS for file workstation file

    D filewkds        DS

    D  filewk_status    *STATUS

    D  filewk_flags         367    368

    D  filewk_aidkey        369    369

    D  filewk_csrloc        370    371

    D  filewk_dtalen        372    375B 0

    D  filewk_relrec        376    377B 0

    D  filewk_minrrn        378    379B 0

    D  filewk_nbrrec        380    381B 0

    D  filewk_wincsr        382    383

    D  filewk_majcod        401    402

    D  filewk_mincod        403    404

 

š    D* QCMDEXC related variables

    D CMD1            C                   'CLRPFM *LIBL/CVUPGIDG'

    D CMD2            C                   'CLRPFM *LIBL/EQPMSTR'

    D command         S             80A   INZ(' ')

    D size            S             15  5

 

š    D* PSSR and other variables related to error routine

    D$PSSR1           S              1

    DPSSA_FILENAME    S             10

    DPSSA_LIBLNAME    S             10

    DPSSA_FILESTAT    S              5

    DPSSA            SDS

    D  PGMNAM                 1     10

    D  PGMSTS                11     15  0                                      Return code

    D  PGMLIB                81     90                                         Program libl

    D  PGMEXD                91    170                                         Exception data

    D  PGEFIL               175    184                                         Name of file

    D  PGMJBN               244    253                                         Job name

    D  USRNAM               254    263                                         User name

    D  PGMJNR               264    269  0                                      Job number

š    D*

 

š    I* Data area saves values in QTEMP for user

    DIS3010VALS      UDS          1000

    D  SV_MAC_FRPOS           1      5                                         From MAC

    D  SV_MAC_TOPOS           6     10                                         To   MAC

    D  SV_SRL_FRPOS          11     15                                         From SERIAL#

    D  SV_SRL_TOPOS          16     20                                         To   SERIAL#

 

š    I* redefine input field name for field in file CVUPGIDG

    ICVREC

    I              CVUPGIDG                    OUT_RECORD

 

š   š *************************************************************************/

š   š *                         MAIN PROGRAM START                            */

š   š *************************************************************************/

 

‚b01€C                   dou       *in03       = *on

‚ 01€C                   write     prompt                                       ˆwrt prompt        €

‚ 01€C                   write     keys                                         ˆwrt keys          €

‚ 01€C                   read      keys

‚ 01€C                   read      IS3010D

‚ 01€C                   movea     clear_inds    *in(90)                        error inds 90 - 98

b02€C     *in01         caseq     *on           Help

 02€C     *in03         caseq     *on           Exit

 02€C     *in05         caseq     *on           Set_pos_mac

 02€C     *in06         caseq     *on           Set_pos_srl

 02€C     *in10         caseq     *on           Begin_mapping

 02€C     *in17         caseq     *on           Roll_to_top

 02€C     *in18         caseq     *on           Roll_to_bot

 02€C     *in19         caseq     *on           Toggle_left

 02€C     *in20         caseq     *on           Toggle_right

 02€C     *in39         caseq     *off          Enter

 02€C     *in61         caseq     *on           Rollup

 02€C                   endcs

e02€C                   enddo

 

š   š *************************************************************************/

š   š *                       Function key subroutines                        */

š   š *************************************************************************/

 

š   š * Exit program

‚ 01€C     exit          begsr                                                  ‚beg exit          €

‚ 01€C                   call      'IS3010C2'                                   deallocate CVUPGIDG

‚ 01€C                   parm                    RETURNCODE

‚ 01€C                   move      *on           *inlr

‚ 01€C                   movel     MAC_FRPOS     SV_MAC_FRPOS

‚ 01€C                   movel     MAC_TOPOS     SV_MAC_TOPOS

‚ 01€C                   movel     SRL_FRPOS     SV_SRL_FRPOS

‚ 01€C                   movel     SRL_TOPOS     SV_SRL_TOPOS

‚ 01€C                   out       IS3010VALS

‚ 01€C                   return

‚ 01€C                   endsr                                                  ‚end exit          €

 

š   š * Enter key pressed

‚ 01€C     enter         begsr                                                  ‚beg enter         €

b02€C                   if        BUILD_EQPM    = *blanks

 02€C                   eval      BUILD_EQPM    = 'N'

e02€C                   end

b02€C                   if        IGNORE_HDR    = *blanks

 02€C                   eval      IGNORE_HDR    = 'N'

e02€C                   end

‚ 01€C                   exsr      SUB_setcolumn

‚ 01€C                   exsr      SUB_validate

‚ 01€C                   eval      rrn01         = rrn01lin

‚ 01€C                   endsr                                                  ‚end enter         €

 

š   š * F01 = HELP

‚ 01€C     Help          begsr                                                  ‚beg Help          €

‚ 01€C                   move      row           PMLIN

‚ 01€C                   move      col           PMPOS

b02€C                   if        row           = 23 and

 02€C                             CFD           = *blanks

 02€C                   eval      CFD           = '*KEYS'                      Help for CF keys

e02€C                   endif

‚ 01€C                   call      'IS3010HR'

‚ 01€C                   parm                    pgmnam

‚ 01€C                   parm                    CFD

‚ 01€C                   parm                    PMLIN             2

‚ 01€C                   parm                    PMPOS             3

‚ 01€C                   endsr                                                  ‚end Help          €

 

š   š * F05 = set position of MAC address

‚ 01€C     Set_pos_mac   begsr                                                  ‚beg Set_pos_mac   €

 

b02€C                   if        row           < 7 or row > 21

 02€C                   eval      *in93         = *on

l02€C                   else

 

š   š * Determine from and to positions (assume 32 character length)

 02€C                   select

 02€C                   when      window        = 1

 02€C                   eval      MAC_FRPOS     = col - 2

 02€C                   eval      MAC_TOPOS     = MAC_FRPOS + 32

 02€C                   when      window        = 2

 02€C                   eval      MAC_FRPOS     = col + 78 - 2

 02€C                   eval      MAC_TOPOS     = MAC_FRPOS + 32

 02€C                   when      window        = 3

 02€C                   eval      MAC_FRPOS     = col + 157 - 2

 02€C                   eval      MAC_TOPOS     = MAC_FRPOS + 32

 02€C                   endsl

 

š   š * Look for a comma and if found, change length assuming this is a CSV file

b03€C     MAC_FRPOS     do        filerreclg    x

šb04€C                   if        %subst(RECDATA:x:1) = ','

š 04€C                   eval      MAC_TOPOS     = x - 1

š 04€C                   leave                                                  ˆgo                €

še04€C                   endif

e03€C                   enddo

 

e02€C                   endif

‚ 01€C                   eval      rrn01         = rrn01lin

‚ 01€C                   endsr                                                  ‚end Set_pos_mac   €

 

š   š * F06 = set position of SERIAL NUMBER

‚ 01€C     Set_pos_srl   begsr                                                  ‚beg Set_pos_srl   €

 

b02€C                   if        row           < 7 or row > 21

 02€C                   eval      *in94         = *on

l02€C                   else

 

š   š * Determine from and to positions (assume 32 character length)

 02€C                   select

 02€C                   when      window        = 1

 02€C                   eval      SRL_FRPOS     = COL - 2

 02€C                   eval      SRL_TOPOS     = SRL_FRPOS + 32

 02€C                   when      window        = 2

 02€C                   eval      SRL_FRPOS     = COL + 78 - 2

 02€C                   eval      SRL_TOPOS     = SRL_FRPOS + 32

 02€C                   when      window        = 3

 02€C                   eval      SRL_FRPOS     = COL + 157 - 2

 02€C                   eval      SRL_TOPOS     = SRL_FRPOS + 32

 02€C                   endsl

 

š   š * Look for a comma and if found, change length assuming this is a CSV file

b03€C     SRL_FRPOS     do        filerreclg    x

šb04€C                   if        %subst(RECDATA:x:1) = ','

š 04€C                   eval      SRL_TOPOS     = x - 1

š 04€C                   leave                                                  ˆgo                €

še04€C                   endif

e03€C                   enddo

 

e02€C                   endif

‚ 01€C                   eval      rrn01         = rrn01lin

‚ 01€C                   endsr                                                  ‚end Set_pos_srl   €

 

š   š * F10 = start map/parse process

‚ 01€C     Begin_mapping begsr                                                  ‚beg Begin_mapping €

‚ 01€C                   eval      continue      = *blanks

‚ 01€C                   exsr      SUB_validate

b02€C                   if        valerrors     <> 'Y'

 02€C                   exsr      SUB_mapdata

e02€C                   endif

‚ 01€C                   endsr                                                  ‚end Begin_mapping €

 

š   š * CF17 = Display top of subfile

‚ 01€C     Roll_to_top   begsr                                                  ‚beg Roll_to_top   €

‚ 01€C                   eval      RRN01         = 1

‚ 01€C                   endsr                                                  ‚end Roll_to_top   €

 

š   š * CF18 = Display bottom of subfile (load all records)

‚ 01€C     Roll_to_bot   begsr                                                  ‚beg Roll_to_bot   €

‚ 01€C                   eval      rollup1_val   = filercdn01

‚ 01€C                   exsr      Rollup

‚ 01€C                   reset                   rollup1_val

‚ 01€C                   endsr                                                  ‚end Roll_to_bot   €

 

š   š * CF19 = Toggle subfile LEFT

‚ 01€C     Toggle_left   begsr                                                  ‚beg Toggle_left   €

b02€C                   if        window        = 1

 02€C                   eval      *in91         = *on                          start already shown

l02€C                   else

 02€C                   eval      window        = window - 1

 02€C                   exsr      Update_sub

e02€C                   endif

‚ 01€C                   eval      rrn01         = rrn01lin

‚ 01€C                   endsr                                                  ‚end Toggle_left   €

 

š   š * CF20 = Toggle subfile RIGHT

‚ 01€C     Toggle_right  begsr                                                  ‚beg Toggle_right  €

b02€C                   if        window        = 3

 02€C                   eval      *in92         = *on                          end already shown

l02€C                   else

 02€C                   eval      window        = window + 1

 02€C                   exsr      Update_sub

e02€C                   endif

‚ 01€C                   eval      rrn01         = rrn01lin

‚ 01€C                   endsr                                                  ‚end Toggle_right  €

 

š   š *-----------------------------------------------------------------------*/

š   š * SUBROUTINE - update subfile when toggle left or right.                */

š   š *-----------------------------------------------------------------------*/

‚ 01€C     Update_sub    begsr                                                  ‚beg Update_sub    €

b02€C     1             do        srn01         x

 02€C     x             chain     sfldata                            99

b03€C                   if        *in99       = *off

 03€C                   select

 03€C                   when      window        = 1

 03€C                   eval      stextl        = %subst(RECDATA:1:78)

 03€C                   when      window        = 2

 03€C                   eval      stextl        = %subst(RECDATA:79:78)

 03€C                   when      window        = 3

 03€C                   eval      stextl        = %subst(RECDATA:157:26)

 03€C                   endsl

 03€C                   update    sfldata                                      ˆupd sfldata       €

e03€C                   endif

e02€C                   enddo

‚ 01€C                   eval      xruler        = rulers(window)

‚ 01€C                   exsr      SUB_setcolumn

‚ 01€C                   endsr                                                  ‚end Update_sub    €

 

š   š *-----------------------------------------------------------------------*/

š   š * SUBROUTINE - Map data from input file to subfile and DISPLAY results. */

š   š *              User may choose to continue or return to prior screen    */

š   š *              and specify starting and ending positions again. If they */

š   š *              choose to continue, population of output files begins.   */

š   š *-----------------------------------------------------------------------*/

‚ 01€C     SUB_mapdata   begsr                                                  ‚beg SUB_mapdata   €

 

š   š * Initialize subfile

‚ 01€C                   eval      number_err    = 0

‚ 01€C                   eval      COL           = 0

‚ 01€C                   eval      ROW           = 0

‚ 01€C                   movea     '0000'        *in(63)

‚ 01€C                   eval      *in84         = *off

‚ 01€C                   eval      *in85         = *off

‚ 01€C                   z-add     0             rrn02             4 0

‚ 01€C                   z-add     0             srn02             4 0

‚ 01€C                   z-add     0             recno             4 0

‚ 01€C                   write     PROMPT2                                      ˆwrt PROMPT2       €

‚ 01€C                   movea     '1010'        *in(63)

‚ 01€C                   eval      *in68         = *off

‚ 01€C                   eval      *in71         = *off

‚ 01€C                   eval      *in72         = *off

‚ 01€C                   eval      *in86         = *off

‚ 01€C     1             setll     INREC

‚ 01€C                   exsr      Rollup2

 

š   š * Display parsed data subfile

b02€C                   dou       *in03         = *on  or

 02€C                             *in12         = *on  or

 02€C                             copy_complete = 'Y'  or

 02€C                             copy_cancel   = 'Y'

 02€C                   write     prompt2                                      ˆwrt prompt2       €

 02€C                   write     keys2                                        ˆwrt keys2         €

 02€C                   read      keys2

 02€C                   read      prompt2                                      ˆwrt prompt2       €

b03€C     *in01         caseq     *on           Help

 03€C     *in03         caseq     *on           Exit

 03€C     *in05         caseq     *on           Display_errs

 03€C     *in12         caseq     *on           Refresh

 03€C     *in23         caseq     *on           Delete_errs

 03€C     *in39         caseq     *off          SUB_begincopy

 03€C     *in61         caseq     *on           Rollup2

 03€C                   endcs

e03€C                   enddo                                                  ‚

 

b03€C                   if        copy_complete = 'Y' or

 03€C                             copy_cancel   = 'Y'

 03€C                   exsr      Refresh

e03€C                   endif

 

 02€C                   endsr                                                  ‚end SUB_mapdata   €

 

š   š *-----------------------------------------------------------------------*/

š   š * SUBROUTINE - add records to 2nd subfile                               */

š   š *-----------------------------------------------------------------------*/

 02€C     Rollup2       begsr                                                  ‚beg Rollup2       €

 02€C                   eval      rrn02         = srn02                        SFLRCDNBR

 02€C                   eval      *in84         = *off

 02€C                   eval      *in85         = *off

b03€C  N68              do        10

 03€C                   read      INREC                                  99

šb04€C                   if        *in99         = *on

š 04€C                   eval      *in68         = *on

šl04€C                   else

˜b05€C                   if        IGNORE_HDR    = 'Y' and skipped = *blanks

˜ 05€C                   eval      skipped       = 'Y'

˜ 05€C                   eval      Save_Header   = RECDATA

˜l05€C                   else

˜ 05€C                   eval      *in88         = *off

˜ 05€C                   eval      *in89         = *off

˜ 05€C                   exsr      SUB_parsedata                                parse fields

˜ 05€C                   add       1             rrn02

˜ 05€C                   add       1             srn02

˜ 05€C                   eval      FILEERRRRN    = filerelr01

‚b06€C                   if        number_err    > 0

‚ 06€C                   eval      *in86         = *on

‚e06€C                   endif

˜ 05€C                   write     sfldata2                                     ˆwrt sfldata2      €

˜ 05€C                   move      *on           *in64

˜e05€C                   endif

še04€C                   endif

e03€C                   enddo

 02€C                   endsr                                                  ‚end Rollup2       €

 

š   š *-----------------------------------------------------------------------*/

š   š * SUBROUTINE - set field COLUMN based on where cursor is, or window.    */

š   š *-----------------------------------------------------------------------*/

 

 02€C     SUB_setcolumn begsr                                                  ‚beg SUB_setcolumn €

 

b03€C                   if        row           < 7 or row > 21

 03€C                   select

 03€C                   when      window        = 1

 03€C                   eval      CUR_COLUMN    = 1

 03€C                   when      window        = 2

 03€C                   eval      CUR_COLUMN    = 79

 03€C                   when      window        = 3

 03€C                   eval      CUR_COLUMN    = 157

 03€C                   endsl

l03€C                   else

 

 03€C                   select

 03€C                   when      window        = 1

 03€C                   eval      CUR_COLUMN    = col - 2

 03€C                   when      window        = 2

 03€C                   eval      CUR_COLUMN    = col + 78 - 2

 03€C                   when      window        = 3

 03€C                   eval      CUR_COLUMN    = col + 157 - 2

 03€C                   endsl

e03€C                   endif

 

 02€C                   endsr                                                  ‚end SUB_setcolumn €

 

š   š *-----------------------------------------------------------------------*/

š   š * SUBROUTINE - display only subfile lines that have an error. This      */

š   š * subroutine will read through the entire input file and load only      */

š   š * those records that have embedded special characters into subfile.     */

š   š *-----------------------------------------------------------------------*/

 02€C     Display_errs  begsr                                                  ‚beg Display_errs  €

 

š   š * Initialize subfile

š   š * NOTE: this subroutine LOADS the subfile and does not DISPLAY the subfile.

 02€C                   eval      COL           = 0

 02€C                   eval      ROW           = 0

 02€C                   z-add     0             rrn02             4 0

 02€C                   z-add     0             srn02             4 0

 02€C                   z-add     0             recno             4 0

 02€C                   movea     '0000'        *in(63)

 02€C                   eval      *in84         = *off

 02€C                   eval      *in85         = *off

 02€C                   write     PROMPT2                                      ˆwrt PROMPT2       €

 02€C                   movea     '1010'        *in(63)

 02€C                   eval      *in68         = *off

 02€C                   eval      *in71         = *on

 02€C                   eval      *in72         = *on

 02€C                   eval      *in73         = *off

 02€C                   eval      number_err    = 0

 

 02€C     1             setll     INREC

 

b03€C                   dou       *in99         = *on

 03€C                   read      INREC                                  99

šb04€C                   if        *in99         = *on

š 04€C                   eval      *in68         = *on

šl04€C                   else

š 04€C                   eval      FILEERRRRN    = filerelr01

˜b05€C                   if        IGNORE_HDR    = 'Y' and skipped = *blanks

˜ 05€C                   eval      skipped       = 'Y'

˜ 05€C                   eval      Save_Header   = RECDATA

˜l05€C                   else

˜ 05€C                   eval      *in88         = *off

˜ 05€C                   eval      *in89         = *off

˜ 05€C                   exsr      SUB_parsedata                                parse fields

‚b06€C                   if        parseerror    = 'Y'                          load only if errors

‚ 06€C                   add       1             rrn02

‚ 06€C                   add       1             srn02

‚ 06€C                   write     sfldata2                                     ˆwrt sfldata2      €

‚ 06€C                   move      *on           *in64

‚ 06€C                   eval      parseerror    = *blanks

‚e06€C                   endif

˜e05€C                   endif

še04€C                   endif

e03€C                   enddo

 

 02€C                   z-add     1             rrn02                          SFLRCDNBR

 

š   š * If no errors were actually found then F23=Delete will not be allowed.

b03€C                   if        number_err    = 0

 03€C                   eval      PPMACD        = '***No errors were found***'

 03€C                   eval      PPSRLD        = *blanks

 03€C                   eval      *in73         = *on

 03€C                   write     sfldata2                                     ˆwrt sfldata2      €

 03€C                   move      *on           *in64

e03€C                   endif

 

 02€C                   endsr                                                  ‚end Display_errs  €

 

š   š *-----------------------------------------------------------------------*/

š   š * SUBROUTINE - delete subfile lines that are in error. This routine     */

š   š * will display a WARNING message window that the record is about to     */

š   š * be deleted. Or, return an error message (goes back to calling subr)   */

š   š * if the line that the cursor is on is NOT an error line.               */

š   š *-----------------------------------------------------------------------*/

 02€C     Delete_errs   begsr                                                  ‚beg Delete_errs   €

 

 02€C                   eval      *in84         = *off                         error indicator

 02€C                   eval      *in85         = *off                         error indicator

 

š   š * If F5 was used to display only error lines, then F23 when not on a

š   š * specific line in error means to DELETE ALL lines.

b03€C                   if        (row < 8 or row > 21) and *in71 = *on

 03€C                   exsr      Delete_errs_A                                Delete ALL errors

l03€C                   else

 

š   š * Display an error message if cursor is not within the subfiles lines.

šb04€C                   if        (row < 8 or row > 21)

š 04€C                   eval      *in84         = *on

šl04€C                   else

 

š   š * Display an error message if subfile line is not an ERROR line.

š 04€C     SFLRRN        chain     SFLDATA2                           99

˜b05€C                   if        *in99         = *on or parseerror <> 'Y'

˜ 05€C                   eval      *in85         = *on

˜l05€C                   else

 

š   š * Display window message warning that record is about to be deleted.

˜ 05€C                   eval      recs01        = FILEERRRRN

‚b06€C                   dou       *in03         = *on or

‚ 06€C                             *in10         = *on or

‚ 06€C                             *in12         = *on

‚ 06€C                   exfmt     message3                                     ˆfmt message3      €

 

š   š * Execute command keys.

b07€C     *in03         caseq     *on           Exit

 07€C     *in10         caseq     *on           Delete_err1

 07€C     *in12         caseq     *on           Refresh

 07€C                   endcs

 

e07€C                   enddo

‚e06€C                   endif

˜e05€C                   endif

še04€C                   endif

 03€C                   endsr                                                  ‚end Delete_errs   €

 

š   š * Delete record from input file by relative record number that

š   š * was stored in the display file as a hidden field.

 03€C     Delete_err1   begsr                                                  ‚beg Delete_err1   €

 03€C     FILEERRRRN    delete    INREC                              99        ˆdlt INREC         €

 03€C                   eval      copy_cancel   = 'Y'

 03€C                   endsr                                                  ‚end Delete_err1   €

 

š   š *-----------------------------------------------------------------------*/

š   š * SUBROUTINE - delete ALL error lines                                   */

š   š *-----------------------------------------------------------------------*/

 03€C     Delete_errs_A begsr                                                  ‚beg Delete_errs_A €

 

šb04€C                   dou       *in03         = *on  or

š 04€C                             *in10         = *on  or

š 04€C                             *in12         = *on  or

š 04€C                             copy_complete = 'Y'  or

š 04€C                             copy_cancel   = 'Y'

š 04€C                   eval      RECS01        = number_err

š 04€C                   exfmt     message4                                     ˆfmt message4      €

˜b05€C     *in03         caseq     *on           Exit

˜ 05€C     *in12         caseq     *on           Refresh

˜ 05€C                   endcs

 

š   š * If F10 is pressed, then delete all records in error.

‚b06€C                   if        *in10         = *on

‚ 06€C                   eval      delete_count  = 0

‚ 06€C     1             setll     INREC

b07€C                   dou       *in99         = *on

 07€C                   read      INREC                                  99

b08€C                   if        *in99         = *off

 08€C                   exsr      SUB_parsedata

šb09€C                   if        parseerror    = 'Y'

š 09€C                   delete    INREC                                        ˆdlt INREC         €

š 09€C                   eval      delete_count  = delete_count + 1

še09€C                   endif

e08€C                   endif

e07€C                   enddo

‚e06€C                   endif

 

‚b06€C                   if        delete_count  > 0

‚ 06€C                   eval      copy_cancel   = 'Y'

‚ 06€C                   eval      FILE_RECS     = filercdn01 - delete_count

‚e06€C                   endif

 

˜e05€C                   enddo

š 04€C                   endsr                                                  ‚end Delete_errs_A €

 

š   š *-----------------------------------------------------------------------*/

š   š * SUBROUTINE - Refresh (clear and initialize)                           */

š   š *-----------------------------------------------------------------------*/

š 04€C     refresh       begsr                                                  ‚beg refresh       €

 

š   š * Initialize subfile

š 04€C                   movea     '0000'        *in(63)

š 04€C                   z-add     0             rrn01             4 0

š 04€C                   z-add     0             srn01             4 0

š 04€C                   z-add     0             recno             4 0

š 04€C                   z-add     0             rrn02             4 0

š 04€C                   eval      COL           = 0

š 04€C                   eval      ROW           = 0

š 04€C                   write     PROMPT                                       ˆwrt PROMPT        €

š 04€C                   movea     '1010'        *in(63)

š 04€C                   eval      *in68         = *off

š 04€C                   eval      *in71         = *off

š 04€C                   eval      *in73         = *off

š 04€C     1             setll     INREC

š 04€C                   eval      valerrors     = *blanks

š 04€C                   eval      parseerrors   = *blanks

š 04€C                   eval      parseerror    = *blanks

 

š   š * Load input file into subfile

š 04€C                   exsr      Rollup

 

š   š * initialize miscellaneous variables

š 04€C                   eval      record_count  = filercdn01

š 04€C                   eval      rrn01         = 1

š 04€C                   eval      CUR_COLUMN    = 1

š 04€C                   eval      skipped       = *blanks

š 04€C                   eval      xruler        = rulers(1)

š 04€C                   eval      copy_complete = *blanks

š 04€C                   eval      window        = 1

 

˜b05€C                   if        IGNORE_HDR    = *blanks

˜ 05€C                   eval      IGNORE_HDR    = 'N'

˜e05€C                   endif

 

š 04€C                   endsr                                                  ‚end refresh       €

 

š   š *-----------------------------------------------------------------------*/

š   š * SUBROUTINE - rollup (add more records to subfile)                     */

š   š *-----------------------------------------------------------------------*/

š 04€C     Rollup        begsr                                                  ‚beg Rollup        €

 

š 04€C                   eval      rrn01         = srn01                        SFLRCDNBR

š 04€C                   eval      copy_cancel   = *blanks

š 04€C                   eval      copy_complete = *blanks

š 04€C                   eval      *in84         = *off

š 04€C                   eval      *in85         = *off

 

š   š * Load input file into subfile

˜b05€C  N68              do        rollup1_val

˜ 05€C                   read      INREC                                  99

‚b06€C                   if        *in99         = *on

‚ 06€C                   eval      *in68         = *on

b07€C                   if        rrn01         = 0

 07€C                   eval      stextl = '*No data was found in input file*'

 07€C                   add       1             rrn01

 07€C                   add       1             srn01

 07€C                   write     SFLDATA                                      ˆwrt SFLDATA       €

 07€C                   move      *on           *in64

 07€C                   leave                                                  ˆgo                €

e07€C                   endif

‚l06€C                   else

b07€C                   if        %subst(recdata:1:1) = '1' and

 07€C                             IGNORE_HDR    = *blanks

 07€C                   eval      IGNORE_HDR    = 'Y'

e07€C                   endif

‚ 06€C                   eval      stextl        = recdata

‚ 06€C                   add       1             rrn01

‚ 06€C                   add       1             srn01

‚ 06€C                   write     SFLDATA                                      ˆwrt SFLDATA       €

‚ 06€C                   move      *on           *in64

‚e06€C                   endif

˜e05€C                   enddo

 

š 04€C                   endsr                                                  ‚end Rollup        €

 

š   š *-----------------------------------------------------------------------*/

š   š * SUBROUTINE - populate parsed data into CONVERTER UPLOAD file and      */

š   š *              optionally into the EQUIPMENT MASTER file. Files must    */

š   š *              be cleared prior to loading.                             */

š   š *-----------------------------------------------------------------------*/

š 04€C     SUB_begincopy begsr                                                  ‚beg SUB_begincopy €

 

š   š * Continue only if user enters a "Y" to conitinue

˜b05€C                   if        continue      = 'Y'

˜ 05€C                   eval      copy_complete = 'Y'

 

š   š * If any parsing errors were encountered during the load of the MAC address

š   š * and serial number display (see subroutine ROLLUP2) then display a warning

š   š * message (done within the SUB_chkparse subroutine).

 

˜ 05€C                   exsr      SUB_chkparse

‚b06€C                   if        continue      = 'Y'

 

š   š * Before populating output files, execute this subroutine which will check

š   š * to see if any records are currently in those files. If the files are not

š   š * empty, then a message window is displayed warning the user that the files

š   š * are about to be cleared (message is displayed in SUB_chkfiles).

 

‚ 06€C                   exsr      SUB_chkfiles

b07€C                   if        continue      = 'Y'

 

š   š * Display status message window

 07€C                   eval      *in87         = *on

 07€C                   eval      KEYSXX        = KEYS02

 07€C                   write     message1                                     ˆwrt message1      €

 

š   š * Clear and then open CONVERTER UPLOAD file

 07€C                   eval      command = CMD1

 07€C                   call      'QCMDEXC'

 07€C                   parm                    command

 07€C                   parm      80            size

 07€C                   open      CVUPGIDG

 

š   š * Clear and then open EQUIPMENT MASTER file

b08€C                   if        BUILD_EQPM    = 'Y'

 08€C                   eval      command = CMD2

 08€C                   call      'QCMDEXC'

 08€C                   parm                    command

 08€C                   parm      80            size

 08€C                   open      EQPMSTR

e08€C                   endif

 

š   š * Output header record to converter upload file

 07€C                   eval      out_rectype   = '1'

 07€C                   eval      out_macaddres = *blanks

 07€C                   eval      out_srlnumber = *blanks

 07€C                   eval      out_record    = outrecord

 07€C                   write     CVREC                                        ˆwrt CVREC         €

 

š   š * Read data from intput file and populate into converter upload file

 07€C     1             setll     INREC

b08€C                   dou       *in99       = *on

 08€C                   read      INREC                                  99

šb09€C                   if        *in99       = *off

š 09€C                   eval      *in88         = *off

š 09€C                   eval      *in89         = *off

š 09€C                   exsr      SUB_parsedata                                parse fields

š 09€C                   eval      out_rectype   = '2'

š 09€C                   eval      out_macaddres = PPMACD

š 09€C                   eval      out_srlnumber = PPSRLD

š 09€C                   eval      out_record    = outrecord

š 09€C                   write     CVREC                                        ˆwrt CVREC         €

˜b10€C                   if        BUILD_EQPM    = 'Y'

˜ 10€C                   eval      SERIAL        = PPSRLD

˜ 10€C                   write     EQPREC                                       ˆwrt EQPREC        €

˜e10€C                   endif

še09€C                   endif

e08€C                   enddo

 

š   š * Display completion message / window

     C                   if        BUILD_EQPM    = 'Y'

     C                   eval      *in74         = *on

     C                   else

     C                   eval      *in74         = *off

     C                   endif

     C                   exfmt     message5

 

š   š * exit upon completion of successful mapping into converter upload file.

 07€C                   exsr      Exit                                         exit program

e07€C                   endif

‚e06€C                   endif

˜e05€C                   endif

 

˜b05€C                   if        continue      = 'N'

˜ 05€C                   eval      copy_cancel   = 'Y'

˜ 05€C                   eval      copy_complete = 'N'

˜ 05€C                   eval      rrn02         = rrn02lin

˜e05€C                   endif

 

˜b05€C                   if        continue      = *blanks

˜ 05€C                   eval      rrn02         = rrn02lin

˜ 05€C                   eval      copy_cancel   = *blanks

˜e05€C                   endif

 

š 04€C                   endsr                                                  ‚end SUB_begincopy €

 

š   š *-----------------------------------------------------------------------*/

š   š * SUBROUTINE - parse data from input record                             */

š   š *-----------------------------------------------------------------------*/

š 04€C     SUB_parsedata begsr                                                  ‚beg SUB_parsedata €

 

š   š * parse MAC address and serial number

š 04€C                   eval      len           = MAC_TOPOS - MAC_FRPOS + 1

š 04€C                   eval      PPMACD        = %subst(RECDATA:MAC_FRPOS:len)

š 04€C                   eval      PPMACD        = %triml(PPMACD)

š 04€C                   eval      len           = SRL_TOPOS - SRL_FRPOS + 1

š 04€C                   eval      PPSRLD        = %subst(RECDATA:SRL_FRPOS:len)

š 04€C                   eval      PPSRLD        = %triml(PPSRLD)

š 04€C                   eval      parseerror    = *blanks

 

š   š * scan string for special characters - in MAC address

˜b05€C     1             do        spec_chars_x  x

˜ 05€C                   eval      arg           = spec_chars_ary(x)

˜ 05€C                   eval      pos           = %scan(arg:%trim(PPMACD):1)

‚b06€C                   if        pos           <> 0

‚ 06€C                   eval      *in88         = *on

‚ 06€C                   eval      parseerrors   = 'Y'

‚ 06€C                   eval      parseerror    = 'Y'

‚ 06€C                   leave                                                  ˆgo                €

‚e06€C                   endif

˜e05€C                   enddo

 

š   š * scan string for special characters - in SERIAL# address

˜b05€C     1             do        spec_chars_x  x

˜ 05€C                   eval      arg           = spec_chars_ary(x)

˜ 05€C                   eval      pos           = %scan(arg:%trim(PPSRLD):1)

‚b06€C                   if        pos           <> 0

‚ 06€C                   eval      *in89         = *on

‚ 06€C                   eval      parseerrors   = 'Y'

‚ 06€C                   eval      parseerror    = 'Y'

‚ 06€C                   leave                                                  ˆgo                €

‚e06€C                   endif

˜e05€C                   enddo

 

š   š * If either MAC or SERIAL is blanks then it is treated as an error.

˜b05€C                   if        PPSRLD        = *blanks or

˜ 05€C                             PPMACD        = *blanks

˜ 05€C                   eval      parseerror    = 'Y'

‚b06€C                   if        PPSRLD        = *blanks

‚ 06€C                   eval      PPSRLD        = 'field is BLANKS'

‚ 06€C                   eval      *IN89         = *on

‚e06€C                   endif

‚b06€C                   if        PPMACD        = *blanks

‚ 06€C                   eval      PPMACD        = 'field is BLANKS'

‚ 06€C                   eval      *IN88         = *on

‚e06€C                   endif

˜e05€C                   endif

 

š   š * Count the number of records that have an error

˜b05€C                   if        parseerror    = 'Y'

˜ 05€C                   eval      number_err    = number_err + 1

˜e05€C                   endif

 

š 04€C                   endsr                                                  ‚end SUB_parsedata €

 

š   š *-----------------------------------------------------------------------*/

š   š * SUBROUTINE - check if files are empty and if not display message      */

š   š *-----------------------------------------------------------------------*/

š 04€C     SUB_chkfiles  begsr                                                  ‚beg SUB_chkfiles  €

 

š 04€C                   eval      RECS01        = 0

š 04€C                   eval      RECS02        = 0

 

š 04€C                   open      CVUPGIDG

š 04€C                   eval      RECS01        = filercdn02

š 04€C                   eval      FILE01        =

š 04€C                              %trim(liblname02) + '/' + filename02

š 04€C                   close     CVUPGIDG

 

˜b05€C                   if        BUILD_EQPM    = 'Y'

˜ 05€C                   open      EQPMSTR

˜ 05€C                   eval      RECS02        = filercdn03

˜ 05€C                   eval      FILE02        =

˜ 05€C                              %trim(liblname03) + '/' + filename03

˜ 05€C                   close     EQPMSTR

˜e05€C                   endif

 

˜b05€C                   if        RECS01        <> 0 or

˜ 05€C                             RECS02        <> 0

 

‚b06€C                   dou       *in03         = *on or

‚ 06€C                             *in10         = *on or

‚ 06€C                             *in12         = *on

 

‚ 06€C                   eval      *in87         = *off

‚ 06€C                   eval      KEYSXX        = KEYS01

‚ 06€C                   eval      COL           = 52

‚ 06€C                   eval      ROW           = 14

 

‚ 06€C                   exfmt     MESSAGE1                                     ˆfmt MESSAGE1      €

 

b07€C                   if        *in03         = *on

 07€C                   exsr      exit

e07€C                   endif

 

b07€C                   if        *in05         = *on and  ROW = 14

 07€C                   eval      SQL_file      = 'CVUPGIDG'

 07€C                   exsr      SUB_dspsql

e07€C                   endif

 

b07€C                   if        *in05         = *on and  ROW = 15

 07€C                   eval      SQL_file      = 'EQPMSTR'

 07€C                   exsr      SUB_dspsql

e07€C                   endif

 

b07€C                   if        *in12         = *on

 07€C                   eval      continue      = 'N'

e07€C                   endif

 

b07€C                   if        *in10         = *on

 07€C                   eval      continue      = 'Y'

e07€C                   endif

 

‚e06€C                   enddo

˜e05€C                   endif

š 04€C                   endsr                                                  ‚end SUB_chkfiles  €

 

š   š *-----------------------------------------------------------------------*/

š   š * SUBROUTINE - if any parsing errors were encountered display warning.  */

š   š *-----------------------------------------------------------------------*/

š 04€C     SUB_chkparse  begsr                                                  ‚beg SUB_chkparse  €

 

˜b05€C                   if        parseerrors   = 'Y'

 

‚b06€C                   dou       *in03         = *on or

‚ 06€C                             *in10         = *on or

‚ 06€C                             *in12         = *on

 

‚ 06€C                   eval      *in87         = *off

‚ 06€C                   eval      KEYSXX        = KEYS01

 

‚ 06€C                   exfmt     MESSAGE2                                     ˆfmt MESSAGE2      €

 

b07€C                   if        *in03         = *on

 07€C                   exsr      exit

e07€C                   endif

 

b07€C                   if        *in12         = *on

 07€C                   eval      continue      = 'N'

e07€C                   endif

 

b07€C                   if        *in10         = *on

 07€C                   eval      continue      = 'Y'

e07€C                   endif

 

‚e06€C                   enddo

˜e05€C                   endif

š 04€C                   endsr                                                  ‚end SUB_chkparse  €

 

š   š *-----------------------------------------------------------------------*/

š   š * SUBROUTINE - display converter upload files with SQL.                 */

š   š *-----------------------------------------------------------------------*/

š 04€C     SUB_dspsql    begsr                                                  ‚beg SUB_dspsql    €

 

š    C* RUNSQL REQUEST('SELECT * FROM CVUPGIDG')

˜b05€C                   if        SQL_file      = 'CVUPGIDG'

˜ 05€C                   eval      SQL_statement =

˜ 05€C                              'RUNSQL REQUEST(' + '''' +

˜ 05€C                              'SELECT * FROM CVUPGIDG' + '''' + ')'

˜ 05€C                   eval      command = SQL_statement

˜ 05€C                   call      'QCMDEXC'

˜ 05€C                   parm                    command

˜ 05€C                   parm      80            size

˜e05€C                   endif

 

š    C* RUNSQL REQUEST('SELECT * FROM EQPMSTR')

˜b05€C                   if        SQL_file      = 'EQPMSTR'

˜ 05€C                   eval      SQL_statement =

˜ 05€C                              'RUNSQL REQUEST(' + '''' +

˜ 05€C                              'SELECT * FROM EQPMSTR' + '''' + ')'

˜ 05€C                   eval      command = SQL_statement

˜ 05€C                   call      'QCMDEXC'

˜ 05€C                   parm                    command

˜ 05€C                   parm      80            size

˜e05€C                   endif

 

š 04€C                   endsr                                                  ‚end SUB_dspsql    €

 

š   š *-----------------------------------------------------------------------*/

š   š * SUBROUTINE - validate screen input.                                   */

š   š *-----------------------------------------------------------------------*/

š 04€C     SUB_Validate  begsr                                                  ‚beg SUB_Validate  €

 

š 04€C                   eval      valerrors     = *blanks

š 04€C                   eval      parseerrors   = *blanks

 

˜b05€C                   if        MAC_FRPOS     = MAC_TOPOS or

˜ 05€C                             SRL_FRPOS     = SRL_TOPOS or

˜ 05€C                             MAC_FRPOS     > MAC_TOPOS or

˜ 05€C                             SRL_FRPOS     > SRL_TOPOS

˜ 05€C                   eval      *in96         = *on

˜ 05€C                   eval      valerrors     = 'Y'

˜l05€C                   else

 

‚b06€C                   if        MAC_FRPOS     = 0 or

‚ 06€C                             MAC_TOPOS     = 0 or

‚ 06€C                             SRL_FRPOS     = 0 or

‚ 06€C                             SRL_TOPOS     = 0

‚ 06€C                   eval      *in95         = *on

‚ 06€C                   eval      valerrors     = 'Y'

‚l06€C                   else

 

b07€C                   if        record_count  = 0 and *in10 = *on

 07€C                   eval      *in90         = *on

 07€C                   eval      valerrors     = 'Y'

l07€C                   else

 

e07€C                   endif

‚e06€C                   endif

˜e05€C                   endif

 

š 04€C                   endsr                                                  ‚end SUB_Validate  €

 

š   š *-----------------------------------------------------------------------*/

š   š * Initialization subroutine                                             */

š   š *-----------------------------------------------------------------------*/

š 04€C     *inzsr        begsr                                                  ‚beg *inzsr        €

 

     C     *entry        plist

     C                   parm                    xxlibld

     C                   parm                    xxfiled

 

š   š * If parameters are passed then use that as library and file name displayed

     C                   if        %parms        >= 2

     C                   if        xxlibld       <> *blanks and

     C                             xxfiled       <> *blanks

š 04€C                   eval      INPUTFILE =

š 04€C                              %trim(xxlibld) + '/' + %trim(xxfiled)

     C                   endif

     C                   endif

 

š   š * Set file name as actual file if not passed as parameter (displayed only)

     C                   if        INPUTFILE = *blanks

š 04€C                   eval      INPUTFILE =

š 04€C                              %trim(liblname01) + '/' + %trim(filename01)

     C                   endif

 

š   š * Retrieve location from EXTCON data area.

 02€C     *dtaara       define    EXTCON        EXTDTA

 02€C                   in        EXTDTA

 02€C     siteid        chain     AGLOCNM0                           99

     C                   if        *in99         = *off

     C                   movel     lmname        location

     C                   endif

 

š   š * Open file in order to determine if file lock exists (return code 01217)

š 04€C                   open      CVUPGIDG                             99

˜b05€C                   if        *in99         = *on

˜ 05€C                   exsr      *PSSR

˜e05€C                   endif

 

š   š * Close file then call CLP to allocate the file to this job

š 04€C                   close     CVUPGIDG                             99

š 04€C                   call      'IS3010C1'

š 04€C                   parm                    RETURNCODE

 

š   š * Load first page of subfile with input data

š 04€C                   exsr      refresh

š 04€C                   eval      FILE_RECS     = filercdn01

 

š   š * Special characters string array to check for valid MAC and serial numbers

š 04€C                   movea     spec_chars    spec_chars_ary

 

š   š * If from/to values saved from last time then load values to display fields.

š 04€C     *dtaara       define    IS3010DTA     IS3010VALS

š 04€C                   in        IS3010VALS

˜b05€C                   if        SV_MAC_FRPOS  <> *blanks

˜ 05€C                   movel     SV_MAC_FRPOS  MAC_FRPOS

˜e05€C                   end

˜b05€C                   if        SV_MAC_TOPOS  <> *blanks

˜ 05€C                   movel     SV_MAC_TOPOS  MAC_TOPOS

˜e05€C                   end

˜b05€C                   if        SV_SRL_FRPOS  <> *blanks

˜ 05€C                   movel     SV_SRL_FRPOS  SRL_FRPOS

˜e05€C                   end

˜b05€C                   if        SV_SRL_TOPOS  <> *blanks

˜ 05€C                   movel     SV_SRL_TOPOS  SRL_TOPOS

˜e05€C                   end

 

š 04€C                   endsr                                                  ‚end *inzsr        €

 

š   š *-----------------------------------------------------------------------*/

š   š * Error subroutine                                                      */

š   š *-----------------------------------------------------------------------*/

š 04€C     *PSSR         begsr                                                  ‚beg *PSSR         €

 

š   š * Check flag to prevent endless looping

˜b05€C                   if        $PSSR1 = *blanks

˜ 05€C                   eval      $PSSR1 = 'Y'

 

š   š * Determine which file is in error if any

˜ 05€C                   select

˜ 05€C                   when      filestat01    <> 00000

˜ 05€C                   eval      PSSA_FILENAME = FILENAME01

˜ 05€C                   eval      PSSA_LIBLNAME = LIBLNAME01

˜ 05€C                   movel     FILESTAT01    PSSA_FILESTAT

˜ 05€C                   when      filestat02    <> 00000

˜ 05€C                   eval      PSSA_FILENAME = FILENAME02

˜ 05€C                   eval      PSSA_LIBLNAME = LIBLNAME02

˜ 05€C                   movel     FILESTAT02    PSSA_FILESTAT

˜ 05€C                   when      filestat03    <> 00000

˜ 05€C                   eval      PSSA_FILENAME = FILENAME03

˜ 05€C                   eval      PSSA_LIBLNAME = LIBLNAME03

˜ 05€C                   movel     FILESTAT03    PSSA_FILESTAT

˜ 05€C                   endsl                                                  ‚                  €

 

š   š * If no file open then use FILE ERROR from PSSA data structure

‚b06€C                   if        PSSA_FILENAME = *blanks

‚ 06€C                   eval      PSSA_FILENAME = PGEFIL

‚e06€C                   endif

‚b06€C                   if        PSSA_LIBLNAME = *blanks

‚ 06€C                   eval      PSSA_LIBLNAME = '*LIBL'

‚e06€C                   endif

 

š   š * Call program to display error

˜ 05€C                   call      'PSSRR1'

˜ 05€C                   parm                    PSSA

˜ 05€C                   parm                    PSSA_FILENAME

˜ 05€C                   parm                    PSSA_LIBLNAME

˜ 05€C                   parm                    PSSA_FILESTAT

 

˜ 05€C                   exsr      exit

˜e05€C                   endif                                                  ‚                  €

š 04€C                   endsr                                                  ‚end *PSSR         €

 

**

*...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+...

.8....+....9....+....0....+....1....+....2....+....+....+....4....+....5....+.

...6....+....7....+....8...