Ken:
Here is sample code - you need to use a IF statement to check for a ? (null
value) with date fields.
Sample code:
DEF VAR d1 AS DATE.
DEF VAR d2 AS DATE.
DEF VAR d3 AS DATE.
DEF VAR c AS CHAR FORMAT "x(50)".
ASSIGN d1 = TODAY d2 = TODAY + 10 d3 = ?.
c = (IF d1 = ? THEN "" ELSE string(d1)) + "|" + (IF d3 = ? THEN "" ELSE
string(d3)) + "|" + (IF d2 = ? THEN "" ELSE string(d2)) + "|".
DISPLAY c FORMAT "x(50)".
I hope it helps.
Carl Peterson
Nexus Software, Inc.
From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of
Brian W. Spolarich
Sent: Thursday, January 07, 2010 4:20 PM
To: vantage@yahoogroups.com
Subject: [Vantage] 4GL Null Values Break BPM
I have a fairly simple 4GL BPM that I want to deploy. But I've found a
case where it doesn't work and I'm not sure why.
Business case: Provide a report that shows date changes to sales
order releases, watching three fields: OrderRel.ReqDate, NeedByDate,
and Date01.
I created a preprocessing BPM that fires on SalesOrder.Update when any
of these three fields is changed from any to any. It executes the 4GL
code below.
This works great for existing SalesOrders, but I can't create new
ones, nor can I modify existing releases if an existing value of any of
these fields is currently null. Vantage complains that "Character01
cannot be null", as it is blowing up at my Assign statement at the end.
I have some logging. When things work they produce logs like this:
[10/01/07@16:06:19.365-0500] P-008360 T-005836 4 AS AS -- TRACE:
SINGLE-RUN Procedure bo/SalesOrder.p:Update START (8458)
[10/01/07@16:06:19.396-0500] P-008360 T-005836 1 AS -- (Procedure:
'UpdatePre26_A1 bo/SalesOrder.p' Line:5871) Processing 500618/1/1
[10/01/07@16:06:19.396-0500] P-008360 T-005836 1 AS -- (Procedure:
'UpdatePre26_A1 bo/SalesOrder.p' Line:5877) ttdata:
12/25/09|12/25/09|01/06/10
[10/01/07@16:06:19.396-0500] P-008360 T-005836 1 AS -- (Procedure:
'UpdatePre26_A1 bo/SalesOrder.p' Line:5877) data:
12/25/09|12/25/09|01/21/10
[10/01/07@16:06:19.396-0500] P-008360 T-005836 1 AS -- (Procedure:
'UpdatePre26_A1 bo/SalesOrder.p' Line:5894) Changemsg: 01/07/10:
CustReqDate - 01/21/10 -> 01/06/10; (bspolarich)
When they don't:
[10/01/07@16:06:32.536-0500] P-008360 T-005836 4 AS AS -- TRACE:
SINGLE-RUN Procedure bo/SalesOrder.p:Update START (8458)
[10/01/07@16:06:32.568-0500] P-008360 T-005836 1 AS -- (Procedure:
'UpdatePre26_A1 bo/SalesOrder.p' Line:5871) Processing 500618/1/1
[10/01/07@16:06:32.583-0500] P-008360 T-005836 1 AS -- (Procedure:
'UpdatePre26_A1 bo/SalesOrder.p' Line:5877) ?
[10/01/07@16:06:32.583-0500] P-008360 T-005836 1 AS -- (Procedure:
'UpdatePre26_A1 bo/SalesOrder.p' Line:5894) ?
So the fact that either my Before or After data has null values breaks
my code. Despite the fact that I set my "changemsg" variable to have a
value even before I start evaluating data, it winds up as the null value
(evidenced by the "?" in the logs), and hence the Assign statement
breaks.
How do I fix this?
-bws
--
Brian W. Spolarich ~ Manager, Information Services ~ Advanced Photonix /
Picometrix
bspolarich@... <mailto:bspolarich%40advancedphotonix.com>
<mailto:bspolarich@...
<mailto:bspolarich%40advancedphotonix.com> > ~ 734-864-5618 ~
www.advancedphotonix.com <http://www.advancedphotonix.com>
define variable rightnow as character no-undo.
define variable changemsg as character no-undo.
define variable orderlinerel as character no-undo.
define variable databuffer as character no-undo.
rightnow = string(date(now)).
changemsg = rightnow + ": ".
for each ttOrderRel where ttOrderRel.RowMod = 'U' no-lock:
orderlinerel = string(ttOrderRel.OrderNum) + "/" +
string(ttOrderRel.OrderLine) + "/" + string(ttOrderRel.OrderRelNum).
message "Processing " + orderlinerel.
find OrderRel where OrderRel.Company =
ttOrderRel.Company and OrderRel.OrderNum = ttOrderRel.OrderNum and
OrderRel.OrderLine = ttOrderRel.OrderLine and OrderRel.OrderRelNum =
ttOrderRel.OrderRelNum.
databuffer = "ttdata: " + string(ttOrderRel.ReqDate) + "|" +
string(ttOrderRel.NeedByDate) + "|" + string(ttOrderRel.Date01) + "~n" +
"data: " + string(OrderRel.ReqDate) + "|" + string(OrderRel.NeedByDate)
+ "|" + string(OrderRel.Date01) + "~n".
message databuffer.
if ttOrderRel.ReqDate <> OrderRel.ReqDate then do:
changemsg = changemsg + "ShipDate - " +
string(OrderRel.ReqDate) + " -> " + string(ttOrderRel.ReqDate) + "; ".
end.
if ttOrderRel.NeedByDate <> OrderRel.NeedByDate then do:
changemsg = changemsg + "NeedByDate - "
+ string(OrderRel.NeedByDate) + " -> " + string(ttOrderRel.NeedByDate) +
"; ".
end.
if ttOrderRel.Date01 <> OrderRel.Date01 then do:
changemsg = changemsg + "CustReqDate - "
+ string(OrderRel.Date01) + " -> " + string(ttOrderRel.Date01) + "; ".
end.
changemsg = changemsg + " (" + DCD-USERID + ")".
if ttOrderRel.Character01 <> "" then do:
changemsg = "~n" + changemsg.
end.
message "Changemsg: " + changemsg.
Assign ttOrderRel.Character01 = ttOrderRel.Character01 +
changemsg.
end.
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
Here is sample code - you need to use a IF statement to check for a ? (null
value) with date fields.
Sample code:
DEF VAR d1 AS DATE.
DEF VAR d2 AS DATE.
DEF VAR d3 AS DATE.
DEF VAR c AS CHAR FORMAT "x(50)".
ASSIGN d1 = TODAY d2 = TODAY + 10 d3 = ?.
c = (IF d1 = ? THEN "" ELSE string(d1)) + "|" + (IF d3 = ? THEN "" ELSE
string(d3)) + "|" + (IF d2 = ? THEN "" ELSE string(d2)) + "|".
DISPLAY c FORMAT "x(50)".
I hope it helps.
Carl Peterson
Nexus Software, Inc.
From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of
Brian W. Spolarich
Sent: Thursday, January 07, 2010 4:20 PM
To: vantage@yahoogroups.com
Subject: [Vantage] 4GL Null Values Break BPM
I have a fairly simple 4GL BPM that I want to deploy. But I've found a
case where it doesn't work and I'm not sure why.
Business case: Provide a report that shows date changes to sales
order releases, watching three fields: OrderRel.ReqDate, NeedByDate,
and Date01.
I created a preprocessing BPM that fires on SalesOrder.Update when any
of these three fields is changed from any to any. It executes the 4GL
code below.
This works great for existing SalesOrders, but I can't create new
ones, nor can I modify existing releases if an existing value of any of
these fields is currently null. Vantage complains that "Character01
cannot be null", as it is blowing up at my Assign statement at the end.
I have some logging. When things work they produce logs like this:
[10/01/07@16:06:19.365-0500] P-008360 T-005836 4 AS AS -- TRACE:
SINGLE-RUN Procedure bo/SalesOrder.p:Update START (8458)
[10/01/07@16:06:19.396-0500] P-008360 T-005836 1 AS -- (Procedure:
'UpdatePre26_A1 bo/SalesOrder.p' Line:5871) Processing 500618/1/1
[10/01/07@16:06:19.396-0500] P-008360 T-005836 1 AS -- (Procedure:
'UpdatePre26_A1 bo/SalesOrder.p' Line:5877) ttdata:
12/25/09|12/25/09|01/06/10
[10/01/07@16:06:19.396-0500] P-008360 T-005836 1 AS -- (Procedure:
'UpdatePre26_A1 bo/SalesOrder.p' Line:5877) data:
12/25/09|12/25/09|01/21/10
[10/01/07@16:06:19.396-0500] P-008360 T-005836 1 AS -- (Procedure:
'UpdatePre26_A1 bo/SalesOrder.p' Line:5894) Changemsg: 01/07/10:
CustReqDate - 01/21/10 -> 01/06/10; (bspolarich)
When they don't:
[10/01/07@16:06:32.536-0500] P-008360 T-005836 4 AS AS -- TRACE:
SINGLE-RUN Procedure bo/SalesOrder.p:Update START (8458)
[10/01/07@16:06:32.568-0500] P-008360 T-005836 1 AS -- (Procedure:
'UpdatePre26_A1 bo/SalesOrder.p' Line:5871) Processing 500618/1/1
[10/01/07@16:06:32.583-0500] P-008360 T-005836 1 AS -- (Procedure:
'UpdatePre26_A1 bo/SalesOrder.p' Line:5877) ?
[10/01/07@16:06:32.583-0500] P-008360 T-005836 1 AS -- (Procedure:
'UpdatePre26_A1 bo/SalesOrder.p' Line:5894) ?
So the fact that either my Before or After data has null values breaks
my code. Despite the fact that I set my "changemsg" variable to have a
value even before I start evaluating data, it winds up as the null value
(evidenced by the "?" in the logs), and hence the Assign statement
breaks.
How do I fix this?
-bws
--
Brian W. Spolarich ~ Manager, Information Services ~ Advanced Photonix /
Picometrix
bspolarich@... <mailto:bspolarich%40advancedphotonix.com>
<mailto:bspolarich@...
<mailto:bspolarich%40advancedphotonix.com> > ~ 734-864-5618 ~
www.advancedphotonix.com <http://www.advancedphotonix.com>
define variable rightnow as character no-undo.
define variable changemsg as character no-undo.
define variable orderlinerel as character no-undo.
define variable databuffer as character no-undo.
rightnow = string(date(now)).
changemsg = rightnow + ": ".
for each ttOrderRel where ttOrderRel.RowMod = 'U' no-lock:
orderlinerel = string(ttOrderRel.OrderNum) + "/" +
string(ttOrderRel.OrderLine) + "/" + string(ttOrderRel.OrderRelNum).
message "Processing " + orderlinerel.
find OrderRel where OrderRel.Company =
ttOrderRel.Company and OrderRel.OrderNum = ttOrderRel.OrderNum and
OrderRel.OrderLine = ttOrderRel.OrderLine and OrderRel.OrderRelNum =
ttOrderRel.OrderRelNum.
databuffer = "ttdata: " + string(ttOrderRel.ReqDate) + "|" +
string(ttOrderRel.NeedByDate) + "|" + string(ttOrderRel.Date01) + "~n" +
"data: " + string(OrderRel.ReqDate) + "|" + string(OrderRel.NeedByDate)
+ "|" + string(OrderRel.Date01) + "~n".
message databuffer.
if ttOrderRel.ReqDate <> OrderRel.ReqDate then do:
changemsg = changemsg + "ShipDate - " +
string(OrderRel.ReqDate) + " -> " + string(ttOrderRel.ReqDate) + "; ".
end.
if ttOrderRel.NeedByDate <> OrderRel.NeedByDate then do:
changemsg = changemsg + "NeedByDate - "
+ string(OrderRel.NeedByDate) + " -> " + string(ttOrderRel.NeedByDate) +
"; ".
end.
if ttOrderRel.Date01 <> OrderRel.Date01 then do:
changemsg = changemsg + "CustReqDate - "
+ string(OrderRel.Date01) + " -> " + string(ttOrderRel.Date01) + "; ".
end.
changemsg = changemsg + " (" + DCD-USERID + ")".
if ttOrderRel.Character01 <> "" then do:
changemsg = "~n" + changemsg.
end.
message "Changemsg: " + changemsg.
Assign ttOrderRel.Character01 = ttOrderRel.Character01 +
changemsg.
end.
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]