阅读更多
1、COMPUTE A = + B,A = - B 一般为笔误,执行结果:A的值等于|B|。
测试:
MOVE 5 TO WK-INPUT
MOVE 5 TO WK-OUTPUT
或者
MOVE -5 TO WK-INPUT
MOVE -5 TO WK-OUTPUT
COMPUTE WK-OUTPUT = + WK-INPUT
执行结果:WK-OUTPUT结果为5.
COMPUTE WK-OUTPUT = - WK-INPUT
执行结果:WK-OUTPUT结果为5.
2、THRU笔误:编译测试均通过
以下包括THRU执行流程、THRU笔误执行测试。
如下笔误:
…… ==> 该部分代码正常执行
PERFORM XXXX-TEST-PREFORM
THRU XXXX-TEST-PREFORM EXIT ==> 红色字为COBOL关键字 不执行XXXX-TEST-PROFORM-EXIT
…… ==> 该部分代码正常执行
XXXX-TEST-PROFORM-EXIT.
EXIT.
上述语句编译成功,不影响正常程序流,程序执行步骤完全一致,所有测试全部通过。
EXIT语句,其实就是标识而已,不起作用。
若XXXX-TEST-PROFORM-EXIT写法如下,执行结果会有很大不同。若写法如下,可能是程序退出点,但因为未正确书写“THRUXXXX-TEST-PROFORM-EXIT”,则程序不会执行该段,导致程序无法退出。
XXXX-TEST-PROFORM-EXIT.
GOBACK./STOP RUN.
测试程序如下:
PROCEDURE DIVISION.
*
MAIN-ROUTINE.
*
DISPLAY 'MAIN ROUTINE START'.
*
PERFORM A-ROUTINE
THRU A-ROUTINE-EXIT
*
DISPLAY '== START EXEC A-C ROUTINE =='.
PERFORM A-ROUTINE
THRU C-ROUTINE-EXIT
DISPLAY '== END EXEC A-C ROUTINE =='.
*
PERFORM B-ROUTINE
THRU B-ROUTINE-EXIT
*
PERFORM C-ROUTINE
THRU C-ROUTINE EXIT
DISPLAY 'C-ROUTINE EXIT IN MAIN'.
*
PERFORM C-ROUTINE
THRU C-ROUTINE-EXIT
DISPLAY 'C-ROUTINE-EXIT IN MAIN'.
*
PERFORM D-ROUTINE
THRU D-ROUTINE-EXIT
*
DISPLAY 'MAIN ROUTINE END'.
MAIN-ROUTINE-EXIT.
STOP RUN.
*
A-ROUTINE.
DISPLAY 'EXEC A ROUTINE'.
A-ROUTINE-EXIT.
DISPLAY 'EXEC A ROUTINE EXIT'.
EXIT.
*
B-ROUTINE.
DISPLAY 'EXEC B ROUTINE'.
B-ROUTINE-EXIT.
DISPLAY 'EXEC B ROUTINE EXIT'.
EXIT.
*
C-ROUTINE.
DISPLAY 'EXEC C ROUTINE'.
C-ROUTINE-EXIT.
DISPLAY 'C-ROUTINE-EXIT IN C'.
EXIT.
*
D-ROUTINE.
DISPLAY 'EXEC D ROUTINE'.
D-ROUTINE-EXIT.
DISPLAY 'EXEC D ROUTINE EXIT'.
EXIT.
*
执行结果如下:
MAIN ROUTINE START
EXEC A ROUTINE
EXEC A ROUTINE EXIT
== START EXEC A-C ROUTINE ==
EXEC A ROUTINE
EXEC A ROUTINE EXIT
EXEC B ROUTINE
EXEC B ROUTINE EXIT
EXEC C ROUTINE
C-ROUTINE-EXIT IN C
== END EXEC A-C ROUTINE ==
EXEC B ROUTINE
EXEC B ROUTINE EXIT
EXEC C ROUTINE
C-ROUTINE EXIT IN MAIN
EXEC C ROUTINE
C-ROUTINE-EXIT IN C
C-ROUTINE-EXIT IN MAIN
EXEC D ROUTINE
EXEC D ROUTINE EXIT
MAIN ROUTINE END
转自:http://hi.baidu.com/clisdena/item/01857711271c686c70d5e8d0
3,
IDENTIFICATION DIVISION.
PROGRAM-ID. PGM012.
AUTHOR. MAINFRAMEWIZARD.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-SUB PIC 9(3) VALUE ZEROS.
PROCEDURE DIVISION.
10000-MAIN-PARA.
PERFORM 20000-FIRST-PARA THRU 30000-THIRD-PARA
DISPLAY 'DEPICTING PERFORM THRU BY MAINFRAMEWIZARD.COM'
DISPLAY 'PARA NAME IS 10000-FIRST-PARA'
STOP RUN.
20000-FIRST-PARA.
DISPLAY 'PARA NAME IS 20000-FIRST-PARA'.
25000-SECOND-PARA.
DISPLAY 'PARA NAME IS 25000-SECOND-PARA'.
30000-THIRD-PARA.
DISPLAY 'PARA NAME IS 30000-THIRD-PARA'
Output of the above program is as below
PARA NAME IS 20000-FIRST-PARA
PARA NAME IS 25000-SECOND-PARA
PARA NAME IS 30000-THIRD-PARA
DEPICTING PERFORM THRU BY MAINFRAMEWIZARD.COM
PARA NAME IS 10000-FIRST-PARA
- See more at: http://www.mainframewizard.com/content/cobol-perform-thru#sthash.SBBE20eI.dpuf