GetItemRepeatConfig removes child items that are used multiple times. How to fix?
Hi community,
I use a classical "GetItemRepeatConfig" query to get a Part BOM over multiple levels.
id="xyz";
Item partItem = inn.newItem("Part","GetItemRepeatConfig");
partItem.setAttribute("select","id,classification,keyed_name,item_number");
partItem.setID(id); // <- target Part
Item bomItem = partItem.createRelationship("Part BOM","get");
bomItem.setAttribute("select","related_id(keyed_name),sort_order");
bomItem.setAttribute("repeatProp","related_id");
bomItem.setAttribute("repeatTimes","10");
partItem = partItem.apply();
When taking a look at the AML result, I discovered that Parts that are used on multiple levels inside a BOM (e.g. common items like screws) are not returned as complete items. The full related item is available only ONCE inside the AML result, but not for every BOM position that use that Part.
Here is how the result looks like:
The image shows three relationship BOM positions. Position 1 and 3 contain the full Part <Item> for the "related_id". Position 2 does not contain the "Item" cause it appeared already present in a previous position.
Problem: Without the date of the related_id/Item, I am not able to render the AML data. In my current use case I want to restructure the AML result in a way that it will also include depth/level of each BOM position. This basically works well, but as soon a duplicate entry appears, the data for the child item is missing:
Here is the current result that I get. I used a placeholder "Data missing" each time the related item is missing:
I discovered that this one is actually a know bug/behavior since over 10 years:
https://community.aras.com/f/archive/2097/developers-forum---getitemrepeatconfig-fix
The solution in the post is to not use GetItemRepeatConfig, but to manually create a query that includes all BOM levels.
Sure, this solution will work. But after 10 years, is this really the solution of choice? My AML query shall also contain other relationships, which would make the query even bigger when we hardcode any level manually.
Does anyone now a better solution for this one or how to modify the GetItemRepeatConfig query so it returns all data?
Thanks for any help!
Angela
I was also in a similar situation to expand the related items but couldn't able to make it using GetItemRepeatConfig when the item repeated in the BOM. I end up writing a SQL stored procedure to get the max level of a BOM and constructed an AML query to fetch the result.
Would like to hear from ARAS if there is any better solution for this issue or status of the bug.
SQL Query
CREATE PROCEDURE [getBOMLevels] @source_id NVARCHAR(MAX)
AS
BEGIN
WITH RecursiveBOM(SOURCE_ID, RELATED_ID, indent_level) AS
(
SELECT pb.SOURCE_ID, pb.RELATED_ID, 0 FROM innovator.PART_BOM pb WHERE SOURCE_ID = @source_id
UNION ALL
SELECT pb1.SOURCE_ID, pb1.RELATED_ID, indent_level +1 FROM innovator.PART_BOM pb1
INNER JOIN RecursiveBOM rb ON rb.related_id = pb1.SOURCE_ID
)
SELECT MAX(indent_level) AS BOM_Level FROM RecursiveBOM rb
ENDUsing this, I constructed the loop of BOM structure AML query.