Taking the following two dynamic-length elementary items:
01 color1 PIC X DYNAMIC. 01 color2 PIC X DYNAMIC.
You can compare the two items as follows:
MOVE "gray " to color1. MOVE "gray" to color2. IF color1 IS EQUAL TO color2 THEN DISPLAY "color match" ELSE DISPLAY "color mismatch" END-IF.
The result is color match, because even though the lengths of color1 and color2 differ, their contents are the same.