Thanks. This was the code that got me most of the way though what I needed. We have 3 plants in the U.S. So I used 3 UDF's on the Shipto table (shipto.number0*) so from any plant to any ship to we have the normal LTL trucking time. This code will adjust if the answer falls on the weekend. It will move the data automatically.

I thought this was real cool, but our Shipping person still insists that I not count weekends. If it's a 7 day transfer and the OrderRel.ReqDate = Wednesday, The answer is not the previous Wednesday, it's that - 2 more days (the weekend). This is my last issue to resolve.

----------------------------------------------

For Each ttOrderRel Where (ttOrderRel.rowmod ='a' or ttOrderRel.rowmod ='u').

If available ttOrderRel Then Do:

Find First ShipTo Where

ShipTo.Company = ttOrderRel.Company and

INT(ShipTo.Custnum) = ttOrderRel.Number10 and

Shipto.ShipToNum = ttOrderRel.ShipToNum.

If available shipto Then Do:

if ttOrderRel.Plant = "mfgsys" then ttorderrel.ReqDate = ttOrderRel.NeedByDate - shipto.number01.

if ttOrderRel.Plant = "05" then ttorderrel.ReqDate = ttOrderRel.NeedByDate - shipto.number02.

if ttOrderRel.Plant = "06" then ttorderrel.ReqDate = ttOrderRel.NeedByDate - shipto.number03.

if Weekday(ttorderrel.ReqDate) = 1 then assign ttOrderRel.ReqDate = ttorderrel.ReqDate - 2.

if Weekday(ttorderrel.ReqDate) = 7 then assign ttOrderRel.ReqDate = ttorderrel.ReqDate - 1.

End.

End.

End.

----------------------------------------------

I thought this was real cool, but our Shipping person still insists that I not count weekends. If it's a 7 day transfer and the OrderRel.ReqDate = Wednesday, The answer is not the previous Wednesday, it's that - 2 more days (the weekend). This is my last issue to resolve.

----------------------------------------------

For Each ttOrderRel Where (ttOrderRel.rowmod ='a' or ttOrderRel.rowmod ='u').

If available ttOrderRel Then Do:

Find First ShipTo Where

ShipTo.Company = ttOrderRel.Company and

INT(ShipTo.Custnum) = ttOrderRel.Number10 and

Shipto.ShipToNum = ttOrderRel.ShipToNum.

If available shipto Then Do:

if ttOrderRel.Plant = "mfgsys" then ttorderrel.ReqDate = ttOrderRel.NeedByDate - shipto.number01.

if ttOrderRel.Plant = "05" then ttorderrel.ReqDate = ttOrderRel.NeedByDate - shipto.number02.

if ttOrderRel.Plant = "06" then ttorderrel.ReqDate = ttOrderRel.NeedByDate - shipto.number03.

if Weekday(ttorderrel.ReqDate) = 1 then assign ttOrderRel.ReqDate = ttorderrel.ReqDate - 2.

if Weekday(ttorderrel.ReqDate) = 7 then assign ttOrderRel.ReqDate = ttorderrel.ReqDate - 1.

End.

End.

End.

----------------------------------------------

--- In vantage@yahoogroups.com, "liss_c" <lissette.contreras@...> wrote:

>

> Scott,

>

> Did you solve the problem?? I will suggest maybe your calendar is setup for weekends also. This is what I found in the Help application:

>

> Select the company's base shop calendar which will be used by the scheduling engine and Material Requirements Planning (MRP). Also, if you are shipping to a costumer or vendor each Supplier entry and the Customer Entry has option to select calendars. Take a look at that so you won't need to add more lines to your code.

>

> Lissette

> KEC

> Corona,CA

>

> --- In vantage@yahoogroups.com, "scottinct78" <spare@> wrote:

> >

> > I have a BPM that works fairly well. It subtracts ship time (in days) from the OrderRel.NeedByDate and puts the answer in teh OrderRel.ReqDate. with some help I figured out how to identify if the answer stored in the ReqDate was a Sat or Sun and subtract 1 or 2 from it.

> >

> > The problem I have now is if the NeedByDate is Monday the 22nd, and there is a 4 day ship time the answer is not Thursday the 18th. I can calculate weekends in my math.

> >

> > I was hoping some one had some code examples or if there was some kind of a date function I could use that would exclude weekends. Any suggestions would be very helpful.

> >

>