The PICTURE clause describes the general characteristics of an elementary data item. These characteristics are described below.
(a) class:
A data item may be one of the three classes – numeric, alphabetic or alphanumeric. As indicated by these names, the numeric items consist only of digits 0 to 9 and the alphabetic items consist only of the letters A to Z and the space (blank) character. The alphanumeric items may consist of digits, letters, as well as special characters.
(b) Sign:
A numeric data item can be signed or unsigned. Implicitly, a numeric data is considered as unsigned and during execution such unsigned data items are treated as positive quantities.
(c) Point Location:
The position of the decimal point is another characteristic that can be specified in the case of numeric data items. If the said position is not specified, the item is considered to be an integer.
(d) Size:
Size is another characteristic which specify the number of characters or digits required to store the data item in the memory.
The four general characteristics described above can be specified through a PICTURE clause.
The PICTURE clause is to be flowed by a picture character string as shown below.
PICTURE
PIC Is Character-string
The character string can consist of 1 to 30 code characters that define the above mentioned attributes of the elementary item. The code character and their interpretations are given below.
Code character Meaning
9 Each occurrence of this code in the picture string indicates that the corresponding character position in the data item contains a numeral.
X Each occurrence of this code indicates that the corresponding character position in the data item contains any allowable character from the COBOL character set.
A Each occurrence of this code indicates that the corresponding character position in the data item contains only a letter or space character.
V The occurrence of this in a picture string indicates the position of the assumed decimal point.
P The occurrence of this indicates the position of the assumed decimal point when the point lies outside the data item.
S The occurrence of this indicates that the data item is signed.
Example: 1
PICTURE IS S999V99
Means that the data is a signed numeric with a size of 5 characters and the position of the assumed decimal point is before 2 places from the rightmost end.
Example: 2
PIC IS PPP999
Means that the numeric data is of 3 characters in size and there are 6 positions after the assumed decimal point. Thus if the data in the memory is 375, the value will be taken as .000375. If, on the other hand, the picture were defined as 999PP, the value would have been 37500.
Example: 3
PIC XXXXX
Means that the data is alphanumeric with a size of 6 characters.
Instead of repeating 9, X, A or P in the picture string, it is possible to write the number of occurrences of a character enclosed within parentheses immediately after the said character.
VALUE Clause:
The VALUE clause defines the initial value of a data item.
Syntax:
VALUE IS literal
The literal can be any numeric value, a nonnumeric string of character included within quote (“) or any figurative constant.
Examples
VALUE IS 3.5
VALUE IS “MY DATA”
VALUED ZERO
what is non editing picture clause
ReplyDeletewhat are the difference between non editing and editing picture clause?
ReplyDelete