EDIT
EDIT returns a character string of length LENGTH(y). Its value is equivalent to what would result if x were assigned to a variable declared with the picture specification given by y.
For the valid picture characters, see Picture specification characters.
- x
- Expression
x must have computational type.
- y
- String expression.
y must have character type and must contain picture characters that are valid for a PICTURE data item. If y does not contain a valid picture specification, the ERROR condition is raised.
Example
dcl pic1 char(9) init ('ZZZZZZZZ9');
dcl pic2 char(7) init ('ZZ9V.99');
dcl num fixed dec (9) init (123456789);
z = edit (num, pic1); /* '123456789' */
z = edit (num, pic2); /* '789.00' */
z = edit (num, substr(pic1,8)); /* '89' */
z = edit (num, substr(pic2,1,5)); /* '789.' */
z = edit (num, substr(pic1,7,3)); /* '789' */
z = edit (num, substr(pic2,3,5)); /* '9.00' */
z = edit ('1', substr(pic1,7,3)); /* ' 1' */
z = edit ('PL/I', 'AAXA'); /* 'PL/I' */
z = edit ('PL/I', 'AAAA'); /* raises conversion */
If x cannot be edited into the picture specification given by y, the conditions raised are those that would be raised if x were assigned to a PICTURE data item which has the same picture specification contained in y.