MSAccessRookie
AWF VIP
- Local time
- Today, 18:13
- Joined
- May 2, 2008
- Messages
- 3,423
I have an SQL Server View that identifies records that are required for shipping. We are attempting to automate the UPS WorldShip Application using this View. Currently, the View identifies the correct shipping records, but the information is not correct, because UPS WorldShip Application requests one box per record, and the Shipment data contains multiple boxes per record. It looks like I will need to create multiple records for each shipment record that represents more than one box.
The Column NoOfPackages (see below) varies from as little as 1 to (on occasion) over 50. I expect that I will need to use that Column to replicate the record the number of times required to have a single entry per box. Is there a way to do this?
Please note that the code is still under development, and any suggestions will be welcomed.
The Column NoOfPackages (see below) varies from as little as 1 to (on occasion) over 50. I expect that I will need to use that Column to replicate the record the number of times required to have a single entry per box. Is there a way to do this?
Please note that the code is still under development, and any suggestions will be welcomed.
Code:
[/FONT]
[FONT=Courier New]USE [CMPNYDB][/FONT]
[FONT=Courier New]GO[/FONT]
[FONT=Courier New]/****** Object: View [dbo].[Shipping_CmpnyToUPS] Script Date: 09/11/2009 17:00:43 ******/[/FONT]
[FONT=Courier New]SET ANSI_NULLS ON[/FONT]
[FONT=Courier New]GO[/FONT]
[FONT=Courier New]SET QUOTED_IDENTIFIER ON[/FONT]
[FONT=Courier New]GO[/FONT]
[FONT=Courier New]ALTER View [dbo].[ Shipping_CmpnyToUPS] As[/FONT]
[FONT=Courier New] [/FONT]
[FONT=Courier New]SELECT T0.Institution_ID, T2.Institution, T6.InvoiceNumber As InvoiceNumber, T6.ShippingDetailsID, [COLOR=green][B]T6.Boxes As NoOfPackages[/B][/COLOR], [/FONT]
[FONT=Courier New]Cast(T6.InvoiceNumber As VarChar) + Cast(T6.ShippingDetailsID As VarChar) As Inv, T0.PO_No As PONum, T3.Department, T3.Address, [/FONT]
[FONT=Courier New]T3.City, IsNull(T3.State, T3.State_NotUSA) As State, IsNull(T3.PostalCode, PostalCode_NotUSA) As PostalCode, T0.ShipToAddressID, [/FONT]
[FONT=Courier New]IsNull(T3.Country_NOTUSA,'USA') As Country, T0.ShipToAttnID As ContactID, [/FONT]
[FONT=Courier New] [/FONT]
[FONT=Courier New]IsNull(T4.L_Name, '') + CASE IsNull(T4.L_Name, '') WHEN '' THEN '' ELSE CASE IsNull(T4.F_Name, '') WHEN '' THEN '' ELSE ', ' END END + IsNull(T4.F_Name, '') As ShiptoName, [/FONT]
[FONT=Courier New]IsNull(T5.L_Name, '') + CASE IsNull(T5.L_Name, '') WHEN '' THEN '' ELSE CASE IsNull(T5.F_Name, '') WHEN '' THEN '' ELSE ', ' END END + IsNull(T5.F_Name, '') As ResearcherName, [/FONT]
[FONT=Courier New]IsNull(T4.Email, '') As ShiptoEmail, IsNull(T5.Email, '') As ResearcherEmail,[/FONT]
[FONT=Courier New] [/FONT]
[FONT=Courier New]CASE IsNull(T4.Email, '') WHEN '' THEN CASE IsNull(T5.Email, '') WHEN '' THEN '' ELSE T5.Email END ELSE T4.Email END As TheEmail,[/FONT]
[FONT=Courier New]'Y' As QVNotify, 'Y' As ShipNotify, 'Y' As ExceptionNotify, 'Y' As DeliveryNotify, [/FONT]
[FONT=Courier New]11 As BoxLength, 9 As BoxWidth, 12 As BoxHeight[/FONT]
[FONT=Courier New] [/FONT]
[FONT=Courier New]FROM tblworkorders T0 [/FONT]
[FONT=Courier New] INNER JOIN INSTITUTIONS T2 on T0.Institution_ID = T2.Institution_ID [/FONT]
[FONT=Courier New] LEFT JOIN tblAddresses T3 ON T0.ShiptoAddressID = T3.AddressID [/FONT]
[FONT=Courier New] LEFT JOIN tblPeople T5 ON T5.Person_id = T0.ResearcherID [/FONT]
[FONT=Courier New] LEFT JOIN tblPeople T4 ON T4.Person_id = T0.ShiptoAttnID [/FONT]
[FONT=Courier New] INNER JOIN (SELECT T0.* FROM tblShippingDetails T0 INNER JOIN tblShippingRoute T2 ON T0.ShipRoute = T2.ShippingRouteID[/FONT]
[FONT=Courier New] WHERE (T2.shippingroute like '%UPS%')) As T6 ON T0.InvoiceNumber = T6.InvoiceNumber[/FONT]
[FONT=Courier New] WHERE ((T6.SHIPDATE IS NULL) AND (T6.Boxes <> 0))[/FONT]
[FONT=Courier New]