You found that saving the value of the previously read key value of the Customer
record and checking it with key value immediately after the next read is causing
the problem.
Because the customer has one record for every company in which he holds
shares, the program logic must be changed to check only the CUST-NM of KEYREC.
Saving the CUST-NM field of KEYREC and checking it just after a READ NEXT should
solve the problem.
The changes you make to the program are (the corrected ‘after lines’ were
commented out):
Before (line 712)
MOVE KEYREC OF CUSTOMER-IO-BUFFER TO WS-CUST-KEY
After (line 713)
MOVE CUST-NM OF CUSTOMER-IO-BUFFER TO WS-CUST-NM
Before (line 723, 724)
PERFORM CALCULATE-SHARE-vaLUE
UNTIL KEY ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.
Karan Singh, Richard Davis, Anuja Deedwaniya, Michael Jägering, Redelf Janßen, Michael Morrissey, Neil O'Connor, Conrad Peche, Arunkumar Ramachandran, Richard Walton