Available Languages: reporting
The OVRLAY function overlays a base character string with a substring. The function enables you to edit part of an alphanumeric field without replacing the entire field.
There is a version of the OVRLAY function that is available only in the Maintain language. For information on this function, see OVRLAY: Overlaying a Character String (Maintain).
OVRLAY(source_string, length, substring, sublen, position, output)
Is the base character string.
Is the number of characters in source_string and output, or a field that contains the length. If this argument is less than or equal to 0, unpredictable results occur.
Is the substring that will overlay source_string.
Is the number of characters in substring, or a field that contains the length. If this argument is less than or equal to 0, the function returns spaces.
Is the position in source_string at which the overlay begins. If this argument is less than or equal to 0, the function returns spaces. If this argument is larger than stringlen, the function returns the source string.
Is the name of the field that contains the result, or the format of the output value enclosed in single quotation marks. If the overlaid string is longer than the output field, the string is truncated to fit the field.
Note that if the overlaid string is longer than the output field, the string is truncated to fit the field.
OVRLAY replaces the last three characters of EMP_ID with CURR_JOBCODE to create a new security identification code and stores the result in NEW_ID:
TABLE FILE EMPLOYEE PRINT EMP_ID AND CURR_JOBCODE AND COMPUTE NEW_ID/A9 = OVRLAY(EMP_ID, 9, CURR_JOBCODE, 3, 7, NEW_ID); BY LAST_NAME BY FIRST_NAME WHERE DEPARTMENT EQ 'MIS'; END
The output is:
LAST_NAME FIRST_NAME EMP_ID CURR_JOBCODE NEW_ID --------- ---------- ------ ------------ ------ BLACKWOOD ROSEMARIE 326179357 B04 326179B04 CROSS BARBARA 818692173 A17 818692A17 GREENSPAN MARY 543729165 A07 543729A07 JONES DIANE 117593129 B03 117593B03 MCCOY JOHN 219984371 B02 219984B02 SMITH MARY 112847612 B14 112847B14