做一个摊销时间表。我在 300-REPORT 模块中设置了显示付款信息的行,然后在显示后更新该信息,就像进行了另一次付款一样。它应该在余额为 0 美元时停止,然后将其全部写入文本文件。
问题是,它显示了该行,而不是进行新的数学运算,它只是一遍又一遍地显示同一行,因此创建了一个无限循环。
300-REPORT.
MOVE WS-BEGYEAR TO WS-REP-YEAR
MOVE WS-BEGMONTH TO WS-REP-MO
MOVE WS-PRINCIPAL TO WS-REP-PRIN
MOVE WS-INTEREST TO WS-REP-INT
MOVE WS-TERM TO WS-REP-TERM
COMPUTE WS-REP-BEG-BAL-M = WS-PRINCIPAL * (1+WS-INT-DEC)
MOVE WS-REP-BEG-BAL-M TO WS-REP-BEG-BAL
MOVE WS-PRINCIPAL TO WS-REP-BEG-BAL-M
MOVE WS-PAYMENT-TOT TO WS-REP-PAYMENT
COMPUTE WS-INT-PAID-M = WS-PRINCIPAL * WS-INT-DEC
MOVE WS-INT-PAID-M TO WS-INT-PAID
COMPUTE WS-CUR-PRIN-M
= WS-PRINCIPAL - (WS-PAYMENT-TOT - WS-INT-PAID-M)
MOVE WS-CUR-PRIN-M TO WS-CUR-PRIN
COMPUTE WS-END-BAL-M = WS-REP-BEG-BAL-M - WS-PAYMENT-TOT
MOVE WS-END-BAL-M TO WS-END-BAL
WRITE OF-LINE FROM WS-TITLE3
WRITE OF-LINE FROM WS-TITLE4
WRITE OF-LINE FROM WS-LINE
WRITE OF-LINE FROM WS-PRIN-LINE
WRITE OF-LINE FROM WS-INT-LINE
WRITE OF-LINE FROM WS-TERM-LINE
WRITE OF-LINE FROM WS-LINE
WRITE OF-LINE FROM WS-HEADERS
WRITE OF-LINE FROM WS-HEADER-SEP.
PERFORM UNTIL WS-END-BAL-M IS <= 0
WRITE OF-LINE FROM WS-REP-DATA-LINE
DISPLAY WS-REP-DATA-LINE
ADD 1 TO WS-PMT-NUM
ADD 1 TO WS-REP-MO
IF WS-REP-MO = 13
ADD 1 TO WS-REP-YEAR
MOVE 01 TO WS-REP-MO
END-IF
MOVE WS-END-BAL TO WS-REP-BEG-BAL
COMPUTE WS-INT-PAID-M = WS-REP-BEG-BAL-M * WS-INT-DEC
MOVE WS-INT-PAID-M TO WS-INT-PAID
COMPUTE WS-CUR-PRIN-M =
WS-REP-BEG-BAL-M - (WS-PAYMENT-TOT - WS-INT-PAID-M)
MOVE WS-CUR-PRIN-M TO WS-CUR-PRIN
COMPUTE WS-END-BAL-M = WS-REP-BEG-BAL-M - WS-PAYMENT-TOT
MOVE WS-END-BAL-M TO WS-END-BAL
END-PERFORM