A LONGCHAR variable consists of CHARACTER data, but unlike the CHARACTER type, this type is not limited to 32K in size. A LONGCHAR variable can be larger, but it may be limited by available memory. You can use many of the ABL character handling capabilities with LONGCHAR strings. The LONGCHAR data type has metadata associated with it to designate its code page and other information. The default initial value of a LONGCHAR variable is the empty string ("").

ABL has another data type known as a character large object (CLOB). A CLOB field is a database table or temp-table field that contains a locater, which points to the associated CLOB data stored in the database. You cannot manipulate CLOB data directly. Instead, you must copy a CLOB to a LONGCHAR to manipulate the character contents of a CLOB field in ABL. You can do this with the COPY-LOB statement.

Like CLOB values, LONGCHAR values can be in any code page supported by the OpenEdge convmap.p file, and the code page information is retained by the LONGCHAR. ABL ensures that all characters are valid with respect to the code page of the LONGCHAR.

Display a LONGCHAR

Because LONGCHAR variables are large in size, you cannot display the values directly. However, there are some ways around this. For shorter LONGCHAR variables, you can assign the LONGCHAR to a CHARACTER variable and then display the CHARACTER variable. Another way is to use the STRING function to convert it to a CHARACTER value. The following example code demonstrates these ways:
VAR LONGCHAR str1 = "abcdefghijklmnopqrstuvwxyz".
VAR CHAR str2.

MESSAGE str1.  // Results in an error
  
/* Assign the LONGCHAR to a CHARACTER variable */
str2 = str1.
MESSAGE str2.

/* Use the STRING function */
MESSAGE STRING(str1).

You can display a portion of a LONGCHAR variable using the SUBSTRING function, but you must still assign the LONGCHAR variable to a CHARACTER variable. Because the input to the SUBSTRING function is a LONGCHAR, its return value is also a LONGCHAR, and you cannot directly display a LONGCHAR. The following example code shows how to display a portion of a LONGCHAR variable.

VAR LONGCHAR str1 = "abcdefghijklmnopqrstuvwxyz".
VAR CHAR str2.

MESSAGE SUBSTRING(str1,1,13,"CHARACTER").  // Results in an error

/* Use the SUBSTRING function and assign it to a CHARACTER variable */
str2 = SUBSTRING(str1,1,13,"CHARACTER").
MESSAGE str2.
You can also display a LONGCHAR by using the DISPLAY statement with the VIEW-AS EDITOR LARGE option. The following example code shows how to display a LONGCHAR using this option. Note that you must set the number of lines and the line width, in characters. The string in the following example code does not exceed 32K, but is used for illustration purposes only.
VAR LONGCHAR myLongchar = "Very long string...".

DISPLAY myLongchar VIEW-AS EDITOR LARGE 
  INNER-LINES 60 INNER-CHARS 100 WITH FRAME f1 WIDTH 120.
For more information, see the following topics in ABL Data Types Addenda: