Advertisement
Guest User

Untitled

a guest
Sep 14th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
COBOL 1.77 KB | None | 0 0
  1. Listing 14-1. A simple SORT applied to the BillableServicesFile
  2. IDENTIFICATION DIVISION.
  3. PROGRAM-ID. Listing14-1.
  4. AUTHOR. Michael Coughlan.
  5. ENVIRONMENT DIVISION.
  6. INPUT-OUTPUT SECTION.
  7. FILE-CONTROL.
  8. SELECT WorkFile ASSIGN TO "WORK.TMP".
  9. SELECT BillableServicesFile ASSIGN TO "Listing14-1.dat"
  10. ORGANIZATION LINE SEQUENTIAL.
  11. SELECT SortedBillablesFile ASSIGN TO "Listing14-1.Srt"
  12. ORGANIZATION LINE SEQUENTIAL.
  13. DATA DIVISION.
  14. FILE SECTION.
  15. FD BillableServicesFile.
  16. 01 SubscriberRec-BSF PIC X(17).
  17. SD WorkFile.
  18. 01 WorkRec.
  19. 02 SubscriberId-WF PIC 9(10).
  20. 02 FILLER PIC X(7).
  21. FD SortedBillablesFile.
  22. 01 SubscriberRec.
  23. 88 EndOfBillablesFile VALUE HIGH-VALUES.
  24. 02 SubscriberId PIC 9(10).
  25. 02 ServiceType PIC 9.
  26. 02 ServiceCost PIC 9(4)V99.
  27. WORKING-STORAGE SECTION.
  28. 01 SubscriberTotal PIC 9(5)V99.
  29. 01 ReportHeader PIC X(33) VALUE "Universal Telecoms Monthly Report".
  30. 01 SubjectHeader PIC X(31) VALUE "SubscriberId BillableValue".
  31. 01 SubscriberLine.
  32. 02 PrnSubscriberId PIC 9(10).
  33. 02 FILLER PIC X(8) VALUE SPACES.
  34. 02 PrnSubscriberTotal PIC $$$,$$9.99.
  35. 01 PrevSubscriberId PIC 9(10).
  36. PROCEDURE DIVISION.
  37. Begin.
  38. SORT WorkFile ON ASCENDING KEY SubscriberId-WF
  39. USING BillableServicesFile
  40. GIVING SortedBillablesFile
  41. DISPLAY ReportHeader
  42. DISPLAY SubjectHeader
  43. OPEN INPUT SortedBillablesFile
  44. READ SortedBillablesFile
  45. AT END SET EndOfBillablesFile TO TRUE
  46. END-READ
  47. PERFORM UNTIL EndOfBillablesFile
  48. MOVE SubscriberId TO PrevSubscriberId, PrnSubscriberId
  49. MOVE ZEROS TO SubscriberTotal
  50. PERFORM UNTIL SubscriberId NOT EQUAL TO PrevSubscriberId
  51. ADD ServiceCost TO SubscriberTotal
  52. READ SortedBillablesFile
  53. AT END SET EndOfBillablesFile TO TRUE
  54. END-READ
  55. END-PERFORM
  56. MOVE SubscriberTotal TO PrnSubscriberTotal
  57. DISPLAY SubscriberLine
  58. END-PERFORM
  59. CLOSE SortedBillablesFile
  60. STOP RUN.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement