you might be able to do it in a shared array, or a pair as I don't know if Crystal goes beyond 1 dimension...I don't use arrays much in Crystal as I can't 'see' the data.
What I will often do for a case like this is to create a string variable and delimit it. Maybe use pipes for the part_number and carats for the quantity ie |part1^quant1|part2^quant2|. This you can build on the fly, as you are adding to a string if the part doesn't exist and updating it if it does.
for finding if a part exists: instr(PartCount, "|"+{table.part}) you might need to trim the part number so that it matches the string, all depends on how you build the string.
variables are pretty easy, in this case, you will never be displaying the variable, just a part of it, and you never be resetting so there is just increment and partial display:
increment is probably harder, something like:
shared stringvar PartCount;
local numbervar iIndex := instr(PartCount, "|"+{table.partNumber})
local numbervar carat;
local numbervar inv;
if iIndex = 0 then(
PartCount := PartCount + "|" + {table.partNumber}+"^"+totext(inventoryAmount)+"|";
inv:=(inventoryAmount)
)
else(
carat := instr(iIndex, PartCount, "^");
inv :=val(mid(PartCount, carat +1, instr(iIndex+1, PartCount, "|")-1));
inv := inv+(inventoryAmount);
PartCount := Left(PartCount, carat) + totext(inv) + mid(PartCount,instr(iIndex+1, PartCount, "|"))
);
inv
displaying is just parsing the string correctly(and you might not need to do it as inv would be the running total, you can modify the first half of the if to set a value to inv then at the end display inv...mods in red
this should work, at least it is good start.
HTH