FMS - Load Ship ORDR.Address2 ONLY if Customer is in Selected CustomerGroup
I am trying to load a Ship address based using combined fields, ONLY if the customer isin a Select Group (in this case 106).
If not in the group I want the default shipping address to load.
My code is loading the new address OK but when the customer is not in group 106 the address is left BLANK. I want the original default ship address to load .
Could someome help on this point.
Version 8.8 Patch 11 SQL Server 2005.
Declare @OrigAdd as Varchar (508)
Declare @Group as int
Declare @PCode as int
---Load copy of original address
Select @OrigAdd = $[$92.0.0]
Set @PCode = 106
select @Group = (select OCRD.GroupCode from OCRD where OCRD.CardCode = $[$4.0.0])
WHEN @PCode = @Group
(Select 'Customer: 'RTRIM($[$54.0.0])char(13)'Deliver To: 'RTRIM($[ORDR.U_ProjName])char(13)RTRIM($[ORDR.U_ProjAdd])char(13)'Contact: 'RTRIM($[ORDR.U_ProjConName])char(13)'Contact Ph. :'RTRIM($[ORDR.U_ProjConPh])CHAR(13)'Delivery Date: '+RTRIM($[$12.0.0]))
WHEN NOT(@PCode = @Group)
THEN (Select @OrigAdd)