Hi JD,
It would be posible but it´s a bit tricky
First you have to prepare a
CSV file
with all available bundle articles. For each bundle article you need one line.
The first column is the bundle article number and the second column ist the count how many articles the bundle article contains. The next colums are the containing article numbers followed by the quantity and so on.
For example:
item,count,artnr1,qty1,artnr2,qty2,artnr3,qty2,...
B101,3,X300,1,X400,2,X500,3,...
To extent the current read text file for the containing bundle articles you need the
GroupOut Heater
. With this you just make as many line copies you need for the bundle article. The count are read with the help of the
String Replace Heater
from the bundle article
CSV file
.
Now you need a little script (see below) and the help if the
.NET Script Heater
to get dynamically the bundle article and the quantity or in case no bundle article the original values from the READ side.
Sounds quit strange but I guess you are able to understand the attached example I’ve made for you.
Important: Please take care about the input parameter sequence!
C# .Net Script to extend the bundle articles
// you may change here the bundle file name and the delimiter
string bundlefile = "bundles.txt";
char [] delimiter = { ',' };
public object DoWork()
{
if (InValues.Length < 2)
throw new Exception("min. 2 input parameter expected!");
// read all lines from the bundle file
string [] lines = File.ReadAllLines(bundlefile);
// get current group out position (AutoID Heater)
int pos = (int)InValues[0].GetInt();
// get current item
string item = (string)InValues[1].GetString();
// in case a third parameter is valid get the quantity
int qty = -1;
if (InValues.Length > 2)
qty = (int)InValues[2].GetInt();
// loop over all lines an search for a bundle article
foreach (string line in lines)
{
// split the line and compare the item number
string [] columns = line.Split(delimiter);
if (item.CompareTo(columns[0]) == 0)
{
// bundle article found
if (qty < 0)
return columns[pos * 2];
else
return Convert.ToInt32(columns[1 + pos * 2]) * qty;
}
}
// in case no bundle article return the original values
if (qty < 0)
return InValues[1].GetValue();
else
return InValues[2].GetValue();
}