Trying to setup logic for Bill of Material (BOM) for a system

Hi Team

I am trying to setup logic for typical BOM data. I am not sure if this forum is appropriate to ask such elaborate logic.

Example Data

I have two Types of BOM Nested & Carton 1 of 2 (Maintained in 2 columns)

and a column to indicate if it is a Parent for the component -Yes/No

Loop Start

IF "is it a Parent=Yes and Ctn 1 of 2 =‘Yes

create the Parent ID BOM by joining the Item (first item)+ "CTN’ constant

Write the BOM Component records (3 Records) - Each Item in the list which has Ctn 1 of 2 = Yes

END Loop When Is it a Parent =No and Ctn 1 of 2 =No

IF "is it a Parent=Yes and Nested ='Yes

create the Parent ID BOM by joining the Item + Sizes (“XS”,“S”,“M”,“L”,“XL”) - Additional Requirement is create Parent Id only if the sum of the component qtys for a given size >0

Write the BOM component records (4 Records)

END Loop When Is it a Parent =No and Nested =No

Expected OUTPUT

Thanks for help in advance

Sunil