table 60114 SubTotalSales { DataClassification = ToBeClassified; Caption = 'sub'; TableType = Temporary; fields { field(60001; DocNum; Code[50]) { DataClassification = ToBeClassified; Caption = 'Code'; } field(60002; Group1; Integer) { DataClassification = ToBeClassified; Caption = 'Code'; } field(60000; Category; Text[200]) { Caption = 'Category;'; } field(60004; SubTotal; Decimal) { Caption = 'SubTotal'; Editable = false; } } keys { key(PK; DocNum, Group1) { Clustered = true; } }[img]https://us.v-cdn.net/5022383/uploads/editor/c5/k2mhqygzf5cw.png[/img]
page 50105 SalesSubTotalsPart { PageType = ListPart; ApplicationArea = All; Editable = false; UsageCategory = Administration; SourceTable = SubTotalSales; DeleteAllowed = false; InsertAllowed = false; layout { area(content) { repeater(Control2) { Caption = 'Sub'; ShowCaption = false; field(Doc; Rec.DocNum) { ApplicationArea = All; Width = 10; } field(Group1; Rec.Group1) { ApplicationArea = all; } field(Cat; Rec.Category) { ApplicationArea = all; Width = 10; } field(SubTotal; Rec.SubTotal) { ApplicationArea = all; } } } } procedure CalculateSubTotalProc(Var DocNum: Code[50])//called from sales order action var SalesLine: Record "Sales Line"; TotalAmount: Decimal; begin Rec.DeleteAll(); TotalAmount := 0; begin//insert SalesLine.Reset(); SalesLine.SetRange("Document Type", SalesLine."Document Type"::Quote); SalesLine.SetRange("Document No.", DocNum); SalesLine.SetRange(Type, SalesLine.Type::" "); if SalesLine.FindSet() then Rec.Init(); repeat Rec.DocNum := SalesLine."Document No."; Rec.Group1 := SalesLine.Group1; Rec.Category := SalesLine.Description; Rec.Insert(); until SalesLine.Next() = 0; end; begin Rec.Reset(); if Rec.FindSet() then repeat Clear(TotalAmount);// SalesLine.Reset(); SalesLine.SetRange("Document Type", SalesLine."Document Type"::Quote); SalesLine.SetRange("Document No.", Rec.DocNum); SalesLine.SetRange(Group1, Rec.Group1); if SalesLine.FindSet() then repeat TotalAmount := TotalAmount + SalesLine."Line Amount"; until SalesLine.Next() = 0; Rec.SubTotal := TotalAmount; Rec.Modify(); until Rec.Next() = 0; end; end;
Answers