%LEN Used to Set the Length of Variable-Length Fields

When used on the left-hand side of an expression, this function sets the current length of a variable-length field. If the set length is greater than the current length, the characters in the field between the old length and the new length are set to blanks.

Note:
%LEN can only be used on the left-hand-side of an expression when the parameter is variable length, and when *MAX is not specified.
Figure 228. %LEN with Variable-Length Field Example
 *..1....+....2....+....3....+....4....+....5....+....6....+....7...+....
D*Name++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++
 *
D city            S             40A   varying inz('North York')
D n1              S              5i 0

 * %LEN used to get the current length of a variable-length field:
 /FREE
    n1 = %len(city);
    // Current length, n1 = 10
 
    // %LEN used to set the current length of a variable-length field:
    %len (city) = 5;
    // city = 'North' (length is 5)
 
    %len (city) = 15;
    // city = 'North          '  (length is 15)
 /END-FREE


[ Top of Page | Previous Page | Next Page | Contents | Index ]