Edit Numeric (CLEDIT)

Where allowed to run:
  • Batch program (*BPGM)
  • Interactive program (*IPGM)
  • Batch ILE CL module (*BMOD)
  • Interactive ILE CL module (*IMOD)
Threadsafe: No
Parameters
Examples
Error messages

The Edit Numeric (CLEDIT) command converts a numeric CL variable to character after applying an edit code or edit word.

Top

Parameters

Keyword Description Choices Notes
VAR CL variable for edited value Character value Required, Positional 1
VALUE Numeric value to edit Not restricted Required, Positional 2
EDIT Edit code/Word Character value, 1, 2, 3, 4, A, B, C, D, J, K, L, M, N, O, P, Q, X Optional, Positional 3
TRIM Trim blanks (left adjust) *YES, *NO Optional, Positional 4
Top

CL variable for edited value (VAR)

Specify any CL variable of TYPE(*CHAR) to receive the edited numeric value.

This is a required parameter.

character CL-variable, any length.
Top

Numeric value to edit (VALUE)

Specify any valid numeric CL variable. This variable's value is converted to character format after appling the edit code or editword specified on the EDIT parameter. Sadly, IBM provides no method to mimic the CHGVAR's VALUE parameter. Therefore an arithmetic express is NOT allowed on this parameter. Only a CL variable name may be specified.

This is a required parameter.

any numeric data type, any length and decimals
Top

Edit code or edit word (EDIT)

Specifies the edit code (1-9, A-D, J-M, N-Q or X) or any valid EDIT WORD pattern to apply to the numeric value value specified on this parameter. If the value for this parameter is longer than 1 position and is NOT 'X-' or '-X', then it is assumed to be an Edit Word. Otherwise it is an edit code.

P
The default 'P' edit code provides the most common form or edit: -12345.67
character-value
Specify any valid edit word mask to be used or one of the following valid edit codes:

                       ------  "Status"  -------
                       ---- (Negative Sign) ----
 Thousands   Zero           Right-Side Left-Side
 Separator   Supress   None  CR Minus    Minus
    Yes       Yes       1    A    J        N
    Yes       No        2    B    K        O
    No        Yes       3    C    L        P
    No        No        4    D    M        Q

Top

Trim blanks (left adjust) (TRIM)

Specifies whether the returned, edited value has leading blanks truncated.

*YES
Blanks that appear on the left-side of the returned value are removed. The resulting edited value is stored left-justifed in the return variable.
*NO
Blanks that appear on the lef-side of the returned value are retained. The full value is returned, including leading (left-side) blanks.
Top

Examples for CLEDIT

Example 1: Using the Default Edit Code

DCL VAR(&AMOUNT) TYPE(*DEC) LEN(7 2)
DCL VAR(&AMT)    TYPE(*CHAR) LEN(10)
CHGVAR VAR(&AMOUNT) VALUE(1250.25)
CLEDIT  VAR(&AMT) VALUE(&AMOUNT)

This example converts the packed decimal data in &AMOUNT into character using the default editcode 'P'. The result is: ' 1250.25' However since TRIM(*YES) is the default, the actual value returned is '1250.25' (leading blanks are removed).

Example 2: Using an Edit Word

DCL VAR(&LEN)  TYPE(*DEC) LEN(5 0)
DCL VAR(&LENA) TYPE(*CHAR) LEN(5)
CHGVAR VAR(&LEN) VALUE(64)       /* .....  */
CLEDIT VAR(&LENA) VALUE(&LEN) EDIT('0    ')

This example converts the value in &LEN to text by applying the edit word specified. The result is: '0064'

Top

Error messages

Unknown
Top