HP 3000 Manuals

Reporting Data from a Dataset [ Getting Started With TRANSACT V ] MPE/iX 5.0 Documentation


Getting Started With TRANSACT V

Reporting Data from a Dataset 

Now let's use VPLUS to display data from the customer dataset.

One way to display the data is to display a record at a time using the
same form we used to add and update data.

The following program illustrates this.
_______________________________________________________________________
|                                                                     |
|      1     system ex28,base=orders,vpls=formfile;                   |
|      2     list(auto) customer;                                     |
|      3     find(serial) customer,perform=display-record;            |
|      4     exit;                                                    |
|                                                                     |
|      5     display-record:                                          |
|                                                                     |
|      6       put(form) vcustomer,wait=                              |
|                                 ,window=("press f1-f7 to continue");|
|      7       return;                                                |
_______________________________________________________________________

          Figure 3-13.  Using VPLUS to display data 

3       The FIND verb can also be a looping verb.  In this example, it
        serially retrieves each record from the customer dataset.  As
        each record is retrieved, the PERFORM= option passes control to
        the routine at label display-record.  When the RETURN is
        encountered, control passes back to the FIND.

6       PUT(FORM) displays the information to the screen.  The WAIT=
        option causes the program to wait until the user has pressed any
        of the function keys before continuing with the next record.  The
        WINDOW= option displays a message in the VPLS window area to
        remind the user that he must press one of the function keys
        before the program will continue.

Another way to display the information back to the terminal is to format
the data to look more like a report, but yet remain within VPLUS. To do
this, we need to set up a form for the report heading information, a form
to hold the detail information for each record, and a counter to
increment so that we know when we have filled the screen.

Up until now, we have accepted the default selection as to what data
elements are extracted and reported.  Now we will override the default
selection by using a qualifier on the verb to specify which subset of
data we want.

The new forms we need are called vcustomerrh, and vcustomerrd.  Their
definition in the dictionary and the format of the forms are shown below.
________________________________________________________________________________
|                                                                              |
|     >show file                                                               |
|                       FILE vcustomerrh                                       |
|                                                                              |
|     FILE                 TYPE: RESPONSIBILITY:                               |
|      VCUSTOMERRH          FORM                                               |
|                                                                              |
|     > show file                                                              |
|                       FILE vcustomerrd                                       |
|                                                                              |
|     FILE                 TYPE: RESPONSIBILITY:                               |
|      VCUSTOMERRD          FORM                                               |
|                                                                              |
|             ELEMENT(ALIAS):             PROPERTIES:         ELEMENT(PRIMARY):|
|              CUST-NO                     9 (4,0,4)           CUST-NO         |
|              NAME                        X (20,0,20)         NAME            |
|              STREET-ADDR                 X (20,0,20)         STREET-ADDR     |
|              CITY-STATE                  X (20,0,20)         CITY-STATE      |
|              ZIPCODE                     X (6,0,6)           ZIPCODE         |
________________________________________________________________________________

          Figure 3-14.  Dictionary definitions for customer forms to be appended 
_________________________________________________
|                                               |
|                              customer  address|
_________________________________________________

          Figure 3-15.  VPLUS form for customer header 
________________________________________________________________
|                                                              |
|                               [    ]   [                    ]|
|                                        [                    ]|
|                                        [                    ]|
|                                        [      ]              |
________________________________________________________________

          Figure 3-16.  VPLUS form to be appended 

We want to FREEZE the report heading on the screen and APPEND each of the
customer records.  When the screen is full, which in this example is
after displaying 5 customer records, we want to pause until the person
requesting this report is ready to go on.

The following program illustrates these points.
_________________________________________________________________________________
|                                                                               |
|      1     system ex29,base=orders,vpls=formfile;                             |
|      2     define(item) counter i(4);                                         |
|      3     list counter,init;                                                 |
|      4     list(auto) customer;                                               |
|      5     put(form) vcustomerrh,freeze;                                      |
|      6     find(serial) customer,list=(cust-no:zipcode)                       |
|                                 ,perform=display-record;                      |
|      7     if (counter) > 0                                                   |
|      8       then update(form) vcustomerrd,list=()                            |
|                                           ,wait=                              |
|                                           ,window=("press f1-f7 to continue");|
|      9     exit;                                                              |
|                                                                               |
|     10     display-record:                                                    |
|                                                                               |
|     11     let (counter) = (counter) + 1;                                     |
|     12     if (counter) = 5                                                   |
|              then                                                             |
|                do                                                             |
|     13         let (counter) = 0;                                             |
|     14         put(form) vcustomerrd,wait=                                    |
|                                     ,window=("press f1-f7 to continue")       |
|                                     ,append;                                  |
|                doend                                                          |
|     15       else put(form) vcustomerrd,window=(" ")                          |
|                                        ,append;                               |
|     16     return;                                                            |
_________________________________________________________________________________

          Figure 3-17.  Program with VPLUS freeze and append 

2       We define an element local to this program called counter.  It is
        an integer that can store a 4-digit number, e.g.  <= 9999.

3       LIST includes this new element in the list of variables that our
        program can access.  The INIT option initializes its value to
        zero.

5       PUT(FORM) displays the report heading form to the terminal.  The
        FREEZE option freezes the form on the terminal so that the
        scrolling portion of the screen begins below this form.

6       The LIST= option designates the items in the program list that
        the FIND verb is to retrieve.  If we didn't do this, it would
        attempt to retrieve the item counter from dataset customer and
        would be unable to do so.  The default for IMAGE data access
        verbs is to retrieve all items known to the program via the LIST
        verb unless this is overridden on the data access verb with the
        LIST= option.  We will see more of this in the section on data
        structures.

        The colon between cust-no and zipcode specifies a range of data
        items.  In this example, we are telling Transact to limit itself
        to the range of items starting with cust-no and ending with
        zipcode.

7       Here we have ended the display of all full screens of customer
        data.  Counter will be greater than zero if we have displayed
        another customer since the last time the screen was entirely
        filled.  If so, then we must pause one more time to give the user
        the opportunity to review this data before going on.  Lines 7 and
        8 take care of the last set of records if there are fewer than
        five.

8       We only want to update the VPLUS message window and wait for a
        response.  We save data transmission time by not re-sending the
        form data to the screen, thus the LIST=() option which specifies
        a null item list.

12      If this customer fills the screen, then wait for the user to
        indicate that he is ready to continue, otherwise append this new
        customer to the screen and go on.

This program produces the screen output shown below.
_______________________________________________________________
|                                                             |
|                             customer  address               |
|                              [14  ]   [Furtado Inports     ]|
|                                       [1396 E Santa Clara  ]|
|                                       [Los Angeles, Ca.    ]|
|                                       [90189 ]              |
|                              [15  ]   [Saxon's             ]|
|                                       [518 W San Carlos    ]|
|                                       [Santa Clara, Ca.    ]|
|                                       [94168 ]              |
|                              [16  ]   [Pour House          ]|
|                                       [1475 Lipton Place   ]|
|                                       [San Jose, Ca.       ]|
|                                       [95122 ]              |
|                              [18  ]   [Excl Chemical Co    ]|
|                                       [630 Walsh           ]|
|                                       [New York, NY        ]|
|                                       [44636 ]              |
|                              [19  ]   [Hold A Hill Planter ]|
|                                       [651 El Camino       ]|
|                                       [Dallas, Texas       ]|
|                                       [45623 ]              |
|     press f1-f7 to continue                                 |
_______________________________________________________________

          Figure 3-18.  Result of VPLUS freeze and append 


MPE/iX 5.0 Documentation