I would like to group items of the same names in a sales order and consolidate the price amount in a report.
For eg. Sales Order
Item A 100usd
Item A 100usd
Item A 100usd
Item A 100usd
On the report I want to sum up the total price of all items and display Item A as one line: Item A 400usd
I know I should be using for loop and array to do this, however it doesnt seem to work.
//scan through all lines
for(i=1;...){
item[i]=getitemforline(i);
itemprice[i]=getitempriceforline(i);
}
//check current line one by one for any duplicates, and sum up itemprice if there is
for(k=1;...){
for(i=1;i<k;i++){
currentitem[k] = getitemforcurrentline(k);
currentitemprice[k] = getitempriceforcurrentline(k);
if(currentitem[k] == item[i]){
itemprice[i] = itemprice[i] + currentitemprice[k];
}
}
print(itemw[i]+itemprice[i]);
}
getitemforline()and other functions return? - nnnnnn