HP 3000 Manuals

Sample VPLUS Program [ HP RPG/iX Reference Manual ] MPE/iX 5.0 Documentation


HP RPG/iX Reference Manual

Sample VPLUS Program 

This section shows a program that uses the RPG VPLUS Interface.  The
program is a typical data entry program.  Data collected from it is
written to a batch file that can be used by other programs and
applications.  The program, shown in Figure 10-7 , does the following:

   *   Displays a VPLUS form with its initial values.
   *   Reads data entered into the form by the terminal operator.
   *   Performs VPLUS and program edits on the input data.
   *   Writes the edited data to a VPLUS batch file.

The File Description Specifications define the WORKSTN file, the VPLUS
file in which the forms are stored, the batch file where the edited data
is written and the trace file where a log of the actions and events is
written.

The Input Specifications define the input records for events 00 (the
ENTER key), 01-08 (function keys f1 through f8), and 09 (the number of
fields with edit errors).  This program treats events 01-07 as if they
were event 08.  Data is not returned by events 01-08; they signal that a
function key is pressed and cause the program to go to the label EXIT.

The Calculation Specifications perform VPLUS actions using exception
output.  Events are returned using demand READs.  The program ends when
f8 is pressed.
___________________________________________________________________________________
|                                                                                 |
|                1         2         3         4         5         6         7    |
|            678901234567890123456789012345678901234567890123456789012345678901234|
|              _______________________________________________________            |
|                                                                                 |
|      1     HDUMPFILE                                                            |
|                                                                                 |
|      2     FTRANSFILUD  V      80            WORKSTN   L5B                      |
|      3     F                                              KFORMS FORMA          |
|      4     F                                              KBATCH BATCHA         |
|      5     F                                              KTRACE TRACEFL        |
|                                                                                 |
|      6     I*** ENTER KEY (00)                                                  |
|            I*                                                                   |
|            ITRANSFILAA  10   1 C0   2 C0                                        |
|            I       OR        1 C1   2 C0                                        |
|            I                                        3  17 FORMB                 |
|            I                                       18  21 DATALN                |
|            I                                       22  78 DATA                  |
|            I                                       22  41 NAME                  |
|                                                                                 |
|                                                                                 |
___________________________________________________________________________________

          Figure 10-7.  A Program that Uses VPLUS 
___________________________________________________________________________________
|                                                                                 |
|                1         2         3         4         5         6         7    |
|            678901234567890123456789012345678901234567890123456789012345678901234|
|              _______________________________________________________            |
|                                                                                 |
|            I                                       42  61 ADDR                  |
|            I                                       62  71 CITY                  |
|            I                                       72  73 ST                    |
|            I                                       74  78 ZIP                   |
|      7     I*** EXIT KEYS (01 - 08)                                             |
|            I        BB  18   1 C0   2 C1                                        |
|            I       OR        1 C0   2 C2                                        |
|            I       OR        1 C0   2 C3                                        |
|            I       OR        1 C0   2 C4                                        |
|            I       OR        1 C0   2 C5                                        |
|            I       OR        1 C0   2 C6                                        |
|            I       OR        1 C0   2 C7                                        |
|            I       OR        1 C0   2 C8                                        |
|      8     I*** NUMBER OF EDIT ERRORS   (09)                                    |
|            I        CC  19   1 C0   2 C9                                        |
|            I                                        3  17 FORMB                 |
|            I                                       18  220NUMERR      01        |
|                                                                                 |
|      9     C*  GET NEXT FORM                                                    |
|            C           START     TAG                                            |
|            C                     MOVEL"GETNXT"  ACTION  6                       |
|            C                     SETON                     35    GETNXT - 51    |
|            C                     EXCPT                                          |
|     10    C*  SET INITIAL VALUES                                                |
|            C                     MOVEL"INIT  "  ACTION           INIT - 58      |
|            C                     EXCPT                                          |
|            C                     SETOF                     35                   |
|     11    C*  DISPLAY FORM                                                      |
|            C           REPEAT    TAG                                            |
|            C                     SETOF                     01                   |
|            C                     MOVEL"SHOW  "  ACTION                          |
|            C                     SETON                     35    SHOW - 53      |
|            C                     EXCPT                                          |
|     12    C*  READ FROM TERMINAL                                                |
|            C                     MOVEL"RDTERM"  ACTION           RDTERM - 54    |
|            C                     EXCPT                                          |
|            C                     SETOF                     35                   |
|     13    C*  READ RECORD                                                       |
|            C                     READ TRANSFIL                 H0               |
|            C*** IF F1 - F8 EXIT ELSE CONTINUE                                   |
|            C   18                SETON                     LR                   |
|            C   LR                GOTO EXIT                       EXIT IF F1 - F8|
|                                                                                 |
|                                                                                 |
___________________________________________________________________________________

          Figure 10-7.  A Program that Uses VPLUS (Continued) 
___________________________________________________________________________________
|                                                                                 |
|                1         2         3         4         5         6         7    |
|            678901234567890123456789012345678901234567890123456789012345678901234|
|              _______________________________________________________            |
|                                                                                 |
|     14    C*  IF ENTER - EDIT DATA                                              |
|            C   10                MOVEL"EDITS "  ACTION                          |
|            C   10                SETON                     35    EDITS - 59     |
|            C   10                EXCPT                                          |
|            C   10                SETOF                     35                   |
|     15    C*  DETERMINE NO. OF ERRORS                                           |
|            C   10                READ TRANSFIL                 H0               |
|            C***  IF ERRORS - RETURN TO STEP 3                                   |
|            C   01                GOTO REPEAT                                    |
|            C*** IF NO ERRORS CONTINUE                                           |
|            C*                                                                   |
|     16    C*  TRANSFER DATA TO PROGRAM                                          |
|            C                     MOVEL"GETDTA"  ACTION                          |
|            C                     SETON                     35    GETDTA - 64    |
|            C                     EXCPT                                          |
|            C                     SETOF                     35                   |
|     17    C*  READ DATA FROM TRANSFIL                                           |
|            C                     READ TRANSFIL                 H0               |
|            C*                                                                   |
|     18    C*  PERFORM USER EDITS                                                |
|            C           MORERR    TAG                                            |
|            C*                                                                   |
|            C*** SUPPLY USER EDITS HERE                                          |
|     19    C*  FIND ERRORS, ENHANCE FIELDS, DISPLAY MESSAGE                      |
|            C  N20                GOTO NOERRS                                    |
|            C                     MOVE "     "   FLDNO   5                       |
|            C                     MOVE "00"      MSLEN   2                       |
|            C                     MOVE " "       ENHCD   1                       |
|            C                     MOVE " "       MSG    47                       |
|            C                     SETON                     36    CORERR - 56    |
|            C                     EXCPT                                          |
|            C                     READ TRANSFIL                                  |
|            C                     GOTO MORERR                                    |
|            C           NOERRS    TAG                                            |
|            C                     SETOF                     36                   |
|            C*                                                                   |
|     20    C*  MOVE DATA FROM PROGRAM TO BUFFER                                  |
|            C                     SETON                     37    PUTDTA - 63    |
|            C                     EXCPT                                          |
|            C                     SETOF                     37                   |
|            C*                                                                   |
|                                                                                 |
|                                                                                 |
___________________________________________________________________________________

          Figure 10-7.  A Program that Uses VPLUS (Continued) 
___________________________________________________________________________________
|                                                                                 |
|                1         2         3         4         5         6         7    |
|            678901234567890123456789012345678901234567890123456789012345678901234|
|              _______________________________________________________            |
|                                                                                 |
|     21    C*  WRITE DATA FROM BUFFER TO BATCH FILE                              |
|            C                     MOVEL"WRTBAT"  ACTION                          |
|            C                     SETON                     35    WRTBAT - 66    |
|            C                     EXCPT                                          |
|            C                     SETOF                     35                   |
|            C*                                                                   |
|     22    C*  CHECK NEXT FORM FOR STATUS CHANGE                                 |
|            C                     MOVE "        "NXTFRM 15                       |
|            C                     MOVEL"        "NXTFRM                          |
|            C                     MOVELFORMB     NXTFRM                          |
|            C                     MOVE "0"       RPTAPP  1                       |
|            C                     MOVE "0"       FRZAPP  1                       |
|            C                     SETON                     38    CHGNXT - 50    |
|            C                     EXCPT                                          |
|            C                     SETOF                     38                   |
|            C*                                                                   |
|     23    C*  RETURN TO STEP 1                                                  |
|            C                     SETOF                     011018               |
|            C                     SETOF                     19                   |
|            C                     GOTO START                                     |
|            C*                                                                   |
|     24    C*  END OF PROCESSING                                                 |
|            C           EXIT      TAG                                            |
|            O*** INDICATOR 35 FOR ACTIONS 51,53,54,58-61,64-70                   |
|            O*** INDICATOR 36 FOR ACTIONS 56 AND 62                              |
|            O*** INDICATOR 37 FOR ACTIONS 57 AND 63                              |
|            O*** INDICATOR 38 FOR ACTION 50                                      |
|            O*                                                                   |
|     25    OTRANSFILE        35                                                  |
|            O                         ACTION     6                               |
|            O        E        36                                                 |
|            O                                    6 "CORERR"                      |
|            O                         FLDNO     11                               |
|            O                         MSLEN     13                               |
|            O                         ENHCD     14                               |
|            O                         MSG       60                               |
|            O        E        37                                                 |
|            O                                    6 "PUTDTA"                      |
|            O                         DATALN    10                               |
|            O                         DATA      67                               |
|                                                                                 |
|                                                                                 |
___________________________________________________________________________________

          Figure 10-7.  A Program that Uses VPLUS (Continued) 
___________________________________________________________________________________
|                                                                                 |
|                1         2         3         4         5         6         7    |
|            678901234567890123456789012345678901234567890123456789012345678901234|
|              _______________________________________________________            |
|                                                                                 |
|            O        E        38                                                 |
|            O                                    6 "CHGNXT"                      |
|            O                         NXTFRM    21                               |
|            O                         RPTAPP    22                               |
|            O                         FRZAPP    23                               |
|                                                                                 |
|                                                                                 |
___________________________________________________________________________________

          Figure 10-7.  A Program that Uses VPLUS (Continued) 

                                   Comments 

 1       This Header Specification directs RPG to save dump information
         in the file DUMPFILE if run-time errors occur.

 2       This line defines the WORKSTN (terminal) file TRANSFIL.

         Column 15 is U to specify an update file type.  You must use
         this file type with VPLUS.

         Column 16 is D to specify that TRANSFIL is a demand file.  For
         this particular example, TRANSFIL must be a demand file.  For
         applications that use the RPG logic cycle, the file may be a
         primary file.

         Column 19 is V to specify variable length records.  All WORKSTN
         files must have variable length records.

         Columns 24-27 contain the record length.  The record length is
         dependent on the data buffer length for the longest form, plus
         20 characters of control information.  (Assume that the longest
         form in this example contains 60 data characters.)

         Columns 40-46 contain WORKSTN to define the device class name
         for the VPLUS file.

         Column 50 is L to enable the function key labels on the
         terminal.

         Column 51 is 5 to specify that 5 seconds is the length of time
         that a message is displayed at the terminal.

         Column 52 is B to enable the BREAK key.

 3       This line defines the VPLUS forms file used in the program.
         (This line is required.)

         Column 53 is K to identify this File Description Specification
         as a Continuation line.

         Columns 54-59 specify that this is a FORMS File Description
         Continuation line.

         Columns 60-74 name the forms file FORMA. If the name is longer
         than 15 characters, enter an MPE FILE command for it.

 4       This line defines the VPLUS batch file used in the program.
         (This line is optional.)

         Columns 54-59 specify that this is a BATCH File Description
         Continuation line.

         Columns 60-74 name the batch file BATCHA.

 5       This line defines the VPLUS trace file used in the program.
         (This line is optional.)

         Columns 54-59 specify that this is a TRACE File Description
         Continuation line.

         Columns 60-74 name the trace file TRACEFL.

 6       This line begins the Input Specifications for event 00 (the
         ENTER key).

 7       This line begins the Input Specifications for events 01-08.
         These events do not read data; they direct program execution to
         the label EXIT.

 8       This line begins the Input Specifications for event 09 (fields
         with errors).

 9       The next few lines read the next form from the forms file
         (GETNXT, action 51).  If the form is currently being used, it is
         not read.

10       The next few lines initialize the form with the FORMSPEC default
         values (INIT, action 58).

11       The next few lines display the initialized form and a message in
         the message window (SHOW, action 53).

12       The next few lines indicate that data is to be read from the
         terminal with RDTERM (action 54).

13       The next few lines read (demand read) the data from the
         terminal.  The data is returned as events 00-08 (for simplicity
         in this example, events 01-07 are treated as event 08).

         If the event is 01-08 (EXIT), terminate the program.  If the
         event is 00 (ENTER), continue.

14       Perform all VPLUS field edits specified for the form using EDITS
         (action 59).

15       Read the WORKSTN file.  The record returned (event 09) specifies
         the number of errors found in the data.

         If errors are found, a message describing the first error is
         moved to the window buffer, and all fields with errors are
         enhanced.  Return to Step 11 to display the form with the error
         message and enhancements.  Repeat Steps 11-15 until no errors
         remain.  If there are no errors, continue with Step 16.

16       Transfer data from the VPLUS data buffer to the program using
         GETDTA (action 64).

17       Read the WORKSTN file.  The record returned (event 10) contains
         the data from the VPLUS buffer.

18       Perform editing specified in the program.  If errors are found,
         continue with Step 19; otherwise, go to Step 20.

19       Using CORERR (action 56) indicate which fields failed the user
         edits and display the form with these fields.  If the program
         buffer contains a message for the window, display it with the
         form.  Action 56 is followed by a demand READ. If the event
         returned is 00, terminal operator entered corrections and
         pressed ENTER. Repeat Steps 18 and 19 until all data passes the
         user edits.

20       Transfer the edited data to the VPLUS buffer using PUTDTA
         (action 63).

21       Write the data in the VPLUS buffer to the batch file using
         WRTBAT (action 66).

22       If the next form name or the repeat/append or freeze/append
         status should be changed, CHGNXT (action 50) makes these
         changes.

23       Go to Step 9.

24       End of processing.

25       This line begins the Output Specifications for actions 56, 63
         and 50.



MPE/iX 5.0 Documentation