Redefines can describe the same memory with different variables. 01 PART_RECODE USAGE DISPLAY 03 PART-TYPE PICTURE ... 03 PART_TYPE_A. 05 PART_NUMBER PICTURE ... 05 PART_COST PICTURE ... 03 PART_TYPE_B REDEFINES PART_TYPE_A. 05 UPC_CODE PICTURE ... 03 PART_TYPE_C REDEFINES PART_TYPE_A. 05 ISBN PICTURE ... according to Part_type decided to use part_type_a or part_type_b or part_type_c. Rules: Part_type_b and part_type_c length cannot be greater than part_type_a. Data items cannot be Value. 01 layers cannot be used in redefines. Part_type_b and part_type_c do not have OCCURS.
Picture defines the specific length, format, and data type of the basic item. It can be short-written to the PIC. The format string can include the following characters: A letter AZ, AZ, space B inserts the space P scheduling character, and the decimal point s algebraic symbols not displayed in the field, the actual display depends on the project USAGE V Digital Point Position X Any character z suppressed 0 of the leader 0 and converted into empty characters 0 inserted 0 9 numbers 0 to 9 / insert /, inserted, (comma could not be used as the last bit of the string, the last comma is a separator). insert. * Inhibition of 0 and convert to * positive insert , negative value insert--Positive insert space, negatively insert-$ inserted into the US CR positive value inserted two spaces, negatively inserted Cr DB positive value inserted two Space, negative value insertion DB example: 03 VAR PIC AAAAA. VAR variable length is 5 characters, no numbers, equivalent to 03 State Pic A (5). Enter asdfg to display the ASDFG 03 VAR PIC XXXXX. VAR variable length is 5 arbitrary characters. Equivalent to 03 FILLER PIC X (5). Enter 123AS, display 123AS 03 VAR PIC 99 / XXX / 9999 length 11, input 05may2004, display 05 / May / 2004 03 VAR PIC 0ABXXX / 9999 length 11, input 05may2004, display 05 May / 2004 03 VAR PIC 9 (3) length 3, between 3, 0 ~ 999. 03 VAR PIC 9 (4) V99 length 6, 0.00 ~ 9999.99. 03 VAR PIC S9 (5) V99 length 7, between -99999.99 ~ 99999.99 between. 03 VAR PIC 9 (6) PPP length 6, can be 1000, 2000, ..., 999999000. Input 1234, display 1000. 03 VAR PIC PIC PPP999 length between 3,0.000001 ~ 0.000999. Input 123, display 0.000123.
03 VAR PIC ZZ.99, input 100.50, display 100.50; input -51.50, display 51.50; input 0, display .00. 03 var pic $ zz.zz-, enter 100.50, display $ 100.50; input -51.50, display $ 51.50-; Enter 0, display 03 VAR PIC $ ***, ***. 99CR, input 1000, display $ ** 1000.00; enter $ ** 1000.00cr; enter 0, display $ ***, *** .00; input 51.5, display $ ***, * 51.50 03 VAR PIC $$$, $$$. 99.50, display $ 100.50; input $ 100.50; enter 0.777, display $ .77; input 0 , Display $ .00 03 VAR PIC $. $$$, type 1.00, display $ .00; enter $ .65; enter 0, display $ .00; 03 var pic $ -, enter 17.7, display $ 17 Input -17.7, display $ -1; input -5, display $ -5 03 VAR PIC $ 999.99 , enter $ 100.50 ; input -100.50, display $ 100.50-; 03 VAR PIC 9 (3) b9 (3) , Input 55, display 000 055; input 1000.78, display 001 000; 03 FILLER PIC X (44), add 44 vacancy USAGE to represent the type of basic or group data. There are binary, computational (comp), display, index, packed-decimal.justified 03 var1 pic x (5) Justified Right. 03 var2 pic x (5). Enter XYZ, VAR1 display "XYZ", VAR2 display is "Xyz".
Blank When Zero 03 VAR PIC $ 999,999.99 Blank when Zero. When the field value is 0, this project is set to all spaces.
When Value is defined, you assign a value. 03 VAR PIC X (5) Value "abcde". 01 var value all spaces. 03 var1 pic xx. 03 var2 pic xx.
The operation order of the operator in the arithmetic statement COBOL is: Take the positive ( ), the maximum, index operation (**) second, multiply (*), in addition to (/), plus ( ), reduce (-)At last. Rounded rounding operation. 77 A PIC 9V9 Value 9.1. 77 B PIC 9. Add 0.5 to a giving b on size error Go to proc1. Add 0.5 to a giving b Rounded on size error Go to proc2. End-add.on size error is when the statement appears Perform it when it is wrong. In this example, there is no error, so on size error does not perform Proc1. In the second sentence, when 0.5 plus 9.1 gets 9.6, because there is Rounded, the rounding operation is performed to obtain 10. And B is only 1 digit, so an error occurs, performs on size error operation, and performs Proc2. The Corresponding (CORR) data item is written in the same name. Add and Substract have this option. 01 a. 03 B. 05 B1 PIC 999V99. 05 B1 PIC 999V99. 03 C. 05 B1 PIC 999V99. 05 B1 PIC 999V99. 05 B1 PIC 999V99. The statement add corr b to C. Equivalent to execution The following three statements below. Add B1 of B TO B1 of C. Add B2 of B TO B2 of C. Add B3 of B TO B3 of C. Group items do not have to format. The content in a group project can not be in another group project, and the data item order is also insignificant. It is only necessary to correspond to the name of the data item. Add A, B Giving C. end-add. Add A and B to C. Subtract A, B from C. End-subtract. Subtract A, B. Multiply A by b giving c. end-multiply from C. End-multiply. Put a, b. Divid a INTO B GIVING C. End-Divide. Add B in the result of A. Divide a by b giving c. end-divide. Put A by the result of the B is placed in C. Divide A By B Giving C Remainder D. Put A in C, the remainder is placed in D = AB * C. 77 C Pic S99V9. 77 D PIC S99V9. Divide 3 INTO 7 GIVING C Remainder D. C is 2.3, D is 0.1. (D = 7-3 * 2.3) Compute In addition to the payment, other operations can be used in other operations. This statement evaluates an arithmetic expression and stores the results in one or more variables. Compute A Rounded, B = x * Y / (N M) Z. Store the results of X * Y / (N M) Z in B, and then put into A.
Move Move A to B. You can also use the CORR option. Move Corr A to B.