Question

BomSearch in Customization , retrieving all PartMtl rows by MtlPart rather than PartNum/(Parent part) ?

  • 25 May 2021
  • 5 replies
  • 205 views

  • Anonymous
  • 0 replies

  Can I use the BomSearch object (or any other objects/adapters that will do it) to read all PartMtl rows by a MtlPart number?  I haven’t been able to find documentation that gets me quite there, not an existing method, and not sure it’s possible (a method of this using a where clause?).  I can see where I can read a Bom by it’s parent part of course.

  Ultimate end game:  A user enters text to search/retrieve all parts by part description containing that text.  Then we take those parts and find all instances of BOM’s they are in, what MFG part they belong to, kind of a ‘Where Used’ by part description.  So, I have to find all rows by the component part.  This is C# in a form customization.  Thanks much for any thoughts!


5 replies

Userlevel 1

You could create a BAQ with a parameter to get the data you want and then call it in your customization with the DynamicQueryAdapter. If not, I would give BomSearchAdapter a go (like GetRows or GetList)

Dragos

Userlevel 3

I agree with Dragos. I’d use a BAQ and then filter on the BAQ results.

You can load the BAQ results into a custom Adapter to use in the customisation. I’ve done similar things previously and it’s worked well. 

If you need any pointers/help on how to achieve the recommendation let me know and I’ll see what notes/instructions I can find.

Userlevel 3

If you only need to go one level, the BAQ would work well.  If you need to find BOMs where the material is used, then find BOMs that include the parent, then find BOMs that include that parent, you’ll want a recursive query.  Depends on if you are looking for the immediate parent or the ultimate finished good.  

Thanks Dragos/Tim!    Yes, if you have any pointers/help/examples/instructions to achieve this, it would be much appreciated.  If I can use GetRows on BomSearch, that’s all I need, so I’ll explore in the meantime too.  So you know where I’m at with it, a code snippet of what I’m working with below.  The listlookup not working on the BomSearch.   Thanks again.

 

 

            bool recordSelected;
            bool ParentRecordsSelected;
            string PartDesc;

              string Outfile = @"U:\PartSearch.csv";
              string OString = "ParentPartNum,ParentPartDesc,MtlPartNum,MtlPartDesc";
          using (System.IO.StreamWriter file = new System.IO.StreamWriter(@Outfile, false))
          {
                 file.WriteLine(OString);


            if (txtSearch1.Text != "")
            {
                string whereClause1 = "PartNum LIKE '%" + txtSearch1.Text + "%'";
                string ParentWhereClause1;
            //MessageBox.Show(whereClause);
                DataSet ds1 = SearchFunctions.listLookup(UD14Form, "PartAdapter", out recordSelected, false, whereClause1);
                MessageBox.Show("After lookup");
                if(recordSelected == true)
                {
                    MessageBox.Show("In recordSelected");

                    string x1;
                    foreach (DataRow rows1 in ds1.Tables[0].Rows)
                    {
                    MessageBox.Show("In ParentrecordSelected");
                        ParentWhereClause1 = "MtlPartNum = '" + rows1["PartNum"].ToString().Trim() + "'";
                        DataSet Pds1 = SearchFunctions.listLookup(UD14Form, "BomSearchAdapter", out ParentRecordsSelected, false, ParentWhereClause1);
                    MessageBox.Show("Past list lookup");

                        if (ParentRecordsSelected == true)
                        {
                            foreach (DataRow Parentrows1 in Pds1.Tables[0].Rows)
                            {
                                PartDesc = rows1["PartDescription"].ToString().Replace(",", "");
                                PartDesc = PartDesc.Replace("\n", "");
                                PartDesc = PartDesc.Replace("\r", "");
                                OString = "P: " + rows1["PartNum"].ToString().Trim() + "," + PartDesc + "," + Parentrows1["MtlPartNum"].ToString().Trim() + "," + PartDesc;
                            //MessageBox.Show(OString);
                            //MessageBox.Show("In file write");
                                 file.WriteLine(OString);
                            }

                        }

                    }

                }
            }

 

Thanks Fred, yeah one level is fine.  As if there ‘are’ multiple levels,  I don’t need to show it.  I would just show the immediate parent, and if that parent belongs to something else, well…  we don’t care here.

Reply