I had a recent inquiry into why all the warnings in Fujitsu COBOL and why have them, and how could they turn off warnings in not only COBOL, but in other mixed languages. I guess I go back to moments in my life, when I was warned “don’t do that”, and like any kid, I may have not heeded the advice, to my later dismay. Warnings are really your friend. They may seem overwhelming at times, but they may point out important things in your code, that many times you don’t even know existed.
The person with the warnings was coming from another COBOL vendor. As he looked through them, he found spots identifying problems that he had encountered intermittent issues with that he never knew existed before, as the other COBOL vendor did not warn on them. For example, extremely long COMPUTES are warned on, as you may exceed intermediate fields. It does not mean the code will not work, but it brings your attention to the thought that it should be checked, that depending on the values in the compute, you may come up with a different value than you would like, the same as if you wanted to add 99 + 99, and put it in a PIC 99 field. Another one of my favorites is if someone has an IF statement, such as “IF Field1 EQUALS (‘A’ or ‘B’)”, where if you note the parenthesis, it makes you wonder, as parenthesis are resolved first. Fujitsu is solid enough to run like that, but it is better to resolve those warnings. I have found Fujitsu COBOL to be thorough in its checking of the code, and taking the time to resolve warnings many time fixes things you did not even know you had issues with on your prior environment. So, I would take the steps to clean up the the warnings, rather than turn them off.
For my purposes, I have a test “warnings” program, which I will include at the end of this blog. You can see the flow the program is using, and the way the checking is being done. You may copy this code and try it out, to see how the warnings will react, or add your own warnings in. This code is given as is, and it is up to the end recipient to use as they wish.
If you still wish to turn off warnings, under Fujitsu COBOL you can do it with the compiler option “FLAG(x)”, where “x” is the compiler error level you want. For example "FLAG(E)” will only show you critical errors. You can consult the manuals for more compiler option and level information.
The following are screen snapshots of the project properties of where you can modify your compiler options for COBOL, C#, and VB.NET. Under NetCOBOL for .NET, it is part of your compiler options as it is under all of COBOL for Fujitsu. For more information on how to set CSharp or VB.NET Warnings or Error levels, please consult the Microsoft manuals.
(Note: You can double click on a picture to expand it).
COBOL
CSharp
VB.NET
TEST WARNING COBOL PROGRAM:
IDENTIFICATION DIVISION.
PROGRAM-ID. TESTJMWARN.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
REPOSITORY.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-ANY-KEY PIC X VALUE SPACES.
01 WS-COUNTER PIC 99 VALUE 0.
* JMN1900I-W: The level-number hierarchy is invalid.
* Note: Data is still visible, and usable.
01 WS-LEVEL-NUMBER-HIERARCHY-INV.
05 WSF2-3.
15 WSF2 PIC X(3) VALUE "ABC".
10 WSF3 PIC X(3) VALUE "DEF".
* JMN2232I-W: The length of the redefining item cannot exceed the length of the redefined item. The redefining item overlaps no items other than ones explicitly specified.
* Note: Implications are that in this case, P-LINE-DATA will not have all 15 characters. I recommend cleaning these up, as the other
* concern is that your memory mapping may not be as you want it.
01 WS-REDEFINE-A.
05 P-LINE-DATA PIC X(10) VALUE "ABCDE12345".
05 P-LINE-O REDEFINES P-LINE-DATA.
10 P-FIELD1 PIC X(5).
10 P-FIELD2 PIC X(10).
01 WS-REDEFINE-B.
05 P-LINE-DATB PIC X(15) VALUE SPACES.
05 P-LINE-OO REDEFINES P-LINE-DATB.
10 P-FIELDA PIC X(5).
*JMN2705I-W: The VALUE clause cannot be specified for an item specified in a REDEFINES clause or for its subordinate item. The VALUE clause is ignored.
*Note: P-FIELDB's data will not be placed in P-LINE-DATA at the start of the program - I don't think any compiler will do this.
10 P-FIELDB PIC X(10) VALUE "0987654321".
* JMN1020I-W - The literal must start in AREA B.
* The above warning is strictly a warning and does not affect the code.
01 SERVICE-D-NOTE-1.
05 FILLER PIC X(13) VALUE SPACES.
05 FILLER PIC X(61) VALUE
"NOTE: FOR 3P3W APPLICATIONS: A NEUTRAL SPACE IS INCLUDED IN ".
01 MYTABLE-SUB PIC 99.
01 MYTABLE.
05 MYITEMS PIC X(2) OCCURS 5 TIMES.
PROCEDURE DIVISION.
*****************************************************************
* BEGIN of JM* Examples...
PERFORM 1020I-JMN1020I-W THRU 1020I-EXIT.
PERFORM 1041I-JMN1041I-W THRU 1041I-EXIT.
PERFORM 1900I-JMN1900I-W THRU 1900I-EXIT.
PERFORM 2506I-JMN2506I-W THRU 2506I-EXIT.
PERFORM 2508I-JMN2508I-W THRU 2508I-EXIT.
PERFORM 2540I-JMN2540I-W.
PERFORM 2682I-JMN2682I-W THRU 2682I-EXIT.
MOVE SPACES TO WS-ANY-KEY.
DISPLAY "PRESS ENTER TO FINISH DEMO" UPON CONSOLE.
ACCEPT WS-ANY-KEY FROM CONSOLE.
STOP RUN.
* End of JM* Examples...
*****************************************************************
1020I-JMN1020I-W.
* JMN1020I-W - The literal must start in AREA B(See Working Storage for field in example).
* The above warning is strictly a warning and does not affect the code.
DISPLAY SERVICE-D-NOTE-1 upon console.
Accept ws-any-key from console.
1020I-EXIT.
EXIT.
1041I-JMN1041I-W.
* JMN1041I-W: A separator must follow the character string. A separator after the
* character string is assumed.
* logic still works OK
DISPLAY "ENTER A 'J' " UPON CONSOLE
ACCEPT WS-ANY-KEY FROM CONSOLE.
IF WS-ANY-KEY="J"
DISPLAY "You selected J" Upon CONSOLE
ELSE
DISPLAY "'J' NOT ENTERED " UPON CONSOLE.
DISPLAY "ENTER TO CONTINUE " UPON CONSOLE.
ACCEPT WS-ANY-KEY FROM CONSOLE.
1041I-EXIT.
EXIT.
1900I-JMN1900I-W.
* JMN1900I-W: The level-number hierarchy is invalid.
* Note: Data is still visible, and usable.
DISPLAY "WS-LEVEL-NUMBER-HIERARCHY-INV ",
WS-LEVEL-NUMBER-HIERARCHY-INV UPON CONSOLE.
1900I-EXIT.
EXIT.
2506I-JMN2506I-W.
* JMN2506I-W: A statement must be specified in a conditional statement or an in-line PERFORM statement. It is accepted as written.
MOVE SPACES TO MYITEMS(1), MYITEMS(2), MYITEMS(3)
MYITEMS(4), MYITEMS(5).
MOVE "AA" TO MYITEMS(1), MYITEMS(2), MYITEMS(3).
PERFORM VARYING MYTABLE-SUB FROM 5 BY -1
UNTIL MYITEMS(MYTABLE-SUB) NOT = SPACE
END-PERFORM
2506I-EXIT.
EXIT.
2508I-JMN2508I-W.
* JMN2508I-W 450 NEXT SENTENCE cannot be specified in an IF or SEARCH statement with an
* explicit scope terminator. It is accepted as written.
MOVE SPACES TO WS-ANY-KEY.
IF WS-ANY-KEY = ' '
IF WS-ANY-KEY = 'A' OR 'B' OR ' '
NEXT SENTENCE
ELSE
DISPLAY "JMN2508I-W TEST IN ELSE AFTER NEXT SENT"
UPON CONSOLE
END-IF
DISPLAY "JMN2508I-W TEST AFTER END-IF" UPON CONSOLE
ELSE
DISPLAY "JMN2508I-W TEST AFTER FINAL ELSE" UPON CONSOLE.
DISPLAY "JMN2508I-W TEST END" UPON CONSOLE.
ACCEPT WS-ANY-KEY FROM CONSOLE.
MOVE SPACES TO WS-ANY-KEY.
2508I-EXIT.
EXIT.
2540I-JMN2540I-W.
* JMN2540I-W The paragraph containing the EXIT statement can only consist of the procedure-name and the
* EXIT statement itself. The EXIT statement is considered to be a CONTINUE statement in this context.
MOVE 0 TO WS-COUNTER.
PERFORM 2540I-COUNT-LOOP 3 TIMES.
IF WS-COUNTER > 1
MOVE 12 TO WS-COUNTER
END-IF
DISPLAY "2540I-JMN2540I-W AFTER PERFORM LOOP "
UPON CONSOLE
EXIT.
2540I-COUNT-LOOP.
COMPUTE WS-COUNTER = WS-COUNTER + 1
DISPLAY "2540I-COUNT-LOOP " UPON CONSOLE
2540I-FELL-THRU.
DISPLAY "2540I-FELL-THRU " UPON CONSOLE.
* Try to get a clean exit by adding an EXIT here after demonstration.
* Note: to fix problem, try adding a clean exit at the point you wish to exit,
* and possibly make it a perform through...
2540I-CLEAN-EXIT.
EXIT.
2682I-JMN2682I-W.
* JMN2682I-W: A parenthesis cannot be specified in an abbreviated combined relation condition. The parenthesis is assumed to be valid.
IF WS-ANY-KEY = ('A' OR 'B' OR ' ')
DISPLAY "JMN2682I-W parenthesis still OK " upon console
else
DISPLAY "JMN2682I-W parenthesis Not OK " upon console
End-if.
2682I-EXIT.
EXIT.
END PROGRAM TESTJMWARN.

Comments
Post has no comments.