Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello, i'm having a problem to calculate the quantities of products that are in a hierarchy structure. There are several levels of subproducts, and its not a balanced tree, so the last levels are not always the same. I have used the Hierarchy function to achieve this structure, here is the code:
Product:
Hierarchy ( ID_SubProduct,ID_Product, Level,,Level, Treeview,,Depth)
LOAD
Quantity_MP,
Quantity,
ID_Product,
ID_SubProduct,
ID_SubProduct as Level
Resident STA03_TEMP;
The structure looks like this:
Level 1 | Level 2 | the Level 3 | Level 4 | Level 5 | Level 6 | Quantity | Quantity MP |
---|---|---|---|---|---|---|---|
Product A | MP4 | - | - | - | - | - | 5 |
Product A | SubProduct 2 | MP3 | - | - | - | - | 2 |
Product A | SubProduct 2 | - | - | - | - | 2 | - |
Product A | SubProduct 1 | SubProduct 4 | MP 2 | - | - | - | 10 |
Product A | SubProduct 1 | SubProduct 4 | MP 1 | - | - | - | 2 |
Product A | SubProduct 1 | SubProduct 4 | - | - | - | 1 | - |
Product A | SubProduct 1 | - | - | - | - | 2 | - |
Product A | - | - | - | - | - | - | - |
What i need to do is to multiply the Quantity of the every subproduct level with the Quantities MP of the last levels. For example, the MP2 quantity should be:
The MP1 Quantity should be:
The MP4 Quantity should be:
Once i have the correct results of the Quantities of the MP Products, i need to store the new value on the Quantity MP field so i can use that values later on. My intention is to generate those values in the script then.
If anyone can help me with this ill be truly grateful.
Thank you.
PS: Sorry for my english, if there is a part that is not very understandable feel free to tell me so i can try to explain me better.
Any ideas?
Hey man, i ve the same problem.... Its very dificult.