MoveStmtContandEditedIO

advertisement
The MOVE Statement Rules for Receiving Field
NON-NUMERIC: Left justify the data in the memory location. If the length of the data
is smaller than the length of the field (as defined by the pic clause), fill to the right with
blanks. If the length of the data is larger than the length of the field (as defined by the
pic clause), truncate the data that does not fit into the memory location.
NUMERIC integer portion: Right justify the data in the integer portion of the memory
location. If the length of the data is smaller than the length of the integer portion of the
field (as defined by the pic clause), then fill to the left with zeros. If the length of the data
is larger than the length of the integer portion of the field (as defined by the pic clause),
then truncate the data to the left that does not fit into the memory location.
NUMERIC decimal portion: Left justify the data into the decimal portion of the memory
location. If the length of the data is smaller than the length of the decimal portion of the
field (as defined by the pic clause), then fill to the right with zeros. If the length of the
data is larger than the length of the decimal portion of the field (as defined by the pic
clause), then truncate the data to the right that does not fit into the memory location.
SIGN: The S character in a PIC clause denotes that the data for that memory location
can be a positive or negative value. The sign, however, does not take up a position in
memory!
FYI: Remember that truncation is used… not rounding!
Move and Edited Output
1
THE MOVE STATEMENT cont
MOVE numeric-literal TO B.
Fill in every memory location for B… use a b (lower case letter b) to denote a blank
Numeric Literal
123456
123456
B PIC
9(6)
9(5)
MEMORY LOCATIONS FOR B
_________________________
_________________________
123456
1234.56
123.456
1234.56
1234.56
9(8)
9(5)
9(4)V99
9(6)V9(3)
9(6)V9
_________________________
_________________________
_________________________
_________________________
_________________________
1234.56
12345
-12345
-12345
9(3)V9
S9(6)
S9(6)
9(6)
_________________________
_________________________
_________________________
_________________________
Move and Edited Output
2
THE MOVE STATEMENT cont
MOVE non-numeric-literal TO B.
Fill in every memory location for B… use a b (lower case letter b) to denote a blank
Non-Numeric
Literal
kitty
kitty
10 caps
B PIC
A(10)
X(8)
A(10)
MEMORY LOCATIONS FOR B
_________________________
_________________________
_________________________
10 caps
X(5)
_________________________
Move and Edited Output
3
Legal and Illegal MOVEs
Type of Move
Legal?
Alphabetic to alphabetic
Alphabetic to alphanumeric
Alphabetic to alphanumeric edited
Yes
Yes
Yes
Alphanumeric to alphanumeric
Alphanumeric to alphanumeric edited
Alphanumeric to alphabetic
Alphanumeric to numeric
Alphanumeric to numeric edited
Yes
Yes
Only if sending field is alphabetic
Only if sending field is an unsigned integer
Only if sending field is an unsigned integer
Numeric to numeric
Numeric to numeric edited
Numeric to alphanumeric
Numeric to alphanumeric edit
Numeric edited to numeric
Yes
Yes
Only if sending field is an unsigned integer
Only if sending field is an unsigned integer
Yes, to de-edit a field
Alphanumeric edited to alphanumeric
Yes, but does not de-edit a field
Move and Edited Output
4
Edited Output Characters
REMEMBER… each character holds a place in memory EX. $9,999.99
1. Insertion characters (alphnumeric editing)  B and / can be used in the picture
clause and that positions takes on a blank space or the / character
2. Insertion characters (numeric editing)  same as above using B / and 0
3. Zero suppression  (numeric editing) the letter Z denotes a blank if position is zero
4. Sign control  plus and minus sign to the right of the field; + denotes that you want
the sign to show; - denotes that you only want the sign to show up if the value is
negative… still holds a place in memory, but is blank
5. Fixed dollar sign  $ always shows up in the placed position
6. Floating dollar sign  $ shows up to the left of the most significant digit; nonsignificant positions are filled in with blanks (including commas!)
7. Check protection  asterisks (*) show up to the left of the most significant digit
8. Floating plus sign  + (see floating $ and sign control)
9. Floating minus sign  - (see floating $ and sign control
10. Other  comma and decimal point
Move and Edited Output
5
Edited Output Examples
REMINDER: the length of the “picture of receiving field” will always
be the same length as the “edit result”
Value of
Sending Field
Picture of
Receiving Field
Edit Result
392380401
03212000
392380401
3212000
125
125
123.45
1.23
1420.90
12.42
XXXBXXBXXXX
XX/XX/XXXX
999B99B9999
99/99/9999
999000
999,000
ZZZ.99
ZZZ.99
Z,ZZZ.99
Z,ZZZ.99
392b38b0401
03/21/2000
392b38b0401
03/21/2000
125000
125,000
123.45
bb1.23
1,420.90
bbb12.42
.09
Z,ZZZ.99
bbbbb.09
1234
ZZZ,ZZZ-
bb1,234b
-1234
ZZZ,ZZZ-
bb1,234-
1234
ZZZ,ZZZ+
bb1,234+
-1234
ZZZ,ZZZ+
bb1,234-
Move and Edited Output
6
Edited Output Examples cont
REMINDER: the length of the “picture of receiving field” will always
be the same length as the “edit result”
Value of
Sending Field
Picture of
Receiving Field
Edit Result
1234
1234.56
11234.56
1420.90
12.42
1420.90
12.42
1234.56
1420.90
-1420.90
12.42
-12.42
1420.90
-1420.90
12.42
-12.42
$ZZZ,ZZZ
$ZZZZ.99
$ZZZZ.99
$$,$$$.99
$$,$$$.999
$*,***.99
$*,***.99
**,***.99
++,+++.99
++,+++.99
++,+++.99
++,+++.99
--,---.99
--,---.99
--,---.99
--,---.99
$bb1,234
$1234.56
$1234.56
$1,420.90
bbb$12.420
$1,420.90
$***12.42
*1,234.56
+1,420.90
-1,420.90
bbb+12.42
bbb-12.42
1,420.90
-1,420.90
bbbb12.42
bbb-12.42
Move and Edited Output
7
Download