home *** CD-ROM | disk | FTP | other *** search
/ Sams Cobol 24 Hours / Sams_Cobol_24_Hours.iso / source / ch18 / chapt18c.cob < prev    next >
Text File  |  1998-09-23  |  6KB  |  155 lines

  1. 000010 @OPTIONS MAIN,TEST
  2. 000020 Identification Division.
  3. 000030 Program-Id.  Chapt18c.
  4. 000031* Sequential File Update
  5. 000043 Environment Division.
  6. 000050 Configuration Section.
  7. 000055 Source-Computer.  IBM-PC.
  8. 000056 Object-Computer.  IBM-PC.
  9. 000061 Input-Output  Section.
  10. 000062 File-Control.
  11. 000063     Select Optional Trans-File Assign To "Trans.Seq"
  12. 000064         Organization Is Line Sequential.
  13. 000066     Select Optional Dealer-File Assign To "Dealer.Seq"
  14. 000067         Organization Is Line Sequential.
  15. 000068     Select Optional Dealer-Out Assign To "Dealer.Out"
  16. 000069         Organization Is Line Sequential.
  17. 000070     Select Optional Reject-File Assign To "Reject.Txt"
  18. 000071         Organization Is Line Sequential.
  19. 000073 Data Division.
  20. 000074 File Section.
  21. 000075 Fd  Trans-File.
  22. 000076 01  Trans-Record.
  23. 000077     03  Transaction-Date   Pic  9(8).
  24. 000078     03  Transaction-Text.
  25. 000079         05  Transaction-Type   Pic  X(4).
  26. 000080         05  Transaction-Dealer Pic  X(8).
  27. 000081     03  Transaction-Price  Pic S9(7)v99.
  28. 000082     03  Transaction-Qty    Pic  9(3).
  29. 000083     03  Filler             Pic  X(40).
  30. 000084 Fd  Reject-File.
  31. 000085 01  Reject-Record          Pic X(72).
  32. 000093 Fd  Dealer-File.
  33. 000094 01  Dealer-Record.
  34. 000095     03  Dealer-Number         Pic X(8).
  35. 000096     03  Dealer-Name.
  36. 000097         05  Last-Name   Pic X(25).
  37. 000098         05  First-Name  Pic X(15).
  38. 000099         05  Middle-Name Pic X(10).
  39. 000100     03  Address-Line-1      Pic X(50).
  40. 000101     03  Address-Line-2      Pic X(50).
  41. 000102     03  City                Pic X(40).
  42. 000103     03  State-Or-Country    Pic X(20).
  43. 000104     03  Postal-Code         Pic X(15).
  44. 000105     03  Home-Phone          Pic X(20).
  45. 000106     03  Work-Phone          Pic X(20).
  46. 000107     03  Other-Phone         Pic X(20).
  47. 000108     03  Start-Date          Pic 9(8).
  48. 000109     03  Last-Rent-Paid-Date Pic 9(8).
  49. 000110     03  Next-Rent-Due-Date  Pic 9(8).
  50. 000111     03  Rent-Amount         Pic 9(4)v99.
  51. 000112     03  Consignment-Percent Pic 9(3).
  52. 000113     03  Last-Sold-Amount    Pic S9(7)v99.
  53. 000114     03  Last-Sold-Date      Pic 9(8).
  54. 000115     03  Sold-To-Date        Pic S9(7)v99.
  55. 000116     03  Commission-To-Date  Pic S9(7)v99.
  56. 000117     03  Filler              Pic X(15).
  57. 000118 Fd  Dealer-Out.
  58. 000119 01  Dealer-Out-Record       Pic X(376).
  59. 000144 Working-Storage Section.
  60. 000145 01  Current-Commission      Pic S9(7)v99 Value Zeros.
  61. 000146 01  Total-Commission        Pic S9(7)v99 Value Zeros.
  62. 000154 01  Transactions-Read       Pic 9(5) Value Zeros.
  63. 000164 01  Transactions-Rejected   Pic 9(5) Value Zeros.
  64. 000174 01  Work-Date.
  65. 000184     03  Work-MM             Pic 9(2).
  66. 000194     03  Work-DD             Pic 9(2).
  67. 000195     03  Work-YYYY           Pic 9(4).
  68. 000196 01  Reverse-Date.
  69. 000197     03  Work-YYYY           Pic 9(4).
  70. 000198     03  Work-MM             Pic 9(2).
  71. 000199     03  Work-DD             Pic 9(2).
  72. 000200 01  Compare-Date-1          Pic 9(8).
  73. 000201 01  Compare-Date-2          Pic 9(8).
  74. 000204 01  Edit-Count              Pic ZZ,ZZ9.
  75. 000205 01  Edit-Amt                Pic Z,ZZZ,ZZZ.99-.
  76. 000206 Procedure Division.
  77. 000207 Chapt18c-Start.
  78. 000208     Display "Begin Process Chapt18c"
  79. 000215     Open Output Reject-File
  80. 000225                 Dealer-Out
  81. 000235          Input  Trans-File
  82. 000245                 Dealer-File
  83. 000246     Perform Read-Dealer
  84. 000247     Perform Read-Trans
  85. 000255     Perform Process-Files Until
  86. 000265             Trans-Record = High-Values And
  87. 000275             Dealer-Record = High-Values
  88. 000285     Close Reject-File
  89. 000295           Dealer-Out
  90. 000305           Trans-File
  91. 000315           Dealer-File
  92. 000316     Move Transactions-Read To Edit-Count
  93. 000317     Display "Processing Complete"
  94. 000318     Display "Transactions Read " Edit-Count
  95. 000319     Move Transactions-Rejected To Edit-Count
  96. 000320     Display "Transactions Rejected " Edit-Count
  97. 000321     Move Total-Commission To Edit-Amt
  98. 000322     Display "Total Commission  " Edit-Amt
  99. 000323     Stop Run
  100. 000325     .
  101. 000326
  102. 000335 Process-Files.
  103. 000345     Evaluate True
  104. 000355       When Dealer-Number < Transaction-Dealer
  105. 000365            Perform Write-Dealer-Out
  106. 000375            Perform Read-Dealer
  107. 000385       When Dealer-Number > Transaction-Dealer
  108. 000395            Perform Write-Reject
  109. 000425            Perform Read-Trans
  110. 000435       When Dealer-Number = Transaction-Dealer
  111. 000445            Perform Apply-Transaction
  112. 000465            Perform Read-Trans
  113. 000475     End-Evaluate
  114. 000485     .
  115. 000495 Apply-Transaction.
  116. 000505     Compute Sold-To-Date = Sold-To-Date +
  117. 000525             (Transaction-Qty * Transaction-Price)
  118. 000526     Compute Current-Commission Rounded =
  119. 000527             (Transaction-Qty * Transaction-Price) *
  120. 000528             (Consignment-Percent / 100)
  121. 000529     Add Current-Commission To Commission-To-Date
  122. 000530                               Total-Commission
  123. 000531     Move Last-Sold-Date To Work-Date
  124. 000532     Move Corresponding Work-Date To Reverse-Date
  125. 000533     Move Reverse-Date To Compare-Date-1
  126. 000534     Move Transaction-Date To Work-Date
  127. 000535     Move Corresponding Work-Date To Reverse-Date
  128. 000536     Move Reverse-Date To Compare-Date-2
  129. 000537     If Compare-Date-2 > Compare-Date-1
  130. 000538        Move Transaction-Date To
  131. 000539             Last-Sold-Date
  132. 000540     End-If
  133. 000541     .
  134. 000542 Write-Dealer-Out.
  135. 000552     Write Dealer-Out-Record From Dealer-Record
  136. 000562     .
  137. 000563 Write-Reject.
  138. 000564     Add 1 To Transactions-Rejected
  139. 000565     Write Reject-Record From Trans-Record
  140. 000566     .
  141. 000572 Read-Dealer.
  142. 000582     Read Dealer-File
  143. 000592          At End
  144. 000602             Move High-Values To Dealer-Record
  145. 000612     End-Read
  146. 000622     .
  147. 000632 Read-Trans.
  148. 000642     Read Trans-File
  149. 000652          At End
  150. 000662             Move High-Values To Trans-Record
  151. 000663          Not At End
  152. 000664             Add 1 To Transactions-Read
  153. 000672     End-Read
  154. 000682     .
  155.