class BOMExplode
{
date _date = mkDate(22,09,2019);
void itemExplode(ItemId _ItemId, int _level = 0, BOMQty _bomQty = 1)
{
BOM bomTable;
BOMVersion bomVersion;
boolean enable;
InventTestVariableId cvQualityGroupId;
Level level = _level;
while select bomVersion
where bomVersion.ItemId == _itemid
&& bomVersion.Active
&& bomVersion.FromDate <= _date//DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone())
&& (!bomVersion.ToDate || bomVersion.ToDate >= _date)//DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()))
{
if (bomVersion.RecId)
{
While select bomTable
where bomTable.BOMId == bomVersion.BOMId
{
Info(strFmt("Parent Item: %1 Part Number: %2 Quantity: %3, Level: %4 ",bomVersion.ItemId,bomTable.ItemId, bomTable.bomQty,level));
if (this.hasChild(bomTable.ItemId))
{
this.itemExplode(bomTable.ItemId, level + 1, bomTable.BOMQty);
}
}
}
}
}
boolean hasChild(ItemId _itemId)
{
BOMVersion bomVersion;
boolean ret = false;
select firstonly bomVersion
where bomVersion.ItemId == _itemid
&& bomVersion.Active
&& bomVersion.FromDate <= _date//DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone())
&& (!bomVersion.ToDate || bomVersion.ToDate >= _date);//DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()));
if (bomVersion.RecId)
{
ret = true ;
}
return ret;
}
public static void Main(Args args)
{
BOMExplode bomExplode = new BOMExplode();
bomExplode.itemExplode("A20HBA06B7");
}
}
{
date _date = mkDate(22,09,2019);
void itemExplode(ItemId _ItemId, int _level = 0, BOMQty _bomQty = 1)
{
BOM bomTable;
BOMVersion bomVersion;
boolean enable;
InventTestVariableId cvQualityGroupId;
Level level = _level;
while select bomVersion
where bomVersion.ItemId == _itemid
&& bomVersion.Active
&& bomVersion.FromDate <= _date//DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone())
&& (!bomVersion.ToDate || bomVersion.ToDate >= _date)//DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()))
{
if (bomVersion.RecId)
{
While select bomTable
where bomTable.BOMId == bomVersion.BOMId
{
Info(strFmt("Parent Item: %1 Part Number: %2 Quantity: %3, Level: %4 ",bomVersion.ItemId,bomTable.ItemId, bomTable.bomQty,level));
if (this.hasChild(bomTable.ItemId))
{
this.itemExplode(bomTable.ItemId, level + 1, bomTable.BOMQty);
}
}
}
}
}
boolean hasChild(ItemId _itemId)
{
BOMVersion bomVersion;
boolean ret = false;
select firstonly bomVersion
where bomVersion.ItemId == _itemid
&& bomVersion.Active
&& bomVersion.FromDate <= _date//DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone())
&& (!bomVersion.ToDate || bomVersion.ToDate >= _date);//DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()));
if (bomVersion.RecId)
{
ret = true ;
}
return ret;
}
public static void Main(Args args)
{
BOMExplode bomExplode = new BOMExplode();
bomExplode.itemExplode("A20HBA06B7");
}
}