4

I'm using Visual Cobol to create a program that reads a file, has the user input criteria, and only displays the records in the file that meet the user's criteria. I need to display the number of records that meet the criteria, which I have done with an accumulator, but I also need to display the total number of records in the file, including the ones not displayed.

I am wondering if I can do it in a Sort statement. I have tried a few things but I'm unsure of the syntax needed.

This is my current sort statement:

   B-100-PROCESS-FILE.

       PERFORM B-200-CRITERIA-CONTROL.

       SORT SORT-FILE
           ON DESCENDING KEY SR-UNIT-COST

           INPUT PROCEDURE B-210-SELECT-RECORDS
           OUTPUT PROCEDURE B-220-DISPLAY-REPORT.

New addition:

   B-210-SELECT-RECORDS.

       OPEN INPUT CUSTOMER-SALES-FILE
       MOVE "N" TO SW-END-OF-FILE.

       READ CUSTOMER-SALES-FILE INTO CUSTOMER-SALES-RECORD

          AT END MOVE "Y" TO SW-END-OF-FILE
          NOT AT END ADD 1 TO AC-RECORD-TOTAL

       PERFORM B-370-RELEASE-RECORDS
           UNTIL END-OF-FILE.

       CLOSE CUSTOMER-SALES-FILE.

almost there...

Loonette
  • 47
  • 3

1 Answers1

0

I have a possible solution:

   OPEN INPUT CUSTOMER-SALES-FILE
   MOVE "N" TO SW-END-OF-FILE.

   READ CUSTOMER-SALES-FILE INTO CUSTOMER-SALES-RECORD

      AT END MOVE "Y" TO SW-END-OF-FILE
   END-READ
   IF SW-END-OF-FILE NOT= 'Y'
      ADD 1 TO WS-CONT
   END-IF 


   PERFORM B-370-RELEASE-RECORDS
       UNTIL END-OF-FILE.

   CLOSE CUSTOMER-SALES-FILE.