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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Get Sales related to Production Order

(0) ShareShare
ReportReport
Posted on by

Hi guys,

I am developping a screen to drive production in our company. The tool is kind of planning displaying all Production Order planned and started that all production department will use to get a global view of the work. Logistic departement will drive the planning.

Now my requirement :

I need to get the SalesOrders related to each ProductionOrder and i'm really not comfortable with the multi level pegging tool (i think this is his name in english but not sure)

Can anybody give me some advice about how to achieve my goal, or how to browse through the multi level pegging tool ?

Thank's in advance.

*This post is locked for comments

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

    This could work, but when I checked in my ProdTable (DEV, TEST and PROD environment), 99% of data has not InventRefId and InventRefType populated (used for relations you describe). When / how is theese fields populated in normal case ?

  • Community Member Profile Picture
    on at

    Mmmh okay, I've looked and I go until method "initFromCaller" of ProdTable, but, this method is never called. (Am I totally missing something or what ???) To be honest, I'm a little bit lost...

  • Suggested answer
    Rustem Galiamov Profile Picture
    8,072 on at

    Hi Stephane M!

    These fields are populated when you create production order from sales order lines

    Screenshot-2018_2D00_12_2D00_06-at-14.35.06.png

    You can set breakpoint to clicked() method of this button and debug the process of production order creation.

  • Community Member Profile Picture
    on at

    After a brief discussion during lunch, I understand why theese fields are not populated.

    Production orders aren't created from SalesLine, they are created from 0. That's why I cant use theese fields. In fact, we dont create 1 Production Order per SalesLine.

    Thank's for help about this, now I back to my first question : How to get the SalesOrders related to each ProductionOrder considering previous informations. The multi level pegging tool has this information. So what is the logic behind this tool to get this information ? 

    If you can help me with this.

    For more informations : I have already done a function to browse through reqTrans and reqTransCov but I'm really not satisfied of my dev so that's why i ask you if you have advice for browsing.

  • Suggested answer
    Rustem Galiamov Profile Picture
    8,072 on at

    If you take a look at the ReqMultiLevelPegging form, you can see what this form uses reqTrans, reqTransCov tables as DS.

    And if you already done with these tables, why you not satisfied?

    Screenshot-2018_2D00_12_2D00_06-at-15.59.42.png

  • Community Member Profile Picture
    on at

    Sorry, I'm really not a good english speaker, maybe that's why I'm not clear on my difficult for this functionnality. I will try an other approach.

    Here is my code for now :  (Explanation in second post coming in several minutes)

    static void updatePlanProdLog()
    {
        DLZplanProdLog  planning;
    
        ttsBegin;
        while select forUpdate planning
        {
            planning.custAccount = DLZPlanProdLogReqMngt::getFirstCustomer(planning.ProdId).AccountNum; // we dont care for the moment
            planning.salesLineRecId = DLZPlanProdLogReqMngt::getFirstSalesLine(planning.ProdId).RecId;
            planning.update();
    
            DLZPlanProdLogInteraction::setFirstCurrentOpr(planning.ProdId); // we dont care for the moment
        }
        info("@DLZ655");
        ttsCommit;
    }
    public static SalesLine getFirstSalesLine(InventTransRefId _refId, ReqRefType _refType = ReqRefType::Production)
    {
        ReqTrans        reqTrans;
        InventTransOrigin   inventTransOrigin;
        SalesLine           salesLine;
        InventTransRefId    pRefId;
        ReqRefType          pReqRefType;
        RefRecId            pPlanVersion;
        container       recIdCollection,
                        recIdCollectionSorted;
        int             i;
        RefRecId        recId;
    
    
        // Récupération des paramètres
        pPlanVersion    = DLZPlanProdLogReqMngt::getCurrentPlanVersion().RecId;
        pRefId          = _refId;
        pReqRefType     = _refType;
    
        // Recupère l'origine des besoins les plus profond de notre OF
        recIdCollection += DLZPlanProdLogReqMngt::getUpstreamRef( pRefId, pReqRefType, pPlanVersion);
    
        // Suppression des RecId doublons
        for (i = 1; i <= conLen(recIdCollection); i++)
        {
            recId = conPeek(recIdCollection, i);
    
            if (!conFind(recIdCollectionSorted, recId))
            {
                recIdCollectionSorted += [recId];
            }
        }
    
        // Parcours les résultats. Si on trouve une CDC, on la retourne
        for (i = 1; i <= conLen(recIdCollectionSorted); i++)
        {
            recId = conPeek(recIdCollectionSorted, i);
            reqTrans = ReqTrans::findRecId(recId);
    
            if (reqTrans.RefType == ReqRefType::Sales)
            {
                // Retrouve les lignes correspondantes aux CDC
                inventTransOrigin = InventTransOrigin::find(reqTrans.InventTransOrigin);
                salesLine = SalesLine::findInventTransId(inventTransOrigin.InventTransId);
            }
        }
    
        return salesLine;
    }

    public static container getUpstreamRef( InventTransRefId    _refId,
                                            ReqRefType          _refType,
                                            RefRecId            _planVersion   )
    {
        ReqTrans        reqTrans;
        ReqTransCov     reqTransCov;
        RefRecId        recId, oldRecId;
        container       recIdCollection;
    
    
        reqTrans = ReqTrans::dlzGetCurrentLvl(_refId, _refType, _planVersion);
    
        recId       = reqTrans.RecId;
    
        recIdCollection += DLZPlanProdLogReqMngt::browseThroughRequirement(recId, _planVersion);
    
        return recIdCollection;
    }

    // Parcours l'origine des besoins
    public static container browseThroughRequirement(   RefRecId    _refRecId,
                                                        RefRecId    _planVersion)
    {
        ReqTrans        reqTrans;
        ReqTransCov     reqTransCov;
        RefRecId        recId, oldRecId;
        container       recIdCollection;
        InventTransRefId    pRefId;
        ReqRefType          pReqRefType;
        RefRecId            pPlanVersion;
    
        recId           = _refRecId;
        pPlanVersion    = _planVersion;
    
        if (ReqTransCov::dlzParentExist(recId))
        {
            // Get parents
            while select reqTransCov
                where reqTransCov.ReceiptRecId == recId
            {
                reqTrans = ReqTrans::findRecId(reqTransCov.IssueRecId);
                pRefId = reqTrans.RefId;
                switch(reqTrans.RefType)
                {
                    case ReqRefType::Production :
                    case ReqRefType::ProdLine :
                        pReqRefType = ReqRefType::Production;
                        break;
    
                    case ReqRefType::BOMPlannedOrder :
                    case ReqRefType::BOMLine :
                        pReqRefType = ReqRefType::BOMPlannedOrder;
                        break;
    
                    case ReqRefType::Sales :
                        pReqRefType = ReqRefType::Sales;
                        break;
                    default :
                        break;
                }
    
                recIdCollection += DLZPlanProdLogReqMngt::getUpstreamRef( pRefId, pReqRefType, pPlanVersion);
            }
        }
        else
        {
            recIdCollection += [recId];
        }
        return recIdCollection;
    }


  • Community Member Profile Picture
    on at

    My process is the following :

    Planning is getting populated with ProductionOrder when we "start" ProductionOrder.

    Right after that, I try to get a SalesLine with "DLZPlanProdLogReqMngt::getFirstSalesLine(planning.ProdId)".

    in getFirstSalesLine(), I go the deepest possible in reqTransCov by calling getUpstreamRef().

    getUpstreamRef() and browseThroughRequirement() are recursive to each other to go until the final level.

    During my browsing, I put all reference in container to finally check if I find some SalesLine.

    Problem:

    Because of recursivity, I have sometime a problem of pile (when Production Order refer to other Production Order which refer to first Production Order for exemple)

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Andrew Jones a1x Profile Picture

Andrew Jones a1x 2

#3
Basit Profile Picture

Basit 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans