Thanks Nigel.
Our commission rate actually depends on the customer, the first sales rep on the order, and the part on the line.
When any of those change, I need to update the rep rate(s). If the part changes, it is simply that line that is affected, and I can code it in the ChangePartNumber method, and it works great.
If SalesRepCode1 or the CustNum changes, I need to iterate over all OrderDtl lines and update the commission rates. I was able to accomplish this in the SalesOrder.Update method, using a pre-process directive to enable a post process directive to update OrderDtl. I still have some testing to do, but so far it seems to work correctly.
Thanks again!
Mike
Our commission rate actually depends on the customer, the first sales rep on the order, and the part on the line.
When any of those change, I need to update the rep rate(s). If the part changes, it is simply that line that is affected, and I can code it in the ChangePartNumber method, and it works great.
If SalesRepCode1 or the CustNum changes, I need to iterate over all OrderDtl lines and update the commission rates. I was able to accomplish this in the SalesOrder.Update method, using a pre-process directive to enable a post process directive to update OrderDtl. I still have some testing to do, but so far it seems to work correctly.
Thanks again!
Mike
--- In vantage@yahoogroups.com, "Nigel Kerley" <nigel.kerley@...> wrote:
>
> My understanding is that there's only one temp table at a time. So when you're changing the Customer on an Order the temp table is ttOrderHed, but the actual Order lines are no longer in "temp" they're "live" (if there are any), so to link to that table you just use OrderDtl.
>
> However, with the OpenEdge licence as supplied you can't write directly to a live table - "orderdtl.RepRate1 = 7" won't work - so you have to "cheat". Try this:
>
>
> for each OrderDtl where OrderDtl.company = ttorderhed.company and OrderDtl.ordernum = ttorderhed.ordernum no-lock:
>
> {lib/PublishInfoMsg.i &InfoMsg = "'Found an orderdtl.'"}
> Run lib\UpdateTableBuffer.p(input BUFFER OrderDtl:HANDLE, 'RepRate1',7).
>
>
>
> HTH,
>
> Nigel.
>
>
> --- In vantage@yahoogroups.com, "mretzlercooper" <mretzler@> wrote:
> >
> > Our commission rate depends on who the customer is. I want to update the field RepRate1 on all OrderDtl lines when the customer changes via a BPM. It is actually more complicated than this, but the first step is to get this working
> >
> > I am not sure where the best place would be to put the 4GL code to accomplish this. Would it be on the SalesOrder.Update method, either as a pre-process or post-process directive? Or, should it be triggered on the ChangeCustomer method as a pre or post-process directive?
> >
> >
> > Here is my code, there are no conditions I have on the directive. I have tried this as both a pre and post process directive on the ChangeCustomer method. It displays the info message 'Found a ttorderhed' but does not display a message saying 'Found a ttorderdtl'.
> >
> >
> > find first ttorderhed where (ttorderhed.RowMod = 'A' or ttorderhed.RowMod = 'U') no-lock no-error.
> > if available ttorderhed then do:
> > {lib/PublishInfoMsg.i &InfoMsg = "'Found a ttorderhed.'"}
> >
> > for each ttOrderDtl where ttOrderDtl.company = ttorderhed.company and ttOrderDtl.ordernum = ttorderhed.ordernum no-lock:
> >
> > {lib/PublishInfoMsg.i &InfoMsg = "'Found a ttorderdtl.'"}
> > ttorderdtl.RepRate1 = 7.
> > end.
> > end.
> >
>