home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / viscobv6.zip / vac22os2 / ibmcobol / samples / pusample / dataeg1.cbl < prev    next >
Text File  |  1996-05-16  |  17KB  |  206 lines

  1.       * Tests modeling of various types of data definitions,            DAT00010
  2.       * simple dataflow, and def/use edge construction.                 DAT00020
  3.                                                                         DAT00030
  4.         IDENTIFICATION DIVISION.                                        DAT00040
  5.         PROGRAM-ID. DataEg1.                                            DAT00050
  6.         DATE-WRITTEN 17 April 1996.                                     DAT00060
  7.                                                                         DAT00070
  8.         ENVIRONMENT DIVISION.                                           DAT00080
  9.         INPUT-OUTPUT SECTION.                                           DAT00090
  10.         FILE-CONTROL.                                                   DAT00100
  11.             SELECT DatesInFile ASSIGN InFile.                           DAT00110
  12.             SELECT DatesOutFile ASSIGN OutFile.                         DAT00120
  13.                                                                         DAT00130
  14.         DATA DIVISION.                                                  DAT00140
  15.                                                                         DAT00150
  16.         FILE SECTION.                                                   DAT00160
  17.         FD DatesInFile RECORDING MODE F.                                DAT00170
  18.         01 DatesIn.                                                     DAT00180
  19.             05 TheDay           PIC 99.                                 DAT00190
  20.             05 TheMonth         PIC 99.                                 DAT00200
  21.             05 TheYear          PIC 99.                                 DAT00210
  22.                                                                         DAT00220
  23.         FD DatesOutFile RECORDING MODE F.                               DAT00230
  24.         01 DatesOut.                                                    DAT00240
  25.             05 TheDay           PIC 99.                                 DAT00250
  26.             05 TheMonth         PIC 99.                                 DAT00260
  27.             05 TheYear          PIC 99.                                 DAT00270
  28.                                                                         DAT00280
  29.         WORKING-STORAGE SECTION.                                        DAT00290
  30.                                                                         DAT00300
  31.         01 Date1.                                                       DAT00310
  32.             05 Split.                                                   DAT00320
  33.                 10 TheDay          PIC 99 VALUE ZEROS.                  DAT00330
  34.                 10 TheMonth        PIC 99 VALUE 11.                     DAT00340
  35.                 10 TheYear         PIC 99 VALUE 22.                     DAT00350
  36.             05 Composite REDEFINES Split.                               DAT00360
  37.                 10 WholeDate       PIC 9(6).                            DAT00370
  38.             66 Dayless RENAMES TheMonth THRU TheYear.                   DAT00380
  39.                                                                         DAT00390
  40.       * Fields are uninitialized in the following                       DAT00400
  41.                                                                         DAT00410
  42.         01 Date2.                                                       DAT00420
  43.             05 Split.                                                   DAT00430
  44.                 10 TheDay          PIC 99.                              DAT00440
  45.                 10 TheMonth        PIC 99.                              DAT00450
  46.                 10 TheYear         PIC 99.                              DAT00460
  47.             05 Composite REDEFINES Split.                               DAT00470
  48.                 10 WholeDate       PIC 9(6).                            DAT00480
  49.             66 Dayless RENAMES TheMonth THRU TheYear.                   DAT00490
  50.                                                                         DAT00500
  51.         01 Date3.                                                       DAT00510
  52.             05 Yearless.                                                DAT00520
  53.                 10 TheDay          PIC 99 VALUE ZEROS.                  DAT00530
  54.                 10 TheMonth        PIC 99 VALUE ZEROS.                  DAT00540
  55.                                                                         DAT00550
  56.         01 Overlaps.                                                    DAT00560
  57.             05 Layout1.                                                 DAT00570
  58.                 10 Field1          PIC X(2).                            DAT00580
  59.                 10 Field2          PIC X(3).                            DAT00590
  60.             05 Layout2 REDEFINES Layout1.                               DAT00600
  61.                 10 Field3          PIC X(3).                            DAT00610
  62.                 10 Field4          PIC X(2).                            DAT00620
  63.             05 Layout3 REDEFINES Layout2 PIC X(5).                      DAT00630
  64.                                                                         DAT00640
  65.         01 AString                 PIC X(20).                           DAT00650
  66.                                                                         DAT00660
  67.         01 FixedEmployeeTable.                                          DAT00670
  68.             05 EmployeeTable OCCURS 100 TIMES                           DAT00680
  69.                ASCENDING KEY IS WageRate EmployeeNo                     DAT00690
  70.                INDEXED BY A, B.                                         DAT00700
  71.                 10 EmployeeName         PIC X(20).                      DAT00710
  72.                 10 EmployeeNo           PIC 9(6).                       DAT00720
  73.                 10 WageRate             PIC 9999V99.                    DAT00730
  74.                 10 WeekRecord OCCURS 52 TIMES                           DAT00740
  75.                    ASCENDING KEY IS WeekNo INDEXED BY C.                DAT00750
  76.                     15 WeekNo           PIC 99.                         DAT00760
  77.                     15 AuthAbsences     PIC 9.                          DAT00770
  78.                     15 UnauthAbsences   PIC 9.                          DAT00780
  79.                     15 LateArrivals     PIC 9.                          DAT00790
  80.                                                                         DAT00800
  81.         01 EmployeeCount                PIC 9999.                       DAT00810
  82.                                                                         DAT00820
  83.         01 VariableEmployeeTable.                                       DAT00830
  84.             05 EmployeeTable OCCURS 1 TO 1000 TIMES                     DAT00840
  85.                DEPENDING ON EmployeeCount                               DAT00850
  86.                ASCENDING KEY IS WageRate EmployeeNo                     DAT00860
  87.                INDEXED BY A, B.                                         DAT00870
  88.                 10 EmployeeName         PIC X(20) VALUE "John Doe".     DAT00880
  89.                 10 EmployeeNo           PIC 9(6).                       DAT00890
  90.                 10 WageRate             PIC 9999V99.                    DAT00900
  91.                 10 WeekRecord OCCURS 52 TIMES                           DAT00910
  92.                    ASCENDING KEY IS WeekNo INDEXED BY C.                DAT00920
  93.                     15 WeekNo           PIC 99.                         DAT00930
  94.                     15 AuthAbsences     PIC 9.                          DAT00940
  95.                     15 UnauthAbsences   PIC 9.                          DAT00950
  96.                     15 LateArrivals     PIC 9.                          DAT00960
  97.                                                                         DAT00970
  98.         01 I                    PIC 9(5).                               DAT00980
  99.                                                                         DAT00990
  100.                                                                         DAT01000
  101.         PROCEDURE DIVISION.                                             DAT01010
  102.                                                                         DAT01020
  103.         MAIN-LINE-ROUTINE.                                              DAT01030
  104.                                                                         DAT01040
  105.       * A slice here should indicate that all fields                    DAT01050
  106.       * of Date1 are defined by its initialization except TheDay.       DAT01060
  107.                                                                         DAT01070
  108.            MOVE 01 TO TheDay OF Date1.                                  DAT01080
  109.                                                                         DAT01090
  110.       * A slice here should indicate that all fields of                 DAT01100
  111.       * Date2 except TheDay are uninitialized.                          DAT01110
  112.                                                                         DAT01120
  113.            MOVE TheDay OF Date1 TO TheDay OF Date2.                     DAT01130
  114.                                                                         DAT01140
  115.       * Slices w/r/t any component of Date1 should refer only to the    DAT01150
  116.       * literal in the following statement (i.e., the assignment to     DAT01160
  117.       * `Composite' should kill all components of `Split').             DAT01170
  118.                                                                         DAT01180
  119.            MOVE 311199 TO WholeDate of Date1.                           DAT01190
  120.                                                                         DAT01200
  121.       * TheDay of Date2 should be unaffected by the following.          DAT01210
  122.                                                                         DAT01220
  123.            MOVE Dayless OF Date1 TO Dayless OF Date2.                   DAT01230
  124.                                                                         DAT01240
  125.       * After assignments below, slices w/r/t TheMonth of Date1 should  DAT01250
  126.       * refer to assignment; all other slices w/r/t                     DAT01260
  127.       * Date1 should refer to new assignments.  TheMonth of Date2 shouldDAT01270
  128.       * still be uninitialized.                                         DAT01280
  129.                                                                         DAT01290
  130.            MOVE 01 TO TheDay OF Date1.                                  DAT01300
  131.            MOVE 01 TO TheDay OF Date2.                                  DAT01310
  132.            MOVE 00 TO TheYear OF Date1.                                 DAT01320
  133.            MOVE 00 TO TheYear OF Date2.                                 DAT01330
  134.                                                                         DAT01340
  135.       * Slices w/r/t TheMonth in Date1 should refer to both of the literDAT01350
  136.       * in the following conditional; slices w/r/t to other components  DAT01360
  137.       * should refer to previous assignments.                           DAT01370
  138.                                                                         DAT01380
  139.            IF TheDay OF Date1 = TheDay OF Date2 THEN                    DAT01390
  140.              MOVE 12 TO TheMonth of Date1                               DAT01400
  141.            ELSE                                                         DAT01410
  142.              MOVE 00 TO TheMonth of Date1                               DAT01420
  143.            END-IF.                                                      DAT01430
  144.                                                                         DAT01440
  145.       * TheYear of Date2 should be unaffected by the following.         DAT01450
  146.                                                                         DAT01460
  147.            MOVE CORRESPONDING Yearless of Date3 TO Split OF Date2.      DAT01470
  148.                                                                         DAT01480
  149.       * Test effect of moves of incompatibly-sized objects.             DAT01490
  150.       * Slices w/r/t fields of Date2 should only refer to fields of     DAT01500
  151.       * Date3 (TheDay and TheMonth); TheYear of Date2 should be         DAT01510
  152.       * zero-filled, and thus not refer to a previous assignment.       DAT01520
  153.                                                                         DAT01530
  154.            MOVE Yearless OF Date3 TO Date2.                             DAT01540
  155.                                                                         DAT01550
  156.       * Test effects of moves to skewed overlapping fields: Assignment  DAT01560
  157.       * to Field1 should affect Field3 but not Field4; assignment to FieDAT01570
  158.       * should affect both Field3 and Field4.                           DAT01580
  159.                                                                         DAT01590
  160.            MOVE "AB" TO Field1 OF Overlaps.                             DAT01600
  161.            MOVE "CDE" TO Field2 OF Overlaps.                            DAT01610
  162.            MOVE Field3 OF Overlaps TO AString.                          DAT01620
  163.            MOVE Field4 OF Overlaps TO AString.                          DAT01630
  164.                                                                         DAT01640
  165.       * Test effect of reference modification; in principal, Field1     DAT01650
  166.       * isn't affected, but without information about reference modificaDAT01660
  167.       * offsets, it (along with the other fields) will probably be affecDAT01670
  168.                                                                         DAT01680
  169.            MOVE AString(1:2) TO Layout3(3:2).                           DAT01690
  170.            MOVE Field1 OF Overlaps TO AString.                          DAT01700
  171.                                                                         DAT01710
  172.       * Initialize only numeric fields in fixed length table; `EmployeeNDAT01720
  173.       * should still refer to                                           DAT01730
  174.            INITIALIZE FixedEmployeeTable REPLACING NUMERIC DATA BY 0.   DAT01740
  175.                                                                         DAT01750
  176.       * Update one field of each element in variable length table.      DAT01760
  177.                                                                         DAT01770
  178.            PERFORM VARYING I FROM 1 BY 1 UNTIL I > EmployeeCount        DAT01780
  179.                MOVE I TO EmployeeNo OF VariableEmployeeTable (I)        DAT01790
  180.            END-PERFORM.                                                 DAT01800
  181.                                                                         DAT01810
  182.       * A slice w/r/t EmployeeName should refer to the initialization   DAT01820
  183.       * in the data definition section (_not_ to the previous loop).    DAT01830
  184.                                                                         DAT01840
  185.            PERFORM VARYING I FROM 1 BY 1 UNTIL I > EmployeeCount        DAT01850
  186.                MOVE EmployeeName OF VariableEmployeeTable (I) TO AStringDAT01860
  187.            END-PERFORM.                                                 DAT01870
  188.                                                                         DAT01880
  189.                                                                         DAT01890
  190.       * A reference to an element of FixedEmployeeTable should refer    DAT01900
  191.       * to corresponding element of VariableEmployeeTable.              DAT01910
  192.                                                                         DAT01920
  193.            MOVE VariableEmployeeTable TO FixedEmployeeTable.            DAT01930
  194.                                                                         DAT01940
  195.       * References to fields of DatesOutFiles should refer to           DAT01950
  196.       * corresponding fields of DatesInFile (if any effort is made      DAT01960
  197.       * to establish this correspondence at all).                       DAT01970
  198.                                                                         DAT01980
  199.            PERFORM VARYING I FROM 1 BY 1 UNTIL I > 10                   DAT01990
  200.                 READ DatesInFile                                        DAT02000
  201.                 MOVE DatesIn TO DatesOut                                DAT02010
  202.                 WRITE DatesOut                                          DAT02020
  203.            END-PERFORM.                                                 DAT02030
  204.                                                                         DAT02040
  205.            GOBACK.                                                      DAT02050
  206.