home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / viscobv6.zip / vac22os2 / ibmcobol / samples / winestr / filerw.cbl < prev    next >
Text File  |  1997-01-21  |  3KB  |  82 lines

  1.       * --------------------------------------------- *
  2.       *  FILERW.CBL
  3.       *     File I/O program for the Wine Store sample.
  4.       *     Version 2
  5.       * --------------------------------------------- *
  6.  
  7.        IDENTIFICATION DIVISION.
  8.        CLASS-ID. "FileRW" Inherits SOMObject.
  9.  
  10.        ENVIRONMENT DIVISION.
  11.        Configuration Section.
  12.        Repository.
  13.             CLASS SOMObject is "SOMObject"
  14.             CLASS TheOrder is "WineOrder".
  15.  
  16.        DATA DIVISION.
  17.        Working-Storage Section.
  18.  
  19.        PROCEDURE DIVISION.
  20.  
  21.       * ========================================
  22.       * ========================================
  23.        Identification Division.
  24.        Method-Id. "XternOrder".
  25.        ENVIRONMENT DIVISION.
  26.        Input-Output Section.
  27.        File-Control.
  28.              Select OPTIONAL Orders Assign to Orders
  29.                 File Status is WS-Status-Flag
  30.                 Organization is Line Sequential.
  31.        DATA DIVISION.
  32.        File Section.
  33.        FD Orders External
  34.            Record contains 255.
  35.        01 Order-Record                 PIC X(255).
  36.        Working-Storage Section.
  37.        01 WS-Status-Flag               PIC X(2).
  38.        01 WS-Ev            Usage Pointer.
  39.        01 WS-Order-Record.
  40.            05 WS-Order-Number          PIC X(5).
  41.            05 WS-Order-Date            PIC X(10).
  42.            05 Filler                   PIC X(3).
  43.            05 WS-Items.
  44.               10 WS-Order-Count        PIC S9(4).
  45.               10 WS-Order-Item     Occurs 1 to 64
  46.                                    Depending on WS-Order-Count
  47.                                    Indexed by WS-Index.
  48.                  15 WSO-Type           PIC X(20).
  49.                  15 WSO-Cost           PIC 9(3)V99.
  50.  
  51.        Linkage Section.
  52.        01  orderObj         Usage Object Reference TheOrder.
  53.  
  54.        PROCEDURE DIVISION
  55.                    Using orderObj.
  56.            Move spaces to WS-Order-Record.
  57.            Move zero to WS-Status-Flag.
  58.       * ---------------------- Open the file
  59.            Open Extend Orders.
  60.       * ---------------------- Check file status
  61.            If (WS-Status-Flag = "00") Or
  62.                        (WS-Status-Flag = "05")
  63.               Invoke orderObj "GetOrderNumber"
  64.                      Returning WS-Order-Number
  65.               Invoke orderObj "GetOrderDate" Returning WS-Order-Date
  66.               Invoke orderObj "DescribeOrder" Returning WS-Items
  67.       * ---------------------- Write the record.
  68.               Write Order-Record from WS-Order-Record
  69.            End-if.
  70.       * ---------------------- Display a message if file I/0 failed
  71.            If WS-Status-Flag Is Not = 00
  72.               Display "   ---> File Error; code: "
  73.                       WS-Status-Flag
  74.            End-if.
  75.       * ---------------------- Close the file.
  76.            Close Orders.
  77.            Exit Method.
  78.        End Method "XternOrder".
  79.  
  80.        END CLASS "FileRW".
  81.  
  82.