Wed Jan 20 1999

ARMRCALC

Subject: ARMRCALC03

The VIEW Operation


The VIEW Operation

The key words for the view operation are as follows:

header= field1 field2 .....

columns= field1 field2 ....

global=

The header= and columns= key words play the same role here as they do in Noodle's screen file. Any number of repetitions are recognized; i.e. to the right of the key word we expect to find a number of field names. If you can't fit them on one line, simply repeat the key word on the next line and enter the additional fields.

The global= key word is used when one wishes to work with the data base as if it where all one record. global= is most often used when one wishes to fill in a field with the same value for each record of the data base.

As mentioned earlier, the data base view has an effect on the CALC operation only. A view is not always required. The view defines the grouping to be used in the CALC step.

If a view operation is omitted, ARMRCALC will process each and every record of the specified subset combinations when the CALC formulae are executed. N.B.; omitting the view altogether is almost equivalent to a pure columnar, or pure header view which names all of the data base fields. We say almost, because we process the records in physical sequence when no view was given; while we would process all records in the specified sort sequence if all fields were mention in the view.

When you build a view, we urge you to picture the equivalent view on a Noodle display screen. Keep in mind that the CALC language does not contain any looping commands. What is accomplished in traditional languages with statements like DO, FOR, etc. is expressed in the data view when it comes to ARMRCALC.

For most applications, a one page columnar view is all you will need. For special applications, it is necessary to set up a book view containing both header and columnar display pages.

The following example shows a columnar view in one cycle; in order to obtain the desired result we must define a book view in the next cycle.

Problem

A data base with a large number of fields is to be collapsed into a special summary base. In particular, we wish to convert the data base such that counters HSSCHED and HSCOMPL become attributes of fields ORG, GROUP, CTYP, and CAT.

A sketch of the ARMRCALC code to do this is as follows:

      ;
      ;  In the first cycle view by org group ctyp cat
      ;  ---------------------------------------------
      ;
      ;  Summarize sched & compl into hssched and hscompl for records
      ;  of the current week. Set hssched and hscompl to zero for
      ;  all record not of the current week.
      ;
      columns=   org group ctyp cat
      ;
      prune_start=
      ;
      ; Note: record with weeknd>thru have already been physically deleted!
      ;
         bracket_start=
            compare= weeknd thru
            match= crntweek
            less_than= othweek
         bracket_end=
      prune_end=
      ;
      ;   Given the defined view, hssched is set to sched+ and hscompl is set to compl+.
      ;
      ;
      calc_start=  crntweek
         hssched=line_sum(sched)
         hscompl=line_sum(compl)
      calc_end=
      ;
      calc_start=  othweek
         hssched=0
         hscompl=0
      calc_end=
      end=
      ;
      ; in the next cycle
      ; -----------------
      ;
      ;   propagate hssched & hscompl over our crucial view
      ;   this makes hssched and hscompl an attribute of: org group ctyp cat
      ;
      header= org group ctyp cat
      columns= hssched hscompl
      ;
      ; Note: the current state of the data base guarantees that
      ;       each page of the book view will have at most two records.
      ;
      ; The following is an exhaustive list of columnar input combinations.
      ;
      ;  1    2    3    4    5    6    7
      ; ---  ---  ---  ---  ---  ---  ---
      ; 0 0  0 y  x 0  x y  0 0  0 0  0 0
      ;                     0 y  x 0  x y
      ;
      ; Note: Let C represent current week's records and let O represent
      ;       other week's records. Then we can say that the composition
      ;       of combinations 1-7 are made up of the following records:
      ;
      ;         1      2      3      4      5      6      7
      ;       ------ ------ ------ ------ ------ ------ ------
      ; row1  C or O   C      C      C      O      O      O
      ; row2                                C      C      C
      ;
      ;
      ; The calc formulae shown later yield the corresponding outputs:
      ;
      ;  1    2    3    4    5    6    7
      ; ---  ---  ---  ---  ---  ---  ---
      ; 0 0  0 y  x 0  x y  0 y  x 0  x y
      ;                     0 y  x 0  x y
      ;
      calc_start=
         hssched=max(hssched,next(hssched))
         hscompl=max(hscompl,next(hscompl))
      calc_end=
      end=

Note

The redundant records created by the formulae for combinations 5, 6, and 7 create no problem, as long as you did NOT specify NOCAN. ARMRCALC always canonizes the data base before filing. Thus we will end up with a base in which HSSCHED and HSCOMPL are indeed attributes of ORG, GROUP, CTYP, and CAT.