Adding Order Line negative Miscellaneous Charge does not update Header Total

Hi
I have a Data Directive DPM that is adding Order Line Miscellaneous Charges (negative as they are actually deductions/allowances) that follows what I see in a Trace when done through the UI. (GetNewOrderMisc, ChangeMiscCode, MasterUpdate). This works great and the line amounts are updated, but the Header does not include the amounts after the BPM runs. I do not see any other BO call in the Trace logs to trigger a recalculation of the Header. If you remove a charge in the UI after it is done, it adds that amount to the Header. So something is not getting triggered in the BPM that does in the UI. I see others who have done this in this site but no one has indicated they see this behavior. Any ideas would be appreciated

How are you calling the MasterUpdate? Do you have 2 rows, one with RowMod empty and the other with U ? If you share the code some people might be able to help you.

Hi Dragos,
Thanks for responding. I am not sure what you mean by 2 rows. These are existing orders that I process after they are brought in via EDI Demand. I am basically following what I see in the Trace when line charges are added in the UI. Here is the relevant code snippet (I get the Charge codes from a custom UD table that contains “rules”

var chg = Db.MiscChrg.Where(c => c.MiscCode == rul.Key2).FirstOrDefault();
so.GetNewOrderMsc(ref ts, ordNum, orderLine);
index = ts.OrderMsc.Count();
var rec = ts.OrderMsc[index - 1];//.Last();
rec.MiscCode = chg.MiscCode;
rec.MiscAmt = chg.MiscAmt;
rec.DocMiscAmt = chg.MiscAmt;
rec.DocDspMiscAmt = chg.MiscAmt;
rec.DspMiscAmt = chg.MiscAmt;
rec.Description = chg.Description;
rec.MiscCodeDescription = chg.Description;
rec.FreqCode = chg.FreqCode;
rec.Type = chg.Type;
rec.Percentage = chg.Percentage;
so.ChangeMiscCode(ref ts, “OrderMsc”);
ts.OrderDtl[i].RowMod = “U”;
ttOrderHed[j].RowMod = “U”;
Db.Validate();
string cResponseMsg;
string cCreditShipAction;
string cDisplayMsg;
string cCompliantMsg;
string cResponseMsgOrdRel;
string cAgingMessage;
bool cont;
so.MasterUpdate(true, true, “OrderMsc”, custNum, ordNum, true, out cont, out cResponseMsg, out cCreditShipAction,
out cDisplayMsg,
out cCompliantMsg,
out cResponseMsgOrdRel,
out cAgingMessage,
ref ts);

This correctly updates the line item total and miscellaneous charge total. If the unit price would change I could call ChangeUnitPrice, which works in another BPM I have that updates the pricelist based on a code in a UD field in the order header.

I appreciate any insight you have

Carl

OK, what table did you use for the BPM ? Is it In-Tran or Standard ?

Hi,
It is a Standard Data Directive on the OrderHed table. It uses the SalesOrderSvcContract. I retrieve the rows to loop through like so:
Snippet

using (var so = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderSvcContract>(Db))
var headCount = ttOrderHed.Count();
for (var j = 0; j < headCount; j++)
{
var ts = new Erp.Tablesets.SalesOrderTableset();
ts = so.GetByID(ttOrderHed[j].OrderNum);

I wouldn’t call the MasterUpdate from the standard directive, it may end up calling itself. I think you need a different BPM. Have a look at this post, looks like it is exactly what you want to do.

1 Like

Hi- that post refers to a Miscellaneous Charge on the header, not the lines. And when you add a charge in the UI, it calls MasterUpdate once…

I have tried every combination of Update, MasterUpdate, In-Trans and Standard. None of them seem to update the totals in the header. I am waiting on an Epicor Support person to come back from vacation.

I will keep trying…

Thanks, and if something else pops into your head, let me know…

I doubt you’ll find the exact code you need. The idea is to tweak it until it works for you. I like to use functions so I did some tests with one and it seems to work for me. It’s basically:

GetByID
GetNewOrderMsc
set OrderMsc.MiscCode field
ChangeMiscCode
set OrderMsc.DocDspMiscAmt field
ChangeMiscAmount
MasterUpdate

The order in which you call/do those above is very important. Also, when are they called is equally important (pre/post, standard/in-tran, which method, etc.).

See the function I used attached, maybe it helps. It’s only widgets, no code.
TESTMC.efxb (51.2 KB)

1 Like

Hi Dragos,
THANK YOU!!!- I will test this over the next two days and let you know my results. Dealing with issues after refreshing our Test Instance from Pilot :frowning:

Hi,
I tried your function and it seems to replicate what my code does- adds the line charges, correctly calculates the line miscellaneous charge total, but never updates the header. I am unsure if your testing called this multiple times per row or not. I am beginning to wonder if this is a bug in Kinetic 2022.1. I will continue to try moving the code around between BPMs to see if things change. Plus the resource I am waiting should be back next week. Thanks for giving me more things to try

Hi Dragos,
An update. I have successfully used your function in a Method Directive that seems to be consistent in updating the header totals. I fire it by adding a checkbox on the form that fires the BPM when they save the record, then unsets the checkbox. However, I cannot get this to work from a Data Directive, using code as close as you can get when doing it in a Data Directive.

It is a Post Processing Method Directive enabled in a Pre-Processing Directive.

From my testing many different scenarios it appears Method Directives cannot be fired from a Data Directive even if you call the same Business Object the Method Directive “monitors”. Probably a good thing to prevent infinite loops.

I may just resort to the Order Entry folks having to set that flag when they review the order- we only do this for certain customers anyway. Our EDI team says they can do this for EDI orders at mapping time, so that will address that when we finally Go Live…

Thank you so much for your help - this web site is invaluable to reach resources such as you.

Carl

1 Like