-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathARSHTTBL_MOVE_SHIPPING_RECORDS.sql
78 lines (64 loc) · 1.49 KB
/
ARSHTTBL_MOVE_SHIPPING_RECORDS.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
USE [001]
GO
INSERT INTO ARSHTTBL (
[ord_no]
,[shipment_no]
,[carrier_cd]
,[mode]
,[ship_cost]
,[total_cost]
,[cod_amount]
,[tracking_no]
,[zone]
,[ship_weight]
,[void_fg]
,[complete_fg]
,[hand_chg]
,[ship_dt]
,[filler_0001]
,[extra_1]
)
select
ltrim(sh.ord_no)
,pp.Line_no
,CASE PP.ParcelType
WHEN 'UPS' THEN 'UPG'
WHEN 'FedEx' THEN 'FXG'
ELSE CASE WHEN bl.ship_via_cd is null then OH.ship_via_cd ELSE bl.ship_via_cd END
END
,CASE pp.Loc
WHEN 'PS' THEN '1'
WHEN 'WS' THEN '2'
WHEN 'BC' THEN '3'
WHEN 'MS' THEN '4'
WHEN 'NE' THEN '5'
WHEN 'MDC' THEN '6'
ELSE '?'
END
,sh.ship_cost
,sh.total_cost
,sh.ID
,sh.tracking_no
,sh.zone
,sh.ship_weight
,null
,sh.complete_fg
,pp.Qty
,CONVERT(varchar(8),pp.ship_dt,112)
,pp.Item_no
,sh.tracking_no
-- ,bl.ID
from [001].dbo.ARSHTFIL_SQL sh
inner join [001].dbo.wsPikPak pp
on pp.ord_no = sh.ord_no
inner join [001].dbo.wsShipment ws
on ws.Shipment = pp.shipment
left outer join [001].dbo.oeordhdr_sql OH
on OH.ord_no = pp.ord_no
left outer join oebolfil_sql bl
on bl.bol_no = ws.bol_no
where sh.ord_no <> '' and sh.void_fg <> 'V' and shipped = 'Y'
and sh.ID not in
(
select cod_amount as int from ARSHTTBL
)