Create BPM to Send email when Requisition Status is changes

Hi Nigel,

I was able to make it works by adding the below codes at the body of the p file

> FOR EACH reqdetail of reqhead no-lock:
> Assign NewEmailBody = NewEmailBody
> + " Item " + STRING(reqdetail.reqline) + ": "
> + STRING(reqdetail.PartNum) + " " + STRING(reqdetail.LineDesc)
> + " - Qty: " + STRING(reqdetail.OrderQty)
> + "~n".
> END.

Thank you very much for your input.


if any one looking for solution regading email notification within requisition, let me know and I will shared the codes.



--- In vantage@yahoogroups.com, "lvuhome" <lvuhome@...> wrote:
>
> Hi Nigel
>
> I added the below codes into the p file
>
> FOR EACH reqhead no-lock:
> FIND reqdetail WHERE (reqhead.Company = reqdetail.Company) AND
> (reqhead.reqnum = reqdetail.reqnum) NO-LOCK NO-ERROR.
> FOR EACH reqdetail of reqhead no-lock:
> Assign NewEmailBody = NewEmailBody
> + " Item " + STRING(reqdetail.reqline) + ": "
> + STRING(reqdetail.PartNum) + " " + STRING(reqdetail.LineDesc)
> + " - Qty: " + STRING(reqdetail.OrderQty)
> + "~n".
> END.
> END.
>
> and get the error in the log as
> [09/05/14@13:30:42.444-0400] P-004840 T-005616 1 AS -- Cannot change cursor of buffer reqhead when executing a trigger. (2873)
>
> Do you know what is wrong with it.
>
> Thanks.
> Lam
>
>
> --- In vantage@yahoogroups.com, "Nigel Kerley" <nigel.kerley@> wrote:
> >
> > Hi Lam,
> >
> > Here's the code to include the detail lines for a PO BAM we have in place. Again, you should be able to amend it for Requisitions:
> >
> > Towards the top of the .p file:
> > FIND PODetail WHERE (PODetail.Company = POHeader.Company) AND
> > (PODetail.PONUM = POHeader.PONum) NO-LOCK NO-ERROR.
> >
> > In the body of the code:
> > /* Lines of Order */
> > FOR EACH PODetail of POHeader no-lock:
> > FIND PORel WHERE (PORel.Company = PODetail.Company) AND
> > (PORel.PONum = PODetail.PONUM) AND (PORel.POLine = PODetail.POLine) NO-LOCK NO-ERROR.
> >
> > FOR EACH PORel of PODetail no-lock:
> > Assign NewEmailBody = NewEmailBody
> > + " Item " + STRING(PODetail.POLine) + ": "
> > + STRING(PODetail.PartNum) + " " + STRING(PODetail.LineDesc)
> > + " - Due: " + STRING(PORel.DueDate)
> > + " - Qty: " + STRING(PODetail.OrderQty)
> > + " - Price: " + STRING(PODetail.UnitCost)
> > + "~n".
> > END.
> > END.
> >
> >
> > HTH,
> >
> > Nigel.
> >
> >
> >
> > --- In vantage@yahoogroups.com, "lvuhome" <lvuhome@> wrote:
> > >
> > > Thanks Nigel for your input. I was able to get the Requisition to email to requestor/dispacher.
> > >
> > > Now I want to go further with the email, I don't know if any one know the logic to print the Requisition lines detail in the email if there is more then one line items.
> > >
> > > Lam
> > >
> > > --- In vantage@yahoogroups.com, "Nigel Kerley" <nigel.kerley@> wrote:
> > > >
> > > > Yes, just copy & paste the code below into Notepad, amend it and save it.
> > > >
> > > > Alert programs are normally saved in \\servername\epicor\mfgsys803\server\ud\xxx.p
> > > >
> > > > When creating the BAM set the path to the program as "ud\xxx.p" - no need to use the full path, even on client PCs.
> > > >
> > > > The only problem with using Notepad is that you've no way of knowing that your code is ok until Vantage runs it. There may be some Progress program supplied with Vantage but I've never looked for it. If the code has errors you'll probably get a 4GL error showing. If that happens, just check the log file for the line number causing the problem: \\servername\epicor\mfgsys803\server\logs\mfgtest803.server.log (or mfgsys803.server.log for the live DB).
> > > >
> > > > Nigel.
> > > >
> > > >
> > > > --- In vantage@yahoogroups.com, "lvuhome" <lvuhome@> wrote:
> > > > >
> > > > > I have not created an Alert program in BAM before. What are the steps of create an alerts program within BAM? can I use notepad to create and save as xxx.p?
> > > > >
> > > > > Thank you
> > > > >
> > > > > --- In vantage@yahoogroups.com, "Nigel Kerley" <nigel.kerley@> wrote:
> > > > > >
> > > > > > We use a BAM to accomplish basically the same thing on POs. You might be able to amend to work with Requisitions.
> > > > > >
> > > > > > The BAM was created against the POHeader table and the selected fields are "ApprovalStatus" and "ApprovedBy".
> > > > > >
> > > > > > The Rules are that ApprovalStatus = 'A' and ApprovedBy <> ''.
> > > > > >
> > > > > > An Alert program is then run which sends the actual email:
> > > > > >
> > > > > >
> > > > > > /* Send email whenever a Purchase Order is created */
> > > > > > {ud/GlbAlert.i &TableName = "POHeader"}
> > > > > >
> > > > > > DEFINE VARIABLE NewEmailBody AS CHARACTER NO-UNDO.
> > > > > >
> > > > > > FIND Vendor WHERE (Vendor.Company = POHeader.Company) AND(Vendor.VendorNum = POHeader.VendorNum) NO-LOCK.
> > > > > >
> > > > > > FIND PurAgent WHERE (PurAgent.Company = POHeader.Company) AND
> > > > > > (PurAgent.BuyerId = POHeader.BuyerID) NO-LOCK.
> > > > > >
> > > > > > FIND POApvMsg WHERE (POApvMsg.Company = POHeader.Company) AND
> > > > > > (POApvMsg.PONum = POHeader.PONum) AND (POApvMsg.MsgType = "2") NO-LOCK NO-ERROR.
> > > > > >
> > > > > > /* Don't send email if PO is closed */
> > > > > > If NOT (POHeader.OpenOrder) THEN DO:
> > > > > > RETURN "CANCEL SEND":U.
> > > > > > END.
> > > > > >
> > > > > > /* Create email */
> > > > > > ASSIGN Email-To = STRING(PurAgent.EMailAddress)
> > > > > >
> > > > > > Email-Subject = "Purchase Order has been approved: # " + STRING(POHeader.PONum)
> > > > > >
> > > > > > /* Create the new body of the email */
> > > > > > NewEmailBody = "~nOrder Number: " + STRING(POHeader.PONum)
> > > > > > + "~n~nSupplier: " + STRING(Vendor.Name)
> > > > > > + "~n~nOrder Date: " + STRING(POHeader.OrderDate).
> > > > > >
> > > > > > ASSIGN NewEmailBody = NewEmailBody
> > > > > > + "~n~nEntry Person: " + STRING(POHeader.EntryPerson)
> > > > > > + "~n~nApproved Value: " + STRING(POHeader.ApprovedAmount).
> > > > > >
> > > > > > IF AVAILABLE POApvMsg THEN DO:
> > > > > > ASSIGN NewEmailBody = NewEmailBody + "~nMessage: " + STRING(POApvMsg.MsgText).
> > > > > > END.
> > > > > >
> > > > > > ASSIGN NewEmailBody = NewEmailBody
> > > > > > + "~n~nDO NOT REPLY TO THIS E-MAIL ACCOUNT, IT DOES NOT GET REVIEWED!".
> > > > > >
> > > > > > /* Print Email Body */
> > > > > > ASSIGN Email-Text = NewEmailBody
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > You might be able to create something similar against the ReqHead table and use the StatusType field.
> > > > > >
> > > > > >
> > > > > > HTH,
> > > > > >
> > > > > > Nigel.
> > > > > >
> > > > > >
> > > > > > --- In vantage@yahoogroups.com, "lvuhome" <lvuhome@> wrote:
> > > > > > >
> > > > > > > Hi There,
> > > > > > >
> > > > > > > Is any one have the BPM code want to share with me or show me how regarding sending email to requestor when the Requisition status is change either from Pending to Orderred.
> > > > > > >
> > > > > > > Thank you very much
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
Hi There,

Is any one have the BPM code want to share with me or show me how regarding sending email to requestor when the Requisition status is change either from Pending to Orderred.

Thank you very much
We use a BAM to accomplish basically the same thing on POs. You might be able to amend to work with Requisitions.

The BAM was created against the POHeader table and the selected fields are "ApprovalStatus" and "ApprovedBy".

The Rules are that ApprovalStatus = 'A' and ApprovedBy <> ''.

An Alert program is then run which sends the actual email:


/* Send email whenever a Purchase Order is created */
{ud/GlbAlert.i &TableName = "POHeader"}

DEFINE VARIABLE NewEmailBody AS CHARACTER NO-UNDO.

FIND Vendor WHERE (Vendor.Company = POHeader.Company) AND(Vendor.VendorNum = POHeader.VendorNum) NO-LOCK.

FIND PurAgent WHERE (PurAgent.Company = POHeader.Company) AND
(PurAgent.BuyerId = POHeader.BuyerID) NO-LOCK.

FIND POApvMsg WHERE (POApvMsg.Company = POHeader.Company) AND
(POApvMsg.PONum = POHeader.PONum) AND (POApvMsg.MsgType = "2") NO-LOCK NO-ERROR.

/* Don't send email if PO is closed */
If NOT (POHeader.OpenOrder) THEN DO:
RETURN "CANCEL SEND":U.
END.

/* Create email */
ASSIGN Email-To = STRING(PurAgent.EMailAddress)

Email-Subject = "Purchase Order has been approved: # " + STRING(POHeader.PONum)

/* Create the new body of the email */
NewEmailBody = "~nOrder Number: " + STRING(POHeader.PONum)
+ "~n~nSupplier: " + STRING(Vendor.Name)
+ "~n~nOrder Date: " + STRING(POHeader.OrderDate).

ASSIGN NewEmailBody = NewEmailBody
+ "~n~nEntry Person: " + STRING(POHeader.EntryPerson)
+ "~n~nApproved Value: " + STRING(POHeader.ApprovedAmount).

IF AVAILABLE POApvMsg THEN DO:
ASSIGN NewEmailBody = NewEmailBody + "~nMessage: " + STRING(POApvMsg.MsgText).
END.

ASSIGN NewEmailBody = NewEmailBody
+ "~n~nDO NOT REPLY TO THIS E-MAIL ACCOUNT, IT DOES NOT GET REVIEWED!".

/* Print Email Body */
ASSIGN Email-Text = NewEmailBody




You might be able to create something similar against the ReqHead table and use the StatusType field.


HTH,

Nigel.


--- In vantage@yahoogroups.com, "lvuhome" <lvuhome@...> wrote:
>
> Hi There,
>
> Is any one have the BPM code want to share with me or show me how regarding sending email to requestor when the Requisition status is change either from Pending to Orderred.
>
> Thank you very much
>
I have not created an Alert program in BAM before. What are the steps of create an alerts program within BAM? can I use notepad to create and save as xxx.p?

Thank you

--- In vantage@yahoogroups.com, "Nigel Kerley" <nigel.kerley@...> wrote:
>
> We use a BAM to accomplish basically the same thing on POs. You might be able to amend to work with Requisitions.
>
> The BAM was created against the POHeader table and the selected fields are "ApprovalStatus" and "ApprovedBy".
>
> The Rules are that ApprovalStatus = 'A' and ApprovedBy <> ''.
>
> An Alert program is then run which sends the actual email:
>
>
> /* Send email whenever a Purchase Order is created */
> {ud/GlbAlert.i &TableName = "POHeader"}
>
> DEFINE VARIABLE NewEmailBody AS CHARACTER NO-UNDO.
>
> FIND Vendor WHERE (Vendor.Company = POHeader.Company) AND(Vendor.VendorNum = POHeader.VendorNum) NO-LOCK.
>
> FIND PurAgent WHERE (PurAgent.Company = POHeader.Company) AND
> (PurAgent.BuyerId = POHeader.BuyerID) NO-LOCK.
>
> FIND POApvMsg WHERE (POApvMsg.Company = POHeader.Company) AND
> (POApvMsg.PONum = POHeader.PONum) AND (POApvMsg.MsgType = "2") NO-LOCK NO-ERROR.
>
> /* Don't send email if PO is closed */
> If NOT (POHeader.OpenOrder) THEN DO:
> RETURN "CANCEL SEND":U.
> END.
>
> /* Create email */
> ASSIGN Email-To = STRING(PurAgent.EMailAddress)
>
> Email-Subject = "Purchase Order has been approved: # " + STRING(POHeader.PONum)
>
> /* Create the new body of the email */
> NewEmailBody = "~nOrder Number: " + STRING(POHeader.PONum)
> + "~n~nSupplier: " + STRING(Vendor.Name)
> + "~n~nOrder Date: " + STRING(POHeader.OrderDate).
>
> ASSIGN NewEmailBody = NewEmailBody
> + "~n~nEntry Person: " + STRING(POHeader.EntryPerson)
> + "~n~nApproved Value: " + STRING(POHeader.ApprovedAmount).
>
> IF AVAILABLE POApvMsg THEN DO:
> ASSIGN NewEmailBody = NewEmailBody + "~nMessage: " + STRING(POApvMsg.MsgText).
> END.
>
> ASSIGN NewEmailBody = NewEmailBody
> + "~n~nDO NOT REPLY TO THIS E-MAIL ACCOUNT, IT DOES NOT GET REVIEWED!".
>
> /* Print Email Body */
> ASSIGN Email-Text = NewEmailBody
>
>
>
>
> You might be able to create something similar against the ReqHead table and use the StatusType field.
>
>
> HTH,
>
> Nigel.
>
>
> --- In vantage@yahoogroups.com, "lvuhome" <lvuhome@> wrote:
> >
> > Hi There,
> >
> > Is any one have the BPM code want to share with me or show me how regarding sending email to requestor when the Requisition status is change either from Pending to Orderred.
> >
> > Thank you very much
> >
>
Yes, just copy & paste the code below into Notepad, amend it and save it.

Alert programs are normally saved in \\servername\epicor\mfgsys803\server\ud\xxx.p

When creating the BAM set the path to the program as "ud\xxx.p" - no need to use the full path, even on client PCs.

The only problem with using Notepad is that you've no way of knowing that your code is ok until Vantage runs it. There may be some Progress program supplied with Vantage but I've never looked for it. If the code has errors you'll probably get a 4GL error showing. If that happens, just check the log file for the line number causing the problem: \\servername\epicor\mfgsys803\server\logs\mfgtest803.server.log (or mfgsys803.server.log for the live DB).

Nigel.


--- In vantage@yahoogroups.com, "lvuhome" <lvuhome@...> wrote:
>
> I have not created an Alert program in BAM before. What are the steps of create an alerts program within BAM? can I use notepad to create and save as xxx.p?
>
> Thank you
>
> --- In vantage@yahoogroups.com, "Nigel Kerley" <nigel.kerley@> wrote:
> >
> > We use a BAM to accomplish basically the same thing on POs. You might be able to amend to work with Requisitions.
> >
> > The BAM was created against the POHeader table and the selected fields are "ApprovalStatus" and "ApprovedBy".
> >
> > The Rules are that ApprovalStatus = 'A' and ApprovedBy <> ''.
> >
> > An Alert program is then run which sends the actual email:
> >
> >
> > /* Send email whenever a Purchase Order is created */
> > {ud/GlbAlert.i &TableName = "POHeader"}
> >
> > DEFINE VARIABLE NewEmailBody AS CHARACTER NO-UNDO.
> >
> > FIND Vendor WHERE (Vendor.Company = POHeader.Company) AND(Vendor.VendorNum = POHeader.VendorNum) NO-LOCK.
> >
> > FIND PurAgent WHERE (PurAgent.Company = POHeader.Company) AND
> > (PurAgent.BuyerId = POHeader.BuyerID) NO-LOCK.
> >
> > FIND POApvMsg WHERE (POApvMsg.Company = POHeader.Company) AND
> > (POApvMsg.PONum = POHeader.PONum) AND (POApvMsg.MsgType = "2") NO-LOCK NO-ERROR.
> >
> > /* Don't send email if PO is closed */
> > If NOT (POHeader.OpenOrder) THEN DO:
> > RETURN "CANCEL SEND":U.
> > END.
> >
> > /* Create email */
> > ASSIGN Email-To = STRING(PurAgent.EMailAddress)
> >
> > Email-Subject = "Purchase Order has been approved: # " + STRING(POHeader.PONum)
> >
> > /* Create the new body of the email */
> > NewEmailBody = "~nOrder Number: " + STRING(POHeader.PONum)
> > + "~n~nSupplier: " + STRING(Vendor.Name)
> > + "~n~nOrder Date: " + STRING(POHeader.OrderDate).
> >
> > ASSIGN NewEmailBody = NewEmailBody
> > + "~n~nEntry Person: " + STRING(POHeader.EntryPerson)
> > + "~n~nApproved Value: " + STRING(POHeader.ApprovedAmount).
> >
> > IF AVAILABLE POApvMsg THEN DO:
> > ASSIGN NewEmailBody = NewEmailBody + "~nMessage: " + STRING(POApvMsg.MsgText).
> > END.
> >
> > ASSIGN NewEmailBody = NewEmailBody
> > + "~n~nDO NOT REPLY TO THIS E-MAIL ACCOUNT, IT DOES NOT GET REVIEWED!".
> >
> > /* Print Email Body */
> > ASSIGN Email-Text = NewEmailBody
> >
> >
> >
> >
> > You might be able to create something similar against the ReqHead table and use the StatusType field.
> >
> >
> > HTH,
> >
> > Nigel.
> >
> >
> > --- In vantage@yahoogroups.com, "lvuhome" <lvuhome@> wrote:
> > >
> > > Hi There,
> > >
> > > Is any one have the BPM code want to share with me or show me how regarding sending email to requestor when the Requisition status is change either from Pending to Orderred.
> > >
> > > Thank you very much
> > >
> >
>
Thanks Nigel for your input. I was able to get the Requisition to email to requestor/dispacher.

Now I want to go further with the email, I don't know if any one know the logic to print the Requisition lines detail in the email if there is more then one line items.

Lam

--- In vantage@yahoogroups.com, "Nigel Kerley" <nigel.kerley@...> wrote:
>
> Yes, just copy & paste the code below into Notepad, amend it and save it.
>
> Alert programs are normally saved in \\servername\epicor\mfgsys803\server\ud\xxx.p
>
> When creating the BAM set the path to the program as "ud\xxx.p" - no need to use the full path, even on client PCs.
>
> The only problem with using Notepad is that you've no way of knowing that your code is ok until Vantage runs it. There may be some Progress program supplied with Vantage but I've never looked for it. If the code has errors you'll probably get a 4GL error showing. If that happens, just check the log file for the line number causing the problem: \\servername\epicor\mfgsys803\server\logs\mfgtest803.server.log (or mfgsys803.server.log for the live DB).
>
> Nigel.
>
>
> --- In vantage@yahoogroups.com, "lvuhome" <lvuhome@> wrote:
> >
> > I have not created an Alert program in BAM before. What are the steps of create an alerts program within BAM? can I use notepad to create and save as xxx.p?
> >
> > Thank you
> >
> > --- In vantage@yahoogroups.com, "Nigel Kerley" <nigel.kerley@> wrote:
> > >
> > > We use a BAM to accomplish basically the same thing on POs. You might be able to amend to work with Requisitions.
> > >
> > > The BAM was created against the POHeader table and the selected fields are "ApprovalStatus" and "ApprovedBy".
> > >
> > > The Rules are that ApprovalStatus = 'A' and ApprovedBy <> ''.
> > >
> > > An Alert program is then run which sends the actual email:
> > >
> > >
> > > /* Send email whenever a Purchase Order is created */
> > > {ud/GlbAlert.i &TableName = "POHeader"}
> > >
> > > DEFINE VARIABLE NewEmailBody AS CHARACTER NO-UNDO.
> > >
> > > FIND Vendor WHERE (Vendor.Company = POHeader.Company) AND(Vendor.VendorNum = POHeader.VendorNum) NO-LOCK.
> > >
> > > FIND PurAgent WHERE (PurAgent.Company = POHeader.Company) AND
> > > (PurAgent.BuyerId = POHeader.BuyerID) NO-LOCK.
> > >
> > > FIND POApvMsg WHERE (POApvMsg.Company = POHeader.Company) AND
> > > (POApvMsg.PONum = POHeader.PONum) AND (POApvMsg.MsgType = "2") NO-LOCK NO-ERROR.
> > >
> > > /* Don't send email if PO is closed */
> > > If NOT (POHeader.OpenOrder) THEN DO:
> > > RETURN "CANCEL SEND":U.
> > > END.
> > >
> > > /* Create email */
> > > ASSIGN Email-To = STRING(PurAgent.EMailAddress)
> > >
> > > Email-Subject = "Purchase Order has been approved: # " + STRING(POHeader.PONum)
> > >
> > > /* Create the new body of the email */
> > > NewEmailBody = "~nOrder Number: " + STRING(POHeader.PONum)
> > > + "~n~nSupplier: " + STRING(Vendor.Name)
> > > + "~n~nOrder Date: " + STRING(POHeader.OrderDate).
> > >
> > > ASSIGN NewEmailBody = NewEmailBody
> > > + "~n~nEntry Person: " + STRING(POHeader.EntryPerson)
> > > + "~n~nApproved Value: " + STRING(POHeader.ApprovedAmount).
> > >
> > > IF AVAILABLE POApvMsg THEN DO:
> > > ASSIGN NewEmailBody = NewEmailBody + "~nMessage: " + STRING(POApvMsg.MsgText).
> > > END.
> > >
> > > ASSIGN NewEmailBody = NewEmailBody
> > > + "~n~nDO NOT REPLY TO THIS E-MAIL ACCOUNT, IT DOES NOT GET REVIEWED!".
> > >
> > > /* Print Email Body */
> > > ASSIGN Email-Text = NewEmailBody
> > >
> > >
> > >
> > >
> > > You might be able to create something similar against the ReqHead table and use the StatusType field.
> > >
> > >
> > > HTH,
> > >
> > > Nigel.
> > >
> > >
> > > --- In vantage@yahoogroups.com, "lvuhome" <lvuhome@> wrote:
> > > >
> > > > Hi There,
> > > >
> > > > Is any one have the BPM code want to share with me or show me how regarding sending email to requestor when the Requisition status is change either from Pending to Orderred.
> > > >
> > > > Thank you very much
> > > >
> > >
> >
>
Hi Lam,

Here's the code to include the detail lines for a PO BAM we have in place. Again, you should be able to amend it for Requisitions:

Towards the top of the .p file:
FIND PODetail WHERE (PODetail.Company = POHeader.Company) AND
(PODetail.PONUM = POHeader.PONum) NO-LOCK NO-ERROR.

In the body of the code:
/* Lines of Order */
FOR EACH PODetail of POHeader no-lock:
FIND PORel WHERE (PORel.Company = PODetail.Company) AND
(PORel.PONum = PODetail.PONUM) AND (PORel.POLine = PODetail.POLine) NO-LOCK NO-ERROR.

FOR EACH PORel of PODetail no-lock:
Assign NewEmailBody = NewEmailBody
+ " Item " + STRING(PODetail.POLine) + ": "
+ STRING(PODetail.PartNum) + " " + STRING(PODetail.LineDesc)
+ " - Due: " + STRING(PORel.DueDate)
+ " - Qty: " + STRING(PODetail.OrderQty)
+ " - Price: " + STRING(PODetail.UnitCost)
+ "~n".
END.
END.


HTH,

Nigel.



--- In vantage@yahoogroups.com, "lvuhome" <lvuhome@...> wrote:
>
> Thanks Nigel for your input. I was able to get the Requisition to email to requestor/dispacher.
>
> Now I want to go further with the email, I don't know if any one know the logic to print the Requisition lines detail in the email if there is more then one line items.
>
> Lam
>
> --- In vantage@yahoogroups.com, "Nigel Kerley" <nigel.kerley@> wrote:
> >
> > Yes, just copy & paste the code below into Notepad, amend it and save it.
> >
> > Alert programs are normally saved in \\servername\epicor\mfgsys803\server\ud\xxx.p
> >
> > When creating the BAM set the path to the program as "ud\xxx.p" - no need to use the full path, even on client PCs.
> >
> > The only problem with using Notepad is that you've no way of knowing that your code is ok until Vantage runs it. There may be some Progress program supplied with Vantage but I've never looked for it. If the code has errors you'll probably get a 4GL error showing. If that happens, just check the log file for the line number causing the problem: \\servername\epicor\mfgsys803\server\logs\mfgtest803.server.log (or mfgsys803.server.log for the live DB).
> >
> > Nigel.
> >
> >
> > --- In vantage@yahoogroups.com, "lvuhome" <lvuhome@> wrote:
> > >
> > > I have not created an Alert program in BAM before. What are the steps of create an alerts program within BAM? can I use notepad to create and save as xxx.p?
> > >
> > > Thank you
> > >
> > > --- In vantage@yahoogroups.com, "Nigel Kerley" <nigel.kerley@> wrote:
> > > >
> > > > We use a BAM to accomplish basically the same thing on POs. You might be able to amend to work with Requisitions.
> > > >
> > > > The BAM was created against the POHeader table and the selected fields are "ApprovalStatus" and "ApprovedBy".
> > > >
> > > > The Rules are that ApprovalStatus = 'A' and ApprovedBy <> ''.
> > > >
> > > > An Alert program is then run which sends the actual email:
> > > >
> > > >
> > > > /* Send email whenever a Purchase Order is created */
> > > > {ud/GlbAlert.i &TableName = "POHeader"}
> > > >
> > > > DEFINE VARIABLE NewEmailBody AS CHARACTER NO-UNDO.
> > > >
> > > > FIND Vendor WHERE (Vendor.Company = POHeader.Company) AND(Vendor.VendorNum = POHeader.VendorNum) NO-LOCK.
> > > >
> > > > FIND PurAgent WHERE (PurAgent.Company = POHeader.Company) AND
> > > > (PurAgent.BuyerId = POHeader.BuyerID) NO-LOCK.
> > > >
> > > > FIND POApvMsg WHERE (POApvMsg.Company = POHeader.Company) AND
> > > > (POApvMsg.PONum = POHeader.PONum) AND (POApvMsg.MsgType = "2") NO-LOCK NO-ERROR.
> > > >
> > > > /* Don't send email if PO is closed */
> > > > If NOT (POHeader.OpenOrder) THEN DO:
> > > > RETURN "CANCEL SEND":U.
> > > > END.
> > > >
> > > > /* Create email */
> > > > ASSIGN Email-To = STRING(PurAgent.EMailAddress)
> > > >
> > > > Email-Subject = "Purchase Order has been approved: # " + STRING(POHeader.PONum)
> > > >
> > > > /* Create the new body of the email */
> > > > NewEmailBody = "~nOrder Number: " + STRING(POHeader.PONum)
> > > > + "~n~nSupplier: " + STRING(Vendor.Name)
> > > > + "~n~nOrder Date: " + STRING(POHeader.OrderDate).
> > > >
> > > > ASSIGN NewEmailBody = NewEmailBody
> > > > + "~n~nEntry Person: " + STRING(POHeader.EntryPerson)
> > > > + "~n~nApproved Value: " + STRING(POHeader.ApprovedAmount).
> > > >
> > > > IF AVAILABLE POApvMsg THEN DO:
> > > > ASSIGN NewEmailBody = NewEmailBody + "~nMessage: " + STRING(POApvMsg.MsgText).
> > > > END.
> > > >
> > > > ASSIGN NewEmailBody = NewEmailBody
> > > > + "~n~nDO NOT REPLY TO THIS E-MAIL ACCOUNT, IT DOES NOT GET REVIEWED!".
> > > >
> > > > /* Print Email Body */
> > > > ASSIGN Email-Text = NewEmailBody
> > > >
> > > >
> > > >
> > > >
> > > > You might be able to create something similar against the ReqHead table and use the StatusType field.
> > > >
> > > >
> > > > HTH,
> > > >
> > > > Nigel.
> > > >
> > > >
> > > > --- In vantage@yahoogroups.com, "lvuhome" <lvuhome@> wrote:
> > > > >
> > > > > Hi There,
> > > > >
> > > > > Is any one have the BPM code want to share with me or show me how regarding sending email to requestor when the Requisition status is change either from Pending to Orderred.
> > > > >
> > > > > Thank you very much
> > > > >
> > > >
> > >
> >
>
Hi Nigel

I added the below codes into the p file

FOR EACH reqhead no-lock:
FIND reqdetail WHERE (reqhead.Company = reqdetail.Company) AND
(reqhead.reqnum = reqdetail.reqnum) NO-LOCK NO-ERROR.
FOR EACH reqdetail of reqhead no-lock:
Assign NewEmailBody = NewEmailBody
+ " Item " + STRING(reqdetail.reqline) + ": "
+ STRING(reqdetail.PartNum) + " " + STRING(reqdetail.LineDesc)
+ " - Qty: " + STRING(reqdetail.OrderQty)
+ "~n".
END.
END.

and get the error in the log as
[09/05/14@13:30:42.444-0400] P-004840 T-005616 1 AS -- Cannot change cursor of buffer reqhead when executing a trigger. (2873)

Do you know what is wrong with it.

Thanks.
Lam


--- In vantage@yahoogroups.com, "Nigel Kerley" <nigel.kerley@...> wrote:
>
> Hi Lam,
>
> Here's the code to include the detail lines for a PO BAM we have in place. Again, you should be able to amend it for Requisitions:
>
> Towards the top of the .p file:
> FIND PODetail WHERE (PODetail.Company = POHeader.Company) AND
> (PODetail.PONUM = POHeader.PONum) NO-LOCK NO-ERROR.
>
> In the body of the code:
> /* Lines of Order */
> FOR EACH PODetail of POHeader no-lock:
> FIND PORel WHERE (PORel.Company = PODetail.Company) AND
> (PORel.PONum = PODetail.PONUM) AND (PORel.POLine = PODetail.POLine) NO-LOCK NO-ERROR.
>
> FOR EACH PORel of PODetail no-lock:
> Assign NewEmailBody = NewEmailBody
> + " Item " + STRING(PODetail.POLine) + ": "
> + STRING(PODetail.PartNum) + " " + STRING(PODetail.LineDesc)
> + " - Due: " + STRING(PORel.DueDate)
> + " - Qty: " + STRING(PODetail.OrderQty)
> + " - Price: " + STRING(PODetail.UnitCost)
> + "~n".
> END.
> END.
>
>
> HTH,
>
> Nigel.
>
>
>
> --- In vantage@yahoogroups.com, "lvuhome" <lvuhome@> wrote:
> >
> > Thanks Nigel for your input. I was able to get the Requisition to email to requestor/dispacher.
> >
> > Now I want to go further with the email, I don't know if any one know the logic to print the Requisition lines detail in the email if there is more then one line items.
> >
> > Lam
> >
> > --- In vantage@yahoogroups.com, "Nigel Kerley" <nigel.kerley@> wrote:
> > >
> > > Yes, just copy & paste the code below into Notepad, amend it and save it.
> > >
> > > Alert programs are normally saved in \\servername\epicor\mfgsys803\server\ud\xxx.p
> > >
> > > When creating the BAM set the path to the program as "ud\xxx.p" - no need to use the full path, even on client PCs.
> > >
> > > The only problem with using Notepad is that you've no way of knowing that your code is ok until Vantage runs it. There may be some Progress program supplied with Vantage but I've never looked for it. If the code has errors you'll probably get a 4GL error showing. If that happens, just check the log file for the line number causing the problem: \\servername\epicor\mfgsys803\server\logs\mfgtest803.server.log (or mfgsys803.server.log for the live DB).
> > >
> > > Nigel.
> > >
> > >
> > > --- In vantage@yahoogroups.com, "lvuhome" <lvuhome@> wrote:
> > > >
> > > > I have not created an Alert program in BAM before. What are the steps of create an alerts program within BAM? can I use notepad to create and save as xxx.p?
> > > >
> > > > Thank you
> > > >
> > > > --- In vantage@yahoogroups.com, "Nigel Kerley" <nigel.kerley@> wrote:
> > > > >
> > > > > We use a BAM to accomplish basically the same thing on POs. You might be able to amend to work with Requisitions.
> > > > >
> > > > > The BAM was created against the POHeader table and the selected fields are "ApprovalStatus" and "ApprovedBy".
> > > > >
> > > > > The Rules are that ApprovalStatus = 'A' and ApprovedBy <> ''.
> > > > >
> > > > > An Alert program is then run which sends the actual email:
> > > > >
> > > > >
> > > > > /* Send email whenever a Purchase Order is created */
> > > > > {ud/GlbAlert.i &TableName = "POHeader"}
> > > > >
> > > > > DEFINE VARIABLE NewEmailBody AS CHARACTER NO-UNDO.
> > > > >
> > > > > FIND Vendor WHERE (Vendor.Company = POHeader.Company) AND(Vendor.VendorNum = POHeader.VendorNum) NO-LOCK.
> > > > >
> > > > > FIND PurAgent WHERE (PurAgent.Company = POHeader.Company) AND
> > > > > (PurAgent.BuyerId = POHeader.BuyerID) NO-LOCK.
> > > > >
> > > > > FIND POApvMsg WHERE (POApvMsg.Company = POHeader.Company) AND
> > > > > (POApvMsg.PONum = POHeader.PONum) AND (POApvMsg.MsgType = "2") NO-LOCK NO-ERROR.
> > > > >
> > > > > /* Don't send email if PO is closed */
> > > > > If NOT (POHeader.OpenOrder) THEN DO:
> > > > > RETURN "CANCEL SEND":U.
> > > > > END.
> > > > >
> > > > > /* Create email */
> > > > > ASSIGN Email-To = STRING(PurAgent.EMailAddress)
> > > > >
> > > > > Email-Subject = "Purchase Order has been approved: # " + STRING(POHeader.PONum)
> > > > >
> > > > > /* Create the new body of the email */
> > > > > NewEmailBody = "~nOrder Number: " + STRING(POHeader.PONum)
> > > > > + "~n~nSupplier: " + STRING(Vendor.Name)
> > > > > + "~n~nOrder Date: " + STRING(POHeader.OrderDate).
> > > > >
> > > > > ASSIGN NewEmailBody = NewEmailBody
> > > > > + "~n~nEntry Person: " + STRING(POHeader.EntryPerson)
> > > > > + "~n~nApproved Value: " + STRING(POHeader.ApprovedAmount).
> > > > >
> > > > > IF AVAILABLE POApvMsg THEN DO:
> > > > > ASSIGN NewEmailBody = NewEmailBody + "~nMessage: " + STRING(POApvMsg.MsgText).
> > > > > END.
> > > > >
> > > > > ASSIGN NewEmailBody = NewEmailBody
> > > > > + "~n~nDO NOT REPLY TO THIS E-MAIL ACCOUNT, IT DOES NOT GET REVIEWED!".
> > > > >
> > > > > /* Print Email Body */
> > > > > ASSIGN Email-Text = NewEmailBody
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > You might be able to create something similar against the ReqHead table and use the StatusType field.
> > > > >
> > > > >
> > > > > HTH,
> > > > >
> > > > > Nigel.
> > > > >
> > > > >
> > > > > --- In vantage@yahoogroups.com, "lvuhome" <lvuhome@> wrote:
> > > > > >
> > > > > > Hi There,
> > > > > >
> > > > > > Is any one have the BPM code want to share with me or show me how regarding sending email to requestor when the Requisition status is change either from Pending to Orderred.
> > > > > >
> > > > > > Thank you very much
> > > > > >
> > > > >
> > > >
> > >
> >
>