今天在家,实现了有cobol 来对数据进行处理,打印报表,
对数据的过滤,分析很有用,下面先看一下打印的结果:
C:\MinGW\local\bin>C:\2012\cobol_t\test\SAMPLE_25
< 区段分析表 >
0 5 10 15 20 25 30 (恖)
+----+----+----+----+----+----+
0- 9| 0
10-19|* 1
20-29|** 2
30-39|**** 4
40-49|********* 9
50-59|******************* 19
60-69|******************* 19
70-79|************* 13
80-89|******* 7
90-99|**** 4
100 |* 1
(揰)
------
下面先把要分析的数据贴上来:
C:\2012\cobol_t\SAMPLE\SAMPLE_23.DAT
10001揤墫 06905806810002桸暿 06906206110003忢楥 06006906110004栐憱 07707107610005棷朑 03702904010006愇庪 04604103910007怟暿 01001501710008嵐棳 04904704210009孃楬 07008007210010廫彑 09809008910011娾栘 07006006210012崅悾 04104404710013攏暎 03503003910014杒忋 05205305110015柭悾 07806907310016柤庢 07307507910017垻晲孏 05505205310018暷戙 05105905510019梇暔 05005005010020巕媑 05105605910021嵟忋 10010010010022晉巑 06206606010023垻夑栰 06706206310024怣擹 08309108210025崟晹 05405705210026忢婅帥 05904805510027恄捠 09209409610028彫栴晹 04005004210029庤庢 05905705210030庪栰 05606105010031埨攞 05904606110032戝堜 05305505110033揤棾 09109210010034栴嶌 05805205510035彲撪 07506608110036栘慮 02502002910037嬨摢棾 06306106610038楅幁 06406506910039塤弌 07906807410040孂揷 06605607310041桼椙 09309709210042戝榓 06905906410043墌嶳 08808208010044壛屆 06206106010045桲曐 06906406210046孎栰 06107206610047愮戙 02702102810048揤恄 06606806510049擔栰 06008005510050斻埳 02004003710051崅捗 03003503810052崅椑 06606206810053埌揷 06306106410054懢揷 04604204310055彫悾 04203704810056嵅攇 07207807610057媑栰 07607107010058撨夑 04804003910059搚婍 05505205110060廳怣 07406508210061暔晹 07007207610062恗梽 07107207110063巐枩廫 07908006710064墦夑 05604805910065嶳崙 05806204710066拀屻 08409008610067栴晹 08608208410068徏塝 08108708910069榋妏 08208608510070壝悾 08007709010071杮柧 05203006910072媏抮 04104504910073媴杹 04904004210074戝暘 06106706010075戝栰 07407607110076斣彔 06306606110077彫娵 05405905910078戝梽 056054049
下面把程序附上来:
IDENTIFICATION DIVISION.
PROGRAM-ID. SAMPLE-25.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT IN-FILE ASSIGN TO "C:\2012\cobol_t\SAMPLE\SAMPLE_23.DAT".
DATA DIVISION.
FILE SECTION.
FD IN-FILE.
01 IN-REC.
02 IN-GAKUBAN PIC 9(5).
02 IN-NAME PIC X(10).
02 IN-KOKU PIC 9(3).
02 IN-SUU PIC 9(3).
02 IN-EI PIC 9(3).
WORKING-STORAGE SECTION.
01 MEISAI.
02 M-LABEL PIC X(5).
02 PIC X VALUE "|".
02 M-BAR PIC X(30).
01 SYUUKEI-TBL.
02 SYUUKEI PIC 9(2) OCCURS 11.
01 RANGE-REC.
03 RANGE-S PIC Z9.
03 PIC X VALUE "-".
03 RANGE-E PIC Z9.
01 GOUKEI PIC 9(3).
01 HEIKIN PIC 999V9.
01 COUNT_1 PIC 9(2).
01 COUNT-BAR PIC Z9.
01 END-FLG PIC 9.
01 I PIC 9(2).
01 J PIC 9(2).
01 R PIC 9(3).
PROCEDURE DIVISION.
MAIN.
OPEN INPUT IN-FILE
INITIALIZE END-FLG SYUUKEI-TBL
PERFORM UNTIL END-FLG = 1
READ IN-FILE
AT END
MOVE 1 TO END-FLG
NOT AT END
COMPUTE GOUKEI = IN-KOKU + IN-SUU + IN-EI
COMPUTE HEIKIN = GOUKEI / 3
COMPUTE I = (HEIKIN / 10) + 1
IF (I <= 11) THEN
ADD 1 TO SYUUKEI(I)
END-IF
END-READ
END-PERFORM
*
DISPLAY " < 区段分析表 >"
DISPLAY " 0 5 10 15 20 25 30 (恖)"
DISPLAY " +----+----+----+----+----+----+"
PERFORM VARYING I FROM 1 BY 1 UNTIL I > 11
COMPUTE R = (I - 1) * 10
IF R = 100 THEN
MOVE "100" TO M-LABEL
ELSE
MOVE R TO RANGE-S
COMPUTE RANGE-E = R + 9
MOVE RANGE-REC TO M-LABEL
END-IF
*
INITIALIZE M-BAR
MOVE SYUUKEI(I) TO COUNT_1
PERFORM VARYING J FROM 1 BY 1 UNTIL J > COUNT_1 OR J > 30
MOVE "*" TO M-BAR(J:1)
END-PERFORM
*
COMPUTE J = J + 4
IF J + 1 <= 30 THEN
MOVE COUNT_1 TO COUNT-BAR
MOVE COUNT-BAR TO M-BAR(J:2)
END-IF
DISPLAY MEISAI
END-PERFORM
DISPLAY " (揰)"
CLOSE IN-FILE
STOP RUN.
----------
以后下面要是要要求,要求客户安装一个cobol 的环境,编译一下修改的程序(根据业务,和分析的需要)
把客户的数据run一下,就可以了。
编译:
C:\MinGW\local\bin>htcobol -o C:\2012\cobol_t\test\SAMPLE_28 C:\2012\cobol_t\SAMPLE\SAMPLE_28.COB
执行:
C:\MinGW\local\bin>C:\2012\cobol_t\test\SAMPLE_28
(说明一下,上面利用的是cobol 的表 的特性)