.p program for New sales order lines for particular customers

Thanks all again for the help.



Mark Trzaska
Administrator
Stanley Machining & Tool Corp.
425 Maple Avenue
Carpentersville, IL 60110
Phone (847) 426-4560
Fax (847) 426-6951
e-mail Mtrzaska@...<mailto:Mtrzaska@...>



[Non-text portions of this message have been removed]
Hi all,

With the help of this group. One particular person in general, I acquired the .p program for a bam for need by date changes. Since im focusing more attention on vantage then ever before. I have been given the task to help improve communication within our facilty.

I have used the .p program (c below). What I'm thinking is that to modify this .p program to send out e-mail alerts for new lines for existing orders or new orders for a particular customer. Should be fairly (I think) simple. Just need a push in the right direction.


{ud/GlbAlert.i &TableName = "OrderRel"}

assign SendEmail = false.


Define variable Planner as character no-undo.
define variable EmailAddress as Character no-undo initial '':U.
define variable UserName as Character no-undo initial '':U.

define variable vFrom as character no-undo initial '':U.
define variable vTo as character no-undo initial '':U.
define variable vCC as character no-undo initial '':U.
define variable vSubject as character no-undo initial '':U.
define variable vBody as character no-undo initial '':U.


Find UserFile where UserFile.DCDUserID = DCD-UserID no-error.
assign Username = Userfile.Name.
assign EMAIL-From = UserFile.EmailAddress.

Message " In OrderRelEmail".

Find First OrderHed Where OrderHed.company = OrderRel.company AND OrderHed.OrderNum = OrderRel.OrderNum no-lock.

Find first Customer where Orderhed.custnum = Customer.Custnum no-lock.


Find First OrderDtl Where OrderDtl.company = OrderRel.company AND OrderDtl.OrderNum = OrderRel.OrderNum and OrderDtl.OrderLine = OrderRel.OrderLine no-lock.

find Part where Part.Company = OrderDtl.Company and Part.PartNum = OrderDtl.PartNum no-lock no-error.

find ProdGrup where ProdGrup.Company = Part.Company and Part.ProdCode = ProdGrup.ProdCode no-lock no-error.

Find UserFile where UserFile.DCDUserID = ProdGrup.PersonID no-lock no-error.
assign vTo = UserFile.EmailAddress.

/* Create the new body of the email */

Assign vBody = "Need By Date changed for Part # " + OrderDtl.PartNum + " by " + UserName +
"~n~n~tCustomer " + Customer.CustID +
"~n~n~tItem " + OrderDtl.PartNum +
"~n~n~tQty " + trim(string(OrderRel.OurReqQty)) +
"~n~n~tOrder Number: " + string(OrderRel.OrderNum) + "~tLine Number: " + string(OrderRel.OrderLine) +
"~n~n~tOld Need By Date " + string(OLDOrderRel.NeedByDate,"99/99/99") +
"~n~n~tNew Need By Date " + string(OrderRel.NeedByDate,"99/99/99").



vCC = "Mtrzaska@...;ertrzaska@...;cmikucki@...;gjez@...;". /* CC to check out alert */



/* Exampes of formatting and conditions */
/*
"~n~n~tMA Cost ~t" + string(Part.StdMaterialCost,"$>>>,>>>,>>9.99") + "~tExtended Cost " + trim(string(Part.StdMaterialCost * OrderRel.XOrderQty,"$>>>,>>>,>>9.99")) +
"~n~tPO Cost ~t" + string(OrderRel.UnitCost,"$>>>,>>>,>>9.99") + "~tExtended Cost " + TRIM(string(OrderRel.UnitCost * OrderRel.XOrderQty,"$>>>,>>>,>>9.99")) +


if (CostAtPO - CostAtStd) > 50 then do:
assign vTO = vTO + "info@...;".
end.

if (CostAtPO - CostAtStd) > 1000 then do:
assign vCC = vCC + "sales@...;".
end.
*/



Message "DEBUG Email - vTO = " + vTO.


EMAIL-To = vTO.
EMAIL-CC = vCC + EMAIL-From.
assign EMAIL-Subject = 'Need By Date Has Changed on Sales Order ' + string(OrderRel.OrderNum).
assign EMAIL-Text = vBody.

If Customer.CustID = "VETCOGRA" then
assign SendEmail = true.


Thank you
Groups help is always appreciated.


Mark Trzaska
Administrator
Stanley Machining & Tool Corp.
425 Maple Avenue
Carpentersville, IL 60110
Phone (847) 426-4560
Fax (847) 426-6951
e-mail Mtrzaska@...<mailto:Mtrzaska@...>



[Non-text portions of this message have been removed]
>> to send out e-mail alerts for new lines for existing orders
>>or new orders for a particular customer.
Have you had a chance to look at BPMs yet?
A while back I stopped using BAMs for new alerts.
If you find the BPM email template doesn't quite fit, you can still build something custom that will use syntax similar to your .p program.

If you'd rather continue with BAM email...
You could try this experiment.
Set up a new BAM on the OrderRel table.
Then copy everything in your existing BAM except... select OrderRel.OrderLine instead of OrderRel.NeedByDate.

That new BAM should send an email every time an OrderRel.OrderLine is added (and saved)? Probably too much email...
So you could then try adding rules (and/or select more fields) to limit the emails.
I think this is where it might prove to be a bit tricky. (And is one of the reasons I have begun to prefer the BPM approach).

>> bam for need by date changes.
I am assuming your existing BAM include the field OrderRel.NeedByDate
any other fields selected?
and has an Action = Send Alert & specifies the .p program
And that BAM does not have any rules?



--- In vantage@yahoogroups.com, "Trzaska, Mark" <mtrzaska@...> wrote:
>
> Hi all,
>
> With the help of this group. One particular person in general, I acquired the .p program for a bam for need by date changes. Since im focusing more attention on vantage then ever before. I have been given the task to help improve communication within our facilty.
>
> I have used the .p program (c below). What I'm thinking is that to modify this .p program to send out e-mail alerts for new lines for existing orders or new orders for a particular customer. Should be fairly (I think) simple. Just need a push in the right direction.
>
>
> {ud/GlbAlert.i &TableName = "OrderRel"}
>
> assign SendEmail = false.
>
>
> Define variable Planner as character no-undo.
> define variable EmailAddress as Character no-undo initial '':U.
> define variable UserName as Character no-undo initial '':U.
>
> define variable vFrom as character no-undo initial '':U.
> define variable vTo as character no-undo initial '':U.
> define variable vCC as character no-undo initial '':U.
> define variable vSubject as character no-undo initial '':U.
> define variable vBody as character no-undo initial '':U.
>
>
> Find UserFile where UserFile.DCDUserID = DCD-UserID no-error.
> assign Username = Userfile.Name.
> assign EMAIL-From = UserFile.EmailAddress.
>
> Message " In OrderRelEmail".
>
> Find First OrderHed Where OrderHed.company = OrderRel.company AND OrderHed.OrderNum = OrderRel.OrderNum no-lock.
>
> Find first Customer where Orderhed.custnum = Customer.Custnum no-lock.
>
>
> Find First OrderDtl Where OrderDtl.company = OrderRel.company AND OrderDtl.OrderNum = OrderRel.OrderNum and OrderDtl.OrderLine = OrderRel.OrderLine no-lock.
>
> find Part where Part.Company = OrderDtl.Company and Part.PartNum = OrderDtl.PartNum no-lock no-error.
>
> find ProdGrup where ProdGrup.Company = Part.Company and Part.ProdCode = ProdGrup.ProdCode no-lock no-error.
>
> Find UserFile where UserFile.DCDUserID = ProdGrup.PersonID no-lock no-error.
> assign vTo = UserFile.EmailAddress.
>
> /* Create the new body of the email */
>
> Assign vBody = "Need By Date changed for Part # " + OrderDtl.PartNum + " by " + UserName +
> "~n~n~tCustomer " + Customer.CustID +
> "~n~n~tItem " + OrderDtl.PartNum +
> "~n~n~tQty " + trim(string(OrderRel.OurReqQty)) +
> "~n~n~tOrder Number: " + string(OrderRel.OrderNum) + "~tLine Number: " + string(OrderRel.OrderLine) +
> "~n~n~tOld Need By Date " + string(OLDOrderRel.NeedByDate,"99/99/99") +
> "~n~n~tNew Need By Date " + string(OrderRel.NeedByDate,"99/99/99").
>
>
>
> vCC = "Mtrzaska@...;ertrzaska@...;cmikucki@...;gjez@...;". /* CC to check out alert */
>
>
>
> /* Exampes of formatting and conditions */
> /*
> "~n~n~tMA Cost ~t" + string(Part.StdMaterialCost,"$>>>,>>>,>>9.99") + "~tExtended Cost " + trim(string(Part.StdMaterialCost * OrderRel.XOrderQty,"$>>>,>>>,>>9.99")) +
> "~n~tPO Cost ~t" + string(OrderRel.UnitCost,"$>>>,>>>,>>9.99") + "~tExtended Cost " + TRIM(string(OrderRel.UnitCost * OrderRel.XOrderQty,"$>>>,>>>,>>9.99")) +
>
>
> if (CostAtPO - CostAtStd) > 50 then do:
> assign vTO = vTO + "info@...;".
> end.
>
> if (CostAtPO - CostAtStd) > 1000 then do:
> assign vCC = vCC + "sales@...;".
> end.
> */
>
>
>
> Message "DEBUG Email - vTO = " + vTO.
>
>
> EMAIL-To = vTO.
> EMAIL-CC = vCC + EMAIL-From.
> assign EMAIL-Subject = 'Need By Date Has Changed on Sales Order ' + string(OrderRel.OrderNum).
> assign EMAIL-Text = vBody.
>
> If Customer.CustID = "VETCOGRA" then
> assign SendEmail = true.
>
>
> Thank you
> Groups help is always appreciated.
>
>
> Mark Trzaska
> Administrator
> Stanley Machining & Tool Corp.
> 425 Maple Avenue
> Carpentersville, IL 60110
> Phone (847) 426-4560
> Fax (847) 426-6951
> e-mail Mtrzaska@...<mailto:Mtrzaska@...>
>
>
>
> [Non-text portions of this message have been removed]
>
Setup 2 new BAMs on OrderHed and OrderLine. Send them to yourself and make sure you get the basic email.

On orderhed only select OrderNum. since this only gets set once it will only trigger once. You can filter the customer like you did in the first one.

on OrderDtl only select OrderNum, OrderLine. In the .p program you can decide what qualifies as a new line for an existing order, but you could check OrderHed.ChangeDate <> OrderHed.OrderDate and then set sendemail = true

Change the tablename on the .p to match the BAM and you won't need to find OrderHed if you start there. Adjust the other finds that user OrderRel to match the new table.

Greg Payne

From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of Trzaska, Mark
Sent: Monday, June 24, 2013 1:41 PM
To: vantage@yahoogroups.com
Subject: [Vantage] .p program for New sales order lines for particular customers



Hi all,

With the help of this group. One particular person in general, I acquired the .p program for a bam for need by date changes. Since im focusing more attention on vantage then ever before. I have been given the task to help improve communication within our facilty.

I have used the .p program (c below). What I'm thinking is that to modify this .p program to send out e-mail alerts for new lines for existing orders or new orders for a particular customer. Should be fairly (I think) simple. Just need a push in the right direction.

{ud/GlbAlert.i &TableName = "OrderRel"}

assign SendEmail = false.

Define variable Planner as character no-undo.
define variable EmailAddress as Character no-undo initial '':U.
define variable UserName as Character no-undo initial '':U.

define variable vFrom as character no-undo initial '':U.
define variable vTo as character no-undo initial '':U.
define variable vCC as character no-undo initial '':U.
define variable vSubject as character no-undo initial '':U.
define variable vBody as character no-undo initial '':U.

Find UserFile where UserFile.DCDUserID = DCD-UserID no-error.
assign Username = Userfile.Name.
assign EMAIL-From = UserFile.EmailAddress.

Message " In OrderRelEmail".

Find First OrderHed Where OrderHed.company = OrderRel.company AND OrderHed.OrderNum = OrderRel.OrderNum no-lock.

Find first Customer where Orderhed.custnum = Customer.Custnum no-lock.

Find First OrderDtl Where OrderDtl.company = OrderRel.company AND OrderDtl.OrderNum = OrderRel.OrderNum and OrderDtl.OrderLine = OrderRel.OrderLine no-lock.

find Part where Part.Company = OrderDtl.Company and Part.PartNum = OrderDtl.PartNum no-lock no-error.

find ProdGrup where ProdGrup.Company = Part.Company and Part.ProdCode = ProdGrup.ProdCode no-lock no-error.

Find UserFile where UserFile.DCDUserID = ProdGrup.PersonID no-lock no-error.
assign vTo = UserFile.EmailAddress.

/* Create the new body of the email */

Assign vBody = "Need By Date changed for Part # " + OrderDtl.PartNum + " by " + UserName +
"~n~n~tCustomer " + Customer.CustID +
"~n~n~tItem " + OrderDtl.PartNum +
"~n~n~tQty " + trim(string(OrderRel.OurReqQty)) +
"~n~n~tOrder Number: " + string(OrderRel.OrderNum) + "~tLine Number: " + string(OrderRel.OrderLine) +
"~n~n~tOld Need By Date " + string(OLDOrderRel.NeedByDate,"99/99/99") +
"~n~n~tNew Need By Date " + string(OrderRel.NeedByDate,"99/99/99").

vCC = "Mtrzaska@...<mailto:Mtrzaska%40StanleyMachining.com>;ertrzaska@...<mailto:ertrzaska%40stanleymachining.com>;cmikucki@...<mailto:cmikucki%40stanleymachining.com>;gjez@...<mailto:gjez%40stanleymachining.com>;". /* CC to check out alert */

/* Exampes of formatting and conditions */
/*
"~n~n~tMA Cost ~t" + string(Part.StdMaterialCost,"$>>>,>>>,>>9.99") + "~tExtended Cost " + trim(string(Part.StdMaterialCost * OrderRel.XOrderQty,"$>>>,>>>,>>9.99")) +
"~n~tPO Cost ~t" + string(OrderRel.UnitCost,"$>>>,>>>,>>9.99") + "~tExtended Cost " + TRIM(string(OrderRel.UnitCost * OrderRel.XOrderQty,"$>>>,>>>,>>9.99")) +

if (CostAtPO - CostAtStd) > 50 then do:
assign vTO = vTO + "info@...<mailto:info%40comp.com>;".
end.

if (CostAtPO - CostAtStd) > 1000 then do:
assign vCC = vCC + "sales@...<mailto:sales%40comp.com>;".
end.
*/

Message "DEBUG Email - vTO = " + vTO.

EMAIL-To = vTO.
EMAIL-CC = vCC + EMAIL-From.
assign EMAIL-Subject = 'Need By Date Has Changed on Sales Order ' + string(OrderRel.OrderNum).
assign EMAIL-Text = vBody.

If Customer.CustID = "VETCOGRA" then
assign SendEmail = true.

Thank you
Groups help is always appreciated.

Mark Trzaska
Administrator
Stanley Machining & Tool Corp.
425 Maple Avenue
Carpentersville, IL 60110
Phone (847) 426-4560
Fax (847) 426-6951
e-mail Mtrzaska@...<mailto:Mtrzaska%40StanleyMachining.com><mailto:Mtrzaska@...<mailto:Mtrzaska%40StanleyMachining.com>>

[Non-text portions of this message have been removed]


________________________________
CONFIDENTIALITY NOTICE

The information contained in this communication, including attachments, is privileged and confidential. It is intended only for the exclusive use of the addressee. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering it to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us at 727-578-6280 and immediately delete the communication.

"This (document/presentation) may contain technical data as defined in the International Traffic In Arms Regulations (ITAR) 22 CFR 120.10. Export of this material is restricted by the Arms Export Control Act (22 U.S.C. 2751 et seq.) and may not be exported to foreign persons without prior approval form the U.S. Department of State."


[Non-text portions of this message have been removed]