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)

how to find the sub-BOM?

(0) ShareShare
ReportReport
Posted on by

Hello!

I'm trying to overcome with finding sub-BOM in any table. I would like to use it on my form, that is why I do not need to find it from "user level", but in particular field in some table.

Where Can I start to looking for?

*This post is locked for comments

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

    Hi there, you can start by looking in the "BOM" or "BOMTable" tables.

    Regards

    Charné

  • Verified answer
    Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    if you want to find BOM lines for any item, following is for your inspiration

    the example below is exploring BOM lines based on any sales item. you can create it as per your need

    SalesLineExplodeBOM salesLineExplodeBOM; 
        SalesLine           SalesLine;
        BOM                 bom;
        container           conBOM;
        int                 numBOMLines, i;
        TmpFrmVirtual         tmpFrmVirtual;
         BOM                   tmpBOM;
        
        salesLineExplodeBOM = SalesLineExplodeBOM::construct();
        
        salesLine = SalesLine::findRecId(5637357585);
        if (!salesLine.inventTable().inventItemType().canHaveBOM())
        {
            throw error("@SYS2069");
        }
        else
        {
            bom.setTmp();
            tmpFrmVirtual = null;
            tmpBOM = null;        
            tmpBOM.setTmp();
            conBOM = BOMSearch::bomTreePackLevelConfig(salesLine.ItemBOMId ? salesLine.ItemBOMId : salesLine.inventTable().bomId(salesLine.deliveryDate(), salesLine.QtyOrdered, salesLine.inventDim()),
                                                       salesLine.deliveryDate(),
                                                       salesLine.ItemId,
                                                       salesLine.inventDim().ConfigId,
                                                       true,
                                                       true);
    
            numBOMLines = conlen(conBOM);
            for (i=1; i<=numBOMLines; i++)
            {
                tmpBOM.data(conpeek(conBOM,i));
                tmpBOM.doInsert();
            }
            
            bom.setTmpData(tmpBOM);
            
            ttsBegin;
                while select tmpBOM
                {
                    info(strFmt("Item Id %1",tmpBOM.ItemId));
                }
            ttsCommit;
            
        }


  • Community Member Profile Picture
    on at

    I have been looking in every table with name starts with "bom" without results. Anyway, Charne Ferreira, thanks for your interest:)

    As Regards foregoing code I can't find any special fragment where sub-Bom's are fetching. I understand that tmpBOM contains every parameter of our Bom, including that hidden in next-lined ones. But how to use it without '_validDate' and '_configId'? Or how to find them in ordinary BOM got from table?

    I thought there is some table, with column called "sub-Bom" or something like that.

  • Verified answer
    Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    Why you want to use it without valid Date and ConfigurationId?

    of course a BOM can be active/non-active as per some date so if you don't want to pass a date just pass today(), which will show you BOM(s) active as of today.

    About configuration parameter, BOM(s) can very based on configuration of item.

    Product subtype can be of two types

    Product master

    Product

    in case of Product master, its has one or more configuration of product, that's why this parameter is needed.

  • Community Member Profile Picture
    on at

    Well, I just need table/list of all the items inside Bom, including  sub-Boms. But my form does not need to consider situation where more than one configuration in available.

  • Verified answer
    Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    you can go ahead with empty configuration also.

    you can find a perfect example here

  • Community Member Profile Picture
    on at

    If I understood it correctly:

    itemId field can contain value witch technically is BOMId of its sub-bom??

    Is that how it works?

    The main thing I need is precisely BOMId.

  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    I did not got what you said in your last reply.

    but I would try to explain how its working

    All BOM Items information is saved in table named as BOM. All sub-boms are also save din save table.

    Whereas Bom versions information and active-inactive of bom(s) is saved in BOMVersion

    The example, which you saw above , is doing following

    //find active version of item's BOM

    //iterate through all item of BOM of selected Item

    {

    if (current item which is part of bom, has further Sub BOM)

    //repeat//iterate process

    }

  • Community Member Profile Picture
    on at

    The algorithm is clear as a day light, but it is getting itemId and working on it. My problem is that I need to work on BOMId. So can I get from this code BOMId?

    For example, if we have bom named "BOM-1234-56" with contains item 00123 and two other boms I need to find BOMId's of this two Sub-Boms.

  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    yes you can find BOM Id for any item, if you will review once more the algorithm, you will see that at start its always finding BOM Version, then its is proceeding to items.

    select firstonly bomVersion
                where bomVersion.ItemId == _itemid
                && bomVersion.Active
                && bomVersion.FromDate <= systemdateget()
                && (!bomVersion.ToDate || bomVersion.ToDate >= systemdateget());
    


     Now, using same approach you can collect active BOM versions and ultimately BOM.

    If you have any difficulty in writing code, le us know, so we can help you.

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
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Ali Zaidi Profile Picture

Ali Zaidi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans