web
You’re offline. This is a read only version of the page.
close
Skip to main content
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
    RE: how to find the sub-BOM?

    public void allBomItems(BOMId _bomid)
    {

    BOM bom;
    BOMVersion bVersion;
    ;

    while select
            BomId, ItemId
            from bom
            where bom.BOMId == _bomid
          join
            ItemId, Active
            from bVersion
            where bom.itemId == bVersion.itemId
             {
              this.BOMId = bom.BOMId;
              this.ItemId = bom.ItemId;

            if(bVersion.Active == NoYes::Yes)
            this.allBomItems(??);
            //what can be inserted inside?

             }
    }

  • Sohaib Cheema Profile Picture
    47,829 User Group Leader on at
    RE: how to find the sub-BOM?

    1) Sub-bom are NOT saved in any separate table.

    2) ALL BOM ans Sub-BOM are saved in table called BOM

    3) how we can know about sub-bom??? The Bom lines of a bom which are actually items of a bom, we need to check each of individual item of a bom, whethere  it has a bom.

    Lets suppose, we have an item called ITEM-001

    we check table BOM for ITEM-001 and we found BOM-001 for ITEM -001

    now we went into lines of BOM-001 and we found two items belonging to BOM-001 lets say ITEM-001-1 and ITEM-001-2

    Now to know about sub bom, we need to check individual bom items ( ITEM-001-1 and ITEM-001-2) whether  any of those have a bom?? if yes we will go again into bom table to find that sub-bom

    it is an iterative/repeating process

  • Community Member Profile Picture
    on at
    RE: how to find the sub-BOM?

    Ok, I have no idea how to get them.

    For testing purpose I wrote job to find out, if itemId's, with Active field set to yes, appears in table BOM, where I have all the informations I need.

    BOMVersion bVer;
        BOM bom;
        ;
    
    
        while
            select
              ItemId, BOMId
              from bVer
              where  bVer.Active == NoYes::Yes
            join
              ItemId, BOMId
              from bom
              where bVer.ItemId == bom.ItemId
        {
                  info(bVer.ItemId + " . " + bVer.BOMId +
                       " || " + bom.ItemId + " . " + bom.BOMId);
        }

    many rows in BomVersion table with Active set to yes have a few other equivalents in BOM, but I have no idea how to find out which one in a sub-bom.

  • Community Member Profile Picture
    on at
    RE: how to find the sub-BOM?

    I have noticed that, when ItemId have have checked active field, its bom name contains it.

    Like itemId = 01234, BomId = BOM-01234-03 and BomId = BOM-01234-01. That is a trail, but both are different.

    What is more, rows where AlternativeBOMAS is set to true have only one BOMId matched to one ItemId, ended by -00, like

    itemid = 01234, BOMId = BOM-01234-00

    itemid = 09876, BOMId = BOM-09876-00

  • Sohaib Cheema Profile Picture
    47,829 User Group Leader on at
    RE: how to find the sub-BOM?

    yes one item can have many bom's.

    but all of those will be different BOMS with respect to different configuration of same item

    if multiple BOM's will be exactly same, for same item, only one of those will be active

  • Community Member Profile Picture
    on at
    RE: how to find the sub-BOM?

    One ItemId can Be assigned to menny BOMId's, so having only itemId it seems to be impossible to get one particular BOMId. So getting it by just:
     

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

    Will not work correctly I think.

    How to get the "main" one? Is it "armed" in some special flag or something?

  • Sohaib Cheema Profile Picture
    47,829 User Group Leader on at
    RE: how to find the sub-BOM?

    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.

  • Community Member Profile Picture
    on at
    RE: how to find the sub-BOM?

    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
    47,829 User Group Leader on at
    RE: how to find the sub-BOM?

    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
    RE: how to find the sub-BOM?

    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.

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Syed Haris Shah Profile Picture

Syed Haris Shah 9

#2
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#2
Community Member Profile Picture

Community Member 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans