Assignment variable


For the FIELDS keyword, an assignment variable can be specified in either of the following ways:

     :length and <data-type>
     :<string operand>

Related topic


Warning

Important

Use of an assignment variable is not allowed within an expression specified using the WHERE keyword.

An assignment variable expressed as :length and <data-type> is useful to force the conversion of a field from one data-type, size and/or precision to another. The expression shown in the following example will cause the field beginning in column 14 (a 4-byte variable in zoned decimal format) to be converted into a 6-byte packed decimal field, with two decimal digits added to the right.

     :6.2P := 14:4Z

An assignment variable is also useful to force the result of a computation into a particular data-type, size and/or precision. For example, the characteristics of the value resulting from the expression shown in the following example will be 3.0P. (The first operand is converted to a 3-byte packed decimal value, and the second is converted to a 1-byte packed value. No decimal alignment is required. The size of the result will be the size of the larger operand).

     :3P := 14:4Z + 1

If it is desired that the result be returned to zoned decimal format, a conversion such as the following example could be used.

     :4Z := 14:4Z + 1

edit picture

An assignment variable expressed as :<edit picture> is useful for converting a source value into an EBCDIC character string to perform the following:

  • Numeric edit picture.
    To format a numeric value into an EBCDIC character string
  • Date edit picture.
    To format a date time value into an EBCDIC char string

Numeric edit picture

The following examples illustrate numeric edit picture masks:

Information
Example

The following produces string 9-character string, representing a numeric value between 0 and 99,999.99 with leading zero suppression; by default, a positive number. Negative values will have a floating minus sign (-).

'ZZ,ZZ9.99'
Information
Example

The following produces a 5-character string, representing a numeric value between 0 and 9,999 with leading zero suppression; by default, a positive number. Negative values will have a floating minus sign (-).

'-,--9 -'
Information
Example

The following produces a 5 character string, representing a numeric value between 0 and 9,999 without leading zero suppression; by default, a positive number. Negative values will have a floating minus sign (-).

'9,999'

The first character of the picture string must be one of those shown in the following table:

The first character

Picture

Description

Digit

Fill

Mark

Rule

+

Leading sign treatment using floating plus sign

Yes

Blank

+

A floating leading sign character (+ or -) is placed into the edited value

Leading sign treatment using floating minus

Yes

Blank

-


$

Leading floating currency symbol

Yes

Blank

$


*

Leading filling guard symbol

Yes

*

Null


Z

Decimal digit from source

Yes

Blank



9

Decimal digit from source

Yes

0

Null


(

Leading sign treatment using floating parenthesis

No

Blank

(

If the source value is negative, a floating leading open parenthesis '(' is placed into the edited value. The last character of the picture string must be a closing parenthesis ')'

%





Cannot be first character. (% is used as first character only in the context of date edit picture)

/any

Escape picture character (message character)

No

Blank

Null


any

Message character

No

Blank

Null


The second character

The middle character(s) are defined as the sequence of edit characters from the first digit position to the last digit position. The middle character(s) of the picture string must be any of those shown in the following table.


Picture

Description

Digit

Rule

+(s)

Floating plus

Yes

Leading sign treatment must be +

–(s)

Floating minus

Yes

Leading sign treatment must be –

$(s)

Floating currency

Yes


*(s)

Filling guard

Yes


Z(s)

Decimal digit from source

Yes

Cannot be followed by any of the above

9(s)

Decimal digit from source

Yes

Cannot be followed by any of the above

·

Decimal point

No

Only one can be specified

,

1000's separator

No

Simple message character with no special meaning

+

Embedded plus

No

Simple message character with no special meaning

Embedded minus

No

Simple message character with no special meaning

(

Embedded parenthesis

No

Simple message character with no special meaning

)

Embedded parenthesis

No

Simple message character with no special meaning

/any

Escape character

No

Message character

any

Message character

No

Message character

The third character

Picture

Description

Digit

Edit mask

Rule

+

Trailing sign treatment using a plus sign

No

'+' for positive, '-' for negative


Trailing sign treatment using a minus sign

No

'-' for negative


CR

Trailing sign treatment using a string

No

'CR' for negative


)

Trailing parenthesis

No

')' for negative

Leading sign treatment must be '('

E+99

Scientific notation

No

'E+99'


Date edit picture

The date edit picture can contain substitution masks as shown in the following table. Any character string that does not match a substitution mask will appear unmodified in the result. The Example column in the following table shows the value generated if the data/time source value is Monday, January 18, 1999 at 17:42:16.743.205 Central Standard Time.

Valid substitution masks for edit picture

Mask

Definition

Example

%YYYY%

4-digit year (e.g., 1999)

1999

%YY%

2-digit year

99

%MO%

Month of year

01

%MONTH%

Month of year

January

%MON%

Abbreviated month

JAN

%DDD%

Day of year

018

%DD%

Day of month

18

%WEEKDAY%

Day of the week

Monday

%DAY%

Abbreviated day of the week

MON

%24%

Hour (military: 00-23)

17

%HH%

Hour (standard: 01-12)

05

%AM%

AM or PM

PM

%MI%

Minute (00-59)

42

%SS%

Second (00-59)

16

%T%

1/10 of second

7

%TH%

1/100 of second

74

%THM%

1/1000 of second (millisecond)

743

%I%

1/10 of millisecond

2

%IJ%

1/100 of millisecond

20

%IJU%

1/1000 of millisecond (microsecond)

205

%OFF%

Time zone offset from UDT

-06:00

%LOCAL%

Display as local time

17:42:16

%UTC%

Display as UTC

23:42:16

An example of a edit picture containing a date mask for conversion follows:

     :'%YYYY%/%MO%/%DD%' := SYSDATE()

This conversion mask would result in an 8-byte character string containing the formatted system date 1999/01/18.


 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*

Fast Path/EP products reference information 4.1