IF Item.FINDSET THEN REPEAT IF NOT TempTable.GET(Item.Type, Item.Location) THEN BEGIN TempTable.CodeField1 := Item.Type; //KEY TempTable.CodeField2 := Item.Location; //KEY TempTable.INSERT END; TempTable.DecimalField1 += Item.GetLocationAmount(); ... TempTable.DecimalField15 += Item.GetLocationQuantity(); TempTable.MODIFY; UNTIL (Item.NEXT = 0);
TempTable.SETCURRENTKEY(DecimalField1); IF TempTable.FINDSET THEN REPEAT ExcelBuffer.AddCell(RowNo, ColNo, TempTable.DecimalField1); .. ExcelBuffer.AddCell(RowNo, ColNo+14, TempTable.DecimalField15); RowNo +=1; UNTIL (TempTable.NEXT = 0);
Answers
I think the better solution is temporary tables.
With XML will be slowest and more difficult to sort.
With .Net structures sort and filter will need more code.
I use temporary tables with a little twist. My keys are Text(250).
In your example my key should be
TempTable.SETRANGE(TextKey1,
'##!' + Item.Type + '!##!' + Item.Location + '!##');
IF NOT TempTable.FINDFIRST THEN
TempTable.TextKey1 :=
'##!' + Item.Type + '!##!' + Item.Location + '!##';
If the order should be Location,Type I change the order when writting TextKey1.
To be a little more organized and readable I use a private function to get this key, like this:
LOCAL GetFilter<YourMeaningText> (Record Item) : Text(250)
MyFilter := '##!' ;
IF Item.Type = '' THEN
MyFilter += 'null'
ELSE
MyFilter += Item.Type;
MyFilter += '!##!';
....
EXIT(MyFilter);
TempTable.SETRANGE(TextKey1, GetFilter<YourMeaningText>(Item));
IF NOT TempTable.FINDFIRST THEN
TempTable.TextKey1 := , GetFilter<YourMeaningText>(Item);
Regards,
parm
Hi, thank you.
This answer give me some ideas to increase transparency of my "Buffers" code.