Kbase P17172: Trailing spaces are stripped assigning a character field through BUFFER-VALUE.
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  16/10/2008 |
|
Status: Unverified
FACT(s) (Environment):
Progress 9.1D
OpenEdge 10.0A
SYMPTOM(s):
Trailing spaces are stripped assigning a character field through BUFFER-VALUE.
CAUSE:
This is expected behavior.
BUFFER-VALUE takes the field's FORMAT into account when assigning the value to the field. This implies that, very much like when you input data from the screen, trailing spaces will be stripped. For example:
DEF VAR hBuffer AS HANDLE.
DEF VAR hField AS HANDLE.
ASSIGN hBuffer = BUFFER customer:HANDLE
hField = hBuffer:BUFFER-FIELD("Name").
DO TRANSACTION:
FIND FIRST customer EXCLUSIVE-LOCK.
hField:BUFFER-VALUE = "aa ".
DISPLAY customer.NAME LENGTH(customer.NAME).
END.
Although the string in the assignment is 5 characters long, LENGTH() returns 2, indicating that the three trailing spaces have been stripped.
FIX:
Stripping is not performed if you assign the LITERAL-QUESTION attribute for the buffer-field object to TRUE.
DEF VAR hBuffer AS HANDLE.
DEF VAR hField AS HANDLE.
ASSIGN hBuffer = BUFFER customer:HANDLE
hField = hBuffer:BUFFER-FIELD("Name")
hField:LITERAL-QUESTION = TRUE.
DO TRANSACTION:
FIND FIRST customer EXCLUSIVE-LOCK.
hField:BUFFER-VALUE = "aa ".
DISPLAY customer.NAME LENGTH(customer.NAME).
END.
LENGTH() now returns 5, meaning that the trailing spaces have not been stripped.
The LITERAL-QUESTION attribute was introduced in version 9.1D and in the latest 9.1C patch. In previous releases, it's impossible to avoid this behavior.