I have a input file which has 3 levels ie shipment, package and item level. I want output to be mapped as shipment, item and package level. I have created a temporary variables on the input side following the same hierarchy of output which is Shipment, item and package.
I have created variables i,j,k for input side and t_s, t_p, t_i for corresponding temporary hierarchy. I want to print the package level under item level while checking if the item is same throught the input. If the item is same then I want to print the corresponding package level. If the item is not same ie unique then I want the print the package level and continue with my iterations.
Let us consider the input as
SHIPMENT, Shipment1,
PACKAGE, package1,
ITEM,Item1,
PACKAGE, package2,
ITEM,Item1,
PACKAGE, package3,
ITEM,Item1,
PACKAGE, package4,
ITEM,Item2,
PACKAGE, package5,
ITEM,Item1.
The desired output is
SHIPMENT, shipment1,
ITEM, Item1,
PACKAGE, package1,
package,package2,
PACKAGE,package3,
PACKAGE,package5,
ITEM,Item2,
PACKAGE,Package4.
i = 1;
temp_ship = 1;
i = 1;
while i <= count($Shipment[*]) do
begin
j = 1;
while j <= count($Package[i][*]) do
begin
k = 1;
while k <= count($Item[i][j][*]) do
begin
current_item = $Item[i][j][k].#Item_No;
found = 0;
p = 1;
while p <= count($Item:2[temp_ship][*]) do
begin
if $Item:2[temp_ship][p].#Item_No:2 = current_item then
begin
found = 1;
end
p = p + 1;
end
if found = 0 then
begin
temp_item = count($Item:2[temp_ship][*]) + 1;
$Item:2[temp_ship][temp_item].#Item_No:2 = current_item;
m = 1;
while m <= count($Shipment[*]) do
begin
n = 1;
while n <= count($Package[m][*]) do
begin
o = 1;
while o <= count($Item[m][n][*]) do
begin
if $Item[m][n][o].#Item_No = current_item then
begin
temp_package = count($Package:2[temp_ship][temp_order][*]) + 1;
$Package:2[temp_ship][temp_order][temp_package].#Package_No:2 = $Package[m][n].#Package_No;
end
o = o + 1;
end
n = n + 1;
end
m = m + 1;
end
end
k = k + 1;
end
j = j + 1;
end
i = i + 1;
end
I’ve also referred to the following question
IBM Sterling map editor: is there a way to sort OID in 204 EDI