Hi Everyone!
Has anyone tried to automate Capable to Promise in using a Method Directive?
I’d like to have CTP run automatically as EDI orders enter the system.
Within the Erp.BO.SalesOrder.Update method, I’m trying to trigger the method “CalculateCTP” and one of the specified parameters is requesting a type of “CapPromiseTableset”. I’m stuck on this parameter. How might I create a variable of this type?
@aidenhoffman I’ve been wanting to try this for a long time but hadn’t gotten around to it. In fact, I’d like to do it at the time of quote (sort of like a lead time estimate).
Have you done a client trace for CTP? I’ve not checked it out but it sounds like there should be another method to call first to generate that dataset. Is there another method to ‘CalculateATP’ ?
For doing BPMs it’s essential. Get familiar with it because it’s the quickest way to prototype what you want a BPM to do, and it gives you all the methods and data sets you need to see in order to create your BPM.
After running a trace, I see 3 CTP methods being used. I wrote this code using those methods and this video.
The BPM is triggered but I get an error regarding a null reference within the CalculateCTP method.
I think CapPromiseGetNew() is returning a CapPromise tableset that I’m putting in promData, but a null says otherwise.
Any tips on what I’m doing wrong, or how I could dig into my promData object? I’d like to view all its child parameters. Thanks!
foreach(var order in ttOrderHed)
{
using (var srvc = ServiceRenderer.GetService<Erp.Contracts.CapPromiseSvcContract>(Db))
{
string msg = "msg ah";
var promData = srvc.CapPromiseGetNew(6090293);
foreach(var row in promData.CapPromiseDtl)
{
row.RowMod = "U";
}
srvc.CalculateCTP(false, out msg, ref promData);
srvc.ConfirmCTP(out msg, ref promData);
}
}
Ok - good progress. When you did the trace - did you choose 'Write Full dataset"? This can be a big help in seeing what the client changed between method calls. Assuming the dataset coming from CapPromiseGetNew() is different when it sends it to CalculateCTP() you should be able to see that difference and then adjust your code to change the value of the dataset to the method doesn’t give you the error.
I hesitate to mention these because I don’t know your skill level (and because I’ve only used it a few times) BUT there is a great tool called PostMan (https://www.postman.com). It’s used for debugging Method calls like this because it mimics the client. The simplisitic view is that the client really just makes a series of Method calls and manipulates the datasets in between calls - so building a BPM is really just mimicking the Client and doing something with the data to cause the effect you want. If you get Postman and take a few minutes to set it up and learn it (lots of info on here for connecting to Epicor) then you can do those three method calls and see the data at each step. You can also alter the data enough to just do the last call.
I hadn’t selected “write full dataset”, but I will!
I’ve used postman when I build my own APIs but I hadn’t considered using it with Epicor.
I’ll give it a shot, thanks Mike! Great info!
For future readers, turns out a BPM is not needed to automate CTP. If you enable the CTP settings on the Customer demand, ship to demand, and check multi-level CTP on the part, Epicor will run the process for you when you import the order.
Interesting find, thanks for sharing. I didn’t see that before - We don’t use ‘demand’ management at all, nor do we import orders. We configure and quote, then convert to orders. I wonder if that works too?
But first I have to find out why all my demand tab fields are greyed out… Maybe b/c we don’t have the Demand Mgmt module license… I’ll have to check.
Interesting, different business models. We don’t quote and we’re heavy on electronic demand. Not sure which modules we have. Thanks again for your help Mike!