GET_PUBLISHED_VALUE passes NULL as space when value of variable (&VAR#) it is accessing has null string

Document ID : KB000088332
Last Modified Date : 14/04/2018
Show Technical Document Details
Issue:
The function GET_PUBLISHED_VALUE is passing a NULL as a space when the value of the variable (&VAR#) it is accessing has a null string.

As a consequence, the IF statement in the following script may evaluate &VAR# as True when comparing it to an empty string('').

 
:SET &RUNID# = ACTIVATE_UC_OBJECT(JOBS.R3.RSPARAM,WAIT)
:PRINT &RUNID#
:SET &VAR# = GET_PUBLISHED_VALUE(&RUNID#,VARIABLE1#)
:PRINT &VAR#

:IF &VAR# = ' '
: PRINT "The value is NULL"
:ELSE
: PRINT "The value is NOT null"
:ENDIF

 
Environment:
OS: All
Resolution:
This is by design.

The GET_PUBLISHED_VALUE correctly transmits the variable &VAR# as Null String.

In fact, the variable &VAR# has the value "". The comparison :IF &VAR# = ' ' is evaluated as TRUE because the trailing blank spaces are not considered in string comparisons.

The following is an excerpt from the documentation:  "Trailing blank spaces are not considered in string comparisons. Therefore, blank strings always are equal independent on their length." 

https://docs.automic.com/documentation/webhelp/english/AWA/12.0/DOCU/12.0/AWA%20Guides/help.htm#AE_AWA_Source/Script/ucaadp.htm%3FTocPath%3DAutomic%2520Scripting%2520Guide%7COrdered%2520by%2520Function%7CScript%2520Structure%2520and%2520Processing%7C_____11

If you would like to check for NULL String Values, do not use a check with IF.  Check or compare with an intermediate STR_MATCH. The STR_MATCH makes a genuine string compare, and "" and " " will not be marked as equal. 

For example:
:SET &VAR# = GET_PUBLISHED_VALUE(&RUNID#,VARIABLE1#) 
:SET &MATCH#= STR_MATCH("",&VAR#) 
:IF &MATCH# = 'Y' 
 : PRINT "The value is NULL" 
:ELSE_ 
: PRINT "The value is NOT NULL"
:ENDIF