Re: SO Reqequsted Ship Date - Should it fill down or not???
The requested ship date only rolls down to the lines at the time that the order is created.
One method to roll down requested ship dates from the header to the lines would be in a SQL Server trigger. The following trigger would do the trick, but needs more thorough testing. It checks to make sure that the Requested Ship Date was changed on the header. It also will only change the Requested Ship Date only if it doesn't already match the header.
Use [COMPANYDB]
/* put whichever DB you want to apply the trigger to inside of the brackets */SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO-- =============================================-- Author: Dwight Brown, Systematica, Inc.-- Create date: 10/10/08-- Description: Rolls down the reqshipdate from the header to all lines-- Only rolls down if the date on the header has changed-- =============================================CREATE TRIGGER tr_SOP10100ReqShipDateRollDown ON dbo.SOP10100 AFTER UPDATEAS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON;
IF UPDATE(ReqShipDate) --
/*this ensures that the ReqShipDate was actually changed during this database update, trying to prevent excessive writes*/
BEGIN UPDATE LineItems set LineItems.ReqShipDate = Header.ReqShipDate FROM SOP10200 LineItems INNER JOIN SOP10100 Header on LineItems.SOPNumbe = Header.SOPNumbe INNER JOIN Inserted On Header.SOPNumbe = Inserted.SOPNumbe Where Header.ReqShipDate <> LineItems.ReqShipDate
/* Aliases used here in order to allow an update with joins */
END ENDGO