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

  1. 000010 @OPTIONS MAIN,TEST
  2. 000020 Identification Division.
  3. 000030 Program-Id.  Chapt18d.
  4. 000031* Indexed 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.Txt"
  12. 000064         Organization Is Line Sequential.
  13. 000066     Select Optional Dealer-File Assign To "Dealer.Dat"
  14. 000067         Organization Indexed
  15. 000068         Access Random
  16. 000069         Record Key Dealer-Number
  17. 000070         Alternate Record Key Dealer-Name
  18. 000071         File Status Dealer-Status.
  19. 000074     Select Optional Reject-File Assign To "Reject.Txt"
  20. 000075         Organization Is Line Sequential.
  21. 000076 Data Division.
  22. 000077 File Section.
  23. 000078 Fd  Trans-File.
  24. 000079 01  Trans-Record.
  25. 000080     03  Transaction-Date   Pic  9(8).
  26. 000081     03  Transaction-Text.
  27. 000082         05  Transaction-Type   Pic  X(4).
  28. 000083         05  Transaction-Dealer Pic  X(8).
  29. 000084     03  Transaction-Price  Pic S9(7)v99.
  30. 000085     03  Transaction-Qty    Pic  9(3).
  31. 000086     03  Filler             Pic  X(40).
  32. 000087 Fd  Reject-File.
  33. 000088 01  Reject-Record          Pic X(72).
  34. 000093 Fd  Dealer-File.
  35. 000094 01  Dealer-Record.
  36. 000095     03  Dealer-Number         Pic X(8).
  37. 000096     03  Dealer-Name.
  38. 000097         05  Last-Name   Pic X(25).
  39. 000098         05  First-Name  Pic X(15).
  40. 000099         05  Middle-Name Pic X(10).
  41. 000100     03  Address-Line-1      Pic X(50).
  42. 000101     03  Address-Line-2      Pic X(50).
  43. 000102     03  City                Pic X(40).
  44. 000103     03  State-Or-Country    Pic X(20).
  45. 000104     03  Postal-Code         Pic X(15).
  46. 000105     03  Home-Phone          Pic X(20).
  47. 000106     03  Work-Phone          Pic X(20).
  48. 000107     03  Other-Phone         Pic X(20).
  49. 000108     03  Start-Date          Pic 9(8).
  50. 000109     03  Last-Rent-Paid-Date Pic 9(8).
  51. 000110     03  Next-Rent-Due-Date  Pic 9(8).
  52. 000111     03  Rent-Amount         Pic 9(4)v99.
  53. 000112     03  Consignment-Percent Pic 9(3).
  54. 000113     03  Last-Sold-Amount    Pic S9(7)v99.
  55. 000114     03  Last-Sold-Date      Pic 9(8).
  56. 000115     03  Sold-To-Date        Pic S9(7)v99.
  57. 000116     03  Commission-To-Date  Pic S9(7)v99.
  58. 000117     03  Filler              Pic X(15).
  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. 000202 01  Used-Transaction-Flag   Pic X Value Spaces.
  75. 000203     88  Used-This-Tran      Value "Y".
  76. 000204 01  Edit-Count              Pic ZZ,ZZ9.
  77. 000205 01  Edit-Amt                Pic Z,ZZZ,ZZZ.99-.
  78. 000206 01  Dealer-Status           Pic XX Value Zeros.
  79. 000207     88  Dealer-Success  Value "00" Thru "09".
  80. 000208 01  Trans-Flag              Pic X Value Spaces.
  81. 000209     88  End-Of-Trans        Value "Y".
  82. 000211 01  Dealer-Flag             Pic X Value Spaces.
  83. 000212     88  Dealer-Error        Value "Y".
  84. 000213 Procedure Division.
  85. 000214 Declaratives.
  86. 000215 Dealer-File-Error Section.
  87. 000216     Use After Standard Error Procedure On Dealer-File
  88. 000217     .
  89. 000218 Dealer-Error-Paragraph.
  90. 000219     Display "Error on Dealer File " Dealer-Status
  91. 000220     Set Dealer-Error To True
  92. 000221     .
  93. 000222 End Declaratives.
  94. 000223 Chapt18d-Start.
  95. 000224     Display "Begin Process Chapt18d"
  96. 000225     Open Output Reject-File
  97. 000235          Input  Trans-File
  98. 000245          I-O    Dealer-File
  99. 000255     Perform Process-Files Until End-Of-Trans Or Dealer-Error
  100. 000265     Close Reject-File
  101. 000305           Trans-File
  102. 000315           Dealer-File
  103. 000316     Move Transactions-Read To Edit-Count
  104. 000317     Display "Processing Complete"
  105. 000318     Display "Transactions Read " Edit-Count
  106. 000319     Move Transactions-Rejected To Edit-Count
  107. 000320     Display "Transactions Rejected " Edit-Count
  108. 000321     Move Total-Commission To Edit-Amt
  109. 000322     Display "Total Commission  " Edit-Amt
  110. 000323     Stop Run
  111. 000325     .
  112. 000326
  113. 000335 Process-Files.
  114. 000336     Read Trans-File
  115. 000337          At End Set End-Of-Trans To True
  116. 000338          Not At End
  117. 000339              Add 1 To Transactions-Read
  118. 000340              Perform Attempt-Transaction
  119. 000341     End-Read
  120. 000485     .
  121. 000495 Attempt-Transaction.
  122. 000496     Move Transaction-Dealer To Dealer-Number
  123. 000497     Read Dealer-File
  124. 000498          Invalid Key
  125. 000499            Perform Write-Reject
  126. 000500          Not Invalid Key
  127. 000501            Perform Apply-Transaction
  128. 000502     End-Read
  129. 000503     .
  130. 000504 Apply-Transaction.
  131. 000505     Compute Sold-To-Date = Sold-To-Date +
  132. 000525             (Transaction-Qty * Transaction-Price)
  133. 000526     Compute Current-Commission Rounded =
  134. 000527             (Transaction-Qty * Transaction-Price) *
  135. 000528             (Consignment-Percent / 100)
  136. 000529     Add Current-Commission To Commission-To-Date
  137. 000530                               Total-Commission
  138. 000531     Move Last-Sold-Date To Work-Date
  139. 000532     Move Corresponding Work-Date To Reverse-Date
  140. 000533     Move Reverse-Date To Compare-Date-1
  141. 000534     Move Transaction-Date To Work-Date
  142. 000535     Move Corresponding Work-Date To Reverse-Date
  143. 000536     Move Reverse-Date To Compare-Date-2
  144. 000537     If Compare-Date-2 > Compare-Date-1
  145. 000538        Move Transaction-Date To
  146. 000539             Last-Sold-Date
  147. 000540     End-If
  148. 000541     Rewrite Dealer-Record
  149. 000542     .
  150. 000563 Write-Reject.
  151. 000564     Add 1 To Transactions-Rejected
  152. 000565     Write Reject-Record From Trans-Record
  153. 000566     .
  154.