web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Where are ReqPO entries deleted when deleting a plan?

(0) ShareShare
ReportReport
Posted on by

Hello there,

I am currently struggling to find the code position where entries of the "ReqPO" table are deleted when using the "Delete plan" dialogue found under "Master planning > Periodic > Plans > Delete plan."

There's the delete method in the table "ReqPlanVersion", which should be triggered by a delete action from what I see, but when I set a breakpoint and delete a plan, it's not met.

There's also the "deletePlanInternal" method in the class "ReqPlanDelete", which is called when deleting a plan. From what I saw in the debugger, stepping through the code, the call 

this.backgroundJobService().startPlanVersionCleanup(sourcePlanVersion);

should be my searched position. However, I can't really seem to find the exact position where ReqPO entries are deleted.

I have a table which has to be synchronised to ProdRoute, ProdTable, ProdRouteJob, ReqPO and many more - the "delete plan" option is a task that has to be synchronised as well, so I need a position where I can enter my own code.

Thank you very much in advance!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at

    The whole functionality behind deleting a plan uses a batch job. A task (PlanVersionCleanup) is being added to this batch and a few moments later the job is being executed.

    The ReqPlanDelete classe's 'run'-method is being called while the job is being executed. Right before the 

    endLengthyOperation();

    code, I added a call to a new method I created in the same class:

    this.<prefix>_planDeletion();

    In this method I'm comparing my table to the ReqPO table to find differences and then delete those missing jobs from my table:

    private void <prefix>__planDeletion()
    {
        <prefix>_AsyncNum   <prefix>_AsyncNum;
        <prefix>_NumType    <prefix>_NumType;
        ReqPO           	reqPO;
        <prefix>_Job    	<prefix>_Job;
        RecId           	planVersion = <prefix>_Aux::getPlanVersion();
        ;
    
        // Catch data to delete from <prefix>_Job (planned production orders)
        <prefix>_NumType = <prefix>_NumType::PlannedProductionOrder;
    
        insert_recordset <prefix>_Async(MBNumType, ProdId, ProdRefRecId)
        select
            MBNumType,
            ProdId,
            ProdRefRecId
        from <prefix>_Job
        group by
            <prefix>_Job.MBNumType,
            <prefix>_Job.ProdId,
            <prefix>_Job.ProdRefRecId
        where 1 == 1
            && <prefix>_Job.MBNumType == <prefix>_NumType
        notexists join reqPO
        where 1 == 1
            && reqPO.PlanVersion == planVersion
            && reqPO.RefId       == <prefix>_Job.ProdId
            && reqPO.RefType     == ReqRefType::BOMPlannedOrder;
    
        // Delete data from <prefix>_Job
        <prefix>_Job::jobDelete(<prefix>_Async);
    }

    I replaced my company's prefix and changed some object's names; however, the functionality should be clear and I hope this is somewhat explainable and hopefully useable for one or another.

    Best regards

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans
Liquid error: parsing "/globalsearch/?q=new+holland+methodist+church%2C+lincolnshire+%7C+lincolnshire+%7C++filetype%3Axls" - Nested quantifier +.