Consultor Eletrônico



Kbase P107344: 4GL/ABL: Error 42 nesting a LENGTH function in a SUBSTRING function when the string LENGTH is too l
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   08/12/2009
Status: Verified

SYMPTOM(s):

4GL/ABL: Error 42 nesting a LENGTH function in a SUBSTRING function when the string LENGTH is too large.

bfx: Field too large for a data item. Try to increase -s. (42)

Executing code similar to:
DEFINE VARIABLE cString AS CHARACTER NO-UNDO.
ASSIGN
cString = FILL('*',31991).
MESSAGE SUBSTRING(cString, LENGTH(cString))
VIEW-AS ALERT-BOX INFO BUTTONS OK.

FACT(s) (Environment):

Progress 9.1x
OpenEdge 10.x
Under OpenEdge 10.1B and OpenEdge 10.1C, the error is not generated if the LENGTH of the string is less than 17764.
Under Progress 9.1E, the error is not generated if the LENGTH of the string is less than 17996.

CAUSE:

Bug# OE00118713

FIX:

Introduce an intermediate variable to store the value returned by the LENGTH function and use that variable in the SUBSTRING function call rather than nesting the LENGTH function call within the SUBSTRING function call. For example:
DEFINE VARIABLE cString AS CHARACTER NO-UNDO.
DEFINE VARIABLE iLength AS INTEGER NO-UNDO.
ASSIGN
cString = FILL('*',31991)
iLength = LENGTH(cString).
MESSAGE SUBSTRING(cString,iLength)
VIEW-AS ALERT-BOX INFO BUTTONS OK.