Some review and some new - features to note

Testing type of data

IF field-name IS [NOT] POSITIVE.
                       NEGATIVE.
                       ZERO.
Note: This test should be done on a numeric field. Examples:
     IF AMT POSITIVE. Could be written as:  IF AMT > 0.
     IF AMT NEGATIVE.                       IF AMT < 0. 
     IF AMT ZERO.                           IF AMT = 0.

IF field-name IS [NOT] NUMERIC.
                       ALPHABETIC.
Note: This test should be done on a alphanumeric field. Examples:
     IF FLD-IN NUMERIC.
     IF FLD-IN ALPHABETIC.
Note that most compilers are now accepting an AND or an OR statement that does not repeat the data name. For example:
	IF AMT-IN < 500 OR > 1000
The traditional coding for this would be:
 	IF AMT-IN < 500 OR AMT-IN > 1000

INITIALIZE:

The INITIALIZE statement can be used to replace a series of MOVE statements. One of the nice features of the INITIALIZE statement is that it can be used to initialize a group of fields by initializing the group name. If used with a group name all of the alphanumeric fields under that group will be initialized to spaces and all of the numeric fields will be initialized to 0.
INITIALIZE field-name1
                ALPHABETIC
                ALPHANUMERIC
     [REPLACING NUMERIC               DATA BY field-name2 ]             
	        ALPHANUMERIC-EDITED           literal-1        
		NUMERIC-EDITED
Example:
 
01  WORK-FIELDS.
    05  FLD1    PIC XXXXX.
    05  FLD2    PIC 999V99.

       INITIALIZE WORK-FIELDS.
This will initialize FLD1 at spaces and FLD2 at 0 with one move. The replacing option can be used to set fields to something other than space or 0. If the replacing clause replaces all numeric fields with 9 then only the numeric fields will be effected and they will all be set to 9. The ACCEPT statement can take in the date, day, day of week or time.
                                DATE
	ACCEPT field-name FROM  DAY 
                                DAY-OF-WEEK
                                TIME
DATE brings in 6 digits in format YYMMDD. DAY brings in 5 digit date in format YYDDD (Julian Date) DAY-OF-WEEK brings in 1 digit representing the day (1 is Monday) TIME brings in 8 digits HHMMSSCC where HH is on a 24 hour clock

FIGURATIVE CONSTANTS:

The figurative constants supported by COBOL are:

ZERO, ZEROS, ZEROES
SPACE, SPACES
HIGH-VALUE, HIGH-VALUES
LOW-VALUE, LOW-VALUES
QUOTE, QUOTES
ALL literal - which means fill the field with ALL "M" etc.

The ALL is a nice way to test line up of the printer. You might be filling in a form where you want to line up the printer and fill in boxes on a form. Before the program starts you might have a loop to print out whatever in the fields. MMMMM is a nice thing to print in test fields because it is a wide character and if it fills okay then chances are you are lined up correctly.

NAME QUALIFICATION:

Name qualification sounds like the answer to a variety of prayers, but in reality it is not used very much.
01  RECORD-IN.
    05  ITEM-NO      PIC XXX.
    05  ITEM-NAME    PIC X(20).
    05  AMT1-IN      PIC 999.
    05  AMT2-IN      PIC 99.
    05  PRICE-IN     PIC 9(5)V99.
    05  VENDOR-IN    PIC XXXX.

01  PRINTZ.
    05  FILLER       PIC X.
    05  ITEM-NO      PIC XXX.
    05  FILLER       PIC X.
    05  ITEM-NAME    PIC X(20).
    05  FILLER       PIC X.
    05  TOT-AMT      PIC Z,ZZ9.
    05  FILLER       PIC X.
    05  PRICE-IN     PIC ZZ,ZZZ.99.
    05  FILLER       PIC X.
    05  VENDOR-IN    PIC XXXX.

MOVE CORRESPONDING RECORD-IN TO PRINTZ.
This statement will move all of the fields with the same name in RECORD-IN to PRINTZ. The problem is that now every time you move or use one of the fields with a similar name you have to use name qualification to move it.
MOVE ITEM-NAME IN RECORD-IN TO ITEM-NAME IN PRINTZ.
MULTIPLY PRICE-IN IN RECORD-IN BY .05
    GIVING PRICE-IN IN PRINTZ.
If you have similarity in 05 and 10 names then you have to use qualification all the way back to a unique name.
01  REC-IN.
    05 FLD-IN.
       10 PART-1-IN PIC XXX.
If FLD-IN and PART-1-IN are both names that are used somewhere else, then the move statement would be:
MOVE PART-1-IN IN FLD-IN IN REC-IN 

Level 77:

Level 77: Somewhere you may run into a level 77, although they tend to be a legacy item. A level 77 is similar to a 01 which has not been subdivided (i.e. there is a picture clause associated with the level 77). Level 77s if used have to be the first things in Working Storage.

BLANK WHEN ZERO:

05  AMT-PR   PIC ZZZ,ZZZ.99  BLANK WHEN ZERO.
This means that if the field is 0 then blanks will print.

JUSTIFIED RIGHT:

05  EMP-NAME-PR   PIC X(20) JUSTIFIED RIGHT.
The default in an alphanumeric field is justified right - if for a certain look you would like to push the data over against the right wall, then use the JUSTIFIED RIGHT clause.

USAGE IS clause:

The possibilities are BINARY, COMPUTATIONAL, COMP, DISPLAY, INDEX, PACKED-DECIMAL (Packed decimal used to be called COMPUTATIONAL-3 or COMP-3). USAGE for non numeric field is DISPLAY. DISPLAY is also the default for numeric fields. Some mathematics work more efficiently if defined as Binary (used to be called COMP or COMPUTATIONAL) or if defined as PACKED-DECIMAL. Essentiially means the number will be stored in pure binary code and packed decimal means that it will be stored in a packed format which is a shorthand that stores the digit for all characters and the sign for the field 9each character does not use 8 bits). Mathematics such as add, subtract, multiply and divide are done with packed fields which means display data is packed prior to a calculation and then unpacked to store the answer. If work areas and accumulators have a USAGE of PACKED-DECIMAL this packing and unpacking is by passed which means the calculations saves a couple of nanoseconds or whatever. INDEX is used for the indexes that are established within at table.

REFERENCE MODIFICATION:

Field-name [(leftmost-character-position : [length]) Test 5th position for a slash:
	IF FLD-WITH-SLASH (5:1) = "/"
Move the third , fourth, fifth, sixth and seventh characters.
	MOVE WHOLE-FILED (3:5) TO ...
Note that where I have numbers, you could use data names.

INTRINSIC FUNCTIONS:

COBOL has a lift of functions, many of them to supplement limitations in mathematical abilities. Some of the ones used outside math are illustrated below - for a complete list go to help and look for intrinsic functions FUNCTION function-name [({argument}...)] [reference-modifier]
COMPUTE LEN-WS = FUNCTION LENGTH(NAME-IN).
MOVE FUNCTION UPPER-CASE(NAM-IN) TO NAM-WS.

PERFORM:

(Print out the PERFORM syntax from your HELP)

PERFORM
PERFORM B-100-PROCESS.
Performs the paragraph one time and continues with the next command.

PERFORM...UNTIL
The default of the PERFORM...UNTIL is to check before performing which means that the paragraph may not be performed at all. In Visual Basic and other languages the equivalent is the DOWHILE. COBOL provides for a WITH TEST BEFORE/WITH TEST AFTER clause with the PERFORM UNTIL. As stated above, the default is the WITH TEST BEFORE. The WITH TEST AFTER means that the paragraph will be performed at least once and the test will be whether or not it gets performed again. This logic is similar to the DOUNTIL in Visual Basic and other languages.
PERFORM B-400-PROC-LOOP
    WITH TEST AFTER
    UNTIL CTR > 5.
In this example B-400-PROC-LOOP will be performed once and then CTR will be checked to determine whether the paragraph B-400-PROC-LOOP should be done again.

PERFORM...THRU
The PERFORM...THRU (can also be written THROUGH) allows the program to specify the name of the first paragraph to perform and the last paragraph to perform (all paragraphs in-between will be performed).
PERFORM B-400-FIRST THROUGH B-440-LAST.
B-400-FIRST.
    ...
B-410-SECOND.
    ...
B-420-THIRD.
    ...
B-430-FOURTH.
    ...
B-440-LAST.
    EXIT.
This means that paragraph B-400-FIRST will be processed and then the program will drop down and execute B-410-SECOND and then B-420-THIRD etc. Traditionally the last paragraph has the word EXIT which is a command that causes no action. At this point the PERFORM is complete. If EXIT is used it is the only command in the paragraph.

PERFORM...TIMES
This means that a particular paragraph is performed the specified number of times. This can be a number or a data name that contains the number of times the paragraph is to be performed.
PERFORM B-500-ROUTINE
   CTR TIMES.

PERFORM..VARYING
PERFORM B-200-DISP
    VARYING FIELD1 FROM 1 BY 1
        UNTIL FIELD1 > 5
    AFTER FIELD2 FROM 2 BY 2 
        UNTIL FIELD2 > 8.
Field1 will start out as 1 and Field2 will start out at 2 the inner loop (which follows the after) will be performed until field2 is greater than 8. Then the outer loop will be reentered and Field1 will be incremented to 2 and field 2 will be reset to 2 and the inner loop will start all over again. Assuming that B-200-DISP shows the output, you will see the following output:
01   02
01   04
01   06
01   08
02   02
02   04
02   06
02   08
03   02 etc.