Friday, October 1, 2021

Develope Report Extension for Business Central 18+ and setup new RDL File

Dear friends,

Create new report extension and setup the default RDL Layout as default build-in


reportextension 65879 MyExtension65879 extends 10121
{
    RDLCLayout = '.\Layouts\10121_PurchaseInvoice_Updated.rdl';


    dataset
    {
        add("Purch. Inv. Header")
        {
            column(DivisionBreakdown_gTxtArr; DivisionBreakdown_gTxtArr[1])
            {

            }
            column(DivisionBreakdown_gTxtArr2; DivisionBreakdown_gTxtArr[2])
            {

            }
            column(DivisionBreakdown_gTxtArr3; DivisionBreakdown_gTxtArr[3])
            {

            }
            column(DivisionBreakdown_gTxtArr4; DivisionBreakdown_gTxtArr[4])
            {

            }
            column(DivisionBreakdown_gTxtArr5; DivisionBreakdown_gTxtArr[5])
            {

            }
            column(DivisionBreakdownVal_gDecArr; DivisionBreakdownVal_gDecArr[1])
            {

            }
            column(DivisionBreakdownVal_gDecArr2; DivisionBreakdownVal_gDecArr[2])
            {

            }
            column(DivisionBreakdownVal_gDecArr3; DivisionBreakdownVal_gDecArr[3])
            {

            }
            column(DivisionBreakdownVal_gDecArr4; DivisionBreakdownVal_gDecArr[4])
            {

            }
            column(DivisionBreakdownVal_gDecArr5; DivisionBreakdownVal_gDecArr[5])
            {

            }
            column(CurrSign_gTxt; CurrSign_gTxt)
            {

            }


        }
        modify("Purch. Inv. Header")
        {
            trigger OnAfterAfterGetRecord()
            var
                i_Int: Integer;
                PurchInvHeader_lRecTmp: Record "Purch. Inv. Header" temporary;
                PurchInvLine_lRec: Record "Purch. Inv. Line";
                Currency_lRec: Record Currency;
                GLSetup_lRec: Record "General Ledger Setup";
                Exit_lBln: Boolean;
            begin
                Clear(GLSetup_lRec);
                Clear(Currency_lRec);
                Clear(CurrSign_gTxt);
                if Currency_lRec.get("Purch. Inv. Header"."Currency Code"then
                    CurrSign_gTxt := Currency_lRec.Symbol
                else begin
                    Clear(GLSetup_lRec);
                    GLSetup_lRec.Get();
                    CurrSign_gTxt := GLSetup_lRec."Local Currency Symbol";
                end;

                If NOT PurchInvHeader_lRecTmp.IsTemporary then
                    Error('Variable PurchInvHeader_lRecTmp must be temp');

                Clear(PurchInvHeader_lRecTmp);
                Clear(PurchInvLine_lRec);
                Clear(DivisionBreakdown_gTxtArr);
                Clear(DivisionBreakdownVal_gDecArr);
                Clear(i_Int);
                PurchInvLine_lRec.SetCurrentKey("Shortcut Dimension 1 Code");
                PurchInvLine_lRec.SetRange("Document No.", "Purch. Inv. Header"."No.");
                if PurchInvLine_lRec.FindSet() then begin
                    repeat
                        i_Int += 1;
                        if i_Int < 6 then begin
                            PurchInvHeader_lRecTmp.Reset();
                            PurchInvHeader_lRecTmp.SetRange("No.", PurchInvLine_lRec."Shortcut Dimension 1 Code");
                            if PurchInvHeader_lRecTmp.FindFirst() then begin
                                PurchInvHeader_lRecTmp."Currency Factor" += PurchInvLine_lRec.Amount + PurchInvLine_lRec."Inv. Discount Amount";
                                PurchInvHeader_lRecTmp.Modify();
                            end else begin
                                Clear(PurchInvHeader_lRecTmp);
                                PurchInvHeader_lRecTmp."No." := PurchInvLine_lRec."Shortcut Dimension 1 Code";
                                PurchInvHeader_lRecTmp.Insert();

                                PurchInvHeader_lRecTmp."Currency Factor" := PurchInvLine_lRec.Amount + PurchInvLine_lRec."Inv. Discount Amount";
                                PurchInvHeader_lRecTmp.Modify();
                            end;
                        end;
                    until PurchInvLine_lRec.Next() 0;
                end;

                Clear(i_Int);
                PurchInvHeader_lRecTmp.Reset();
                PurchInvHeader_lRecTmp.SetFilter("No.", '<>%1''');
                if PurchInvHeader_lRecTmp.FindSet() then begin
                    repeat
                        i_Int += 1;
                        if i_Int < 6 then begin
                            DivisionBreakdown_gTxtArr[i_Int] := PurchInvHeader_lRecTmp."No.";
                            DivisionBreakdownVal_gDecArr[i_Int] := PurchInvHeader_lRecTmp."Currency Factor";
                        end;
                    until PurchInvHeader_lRecTmp.Next() 0;
                end;

                Clear(i_Int);
                Exit_lBln := false;
                PurchInvHeader_lRecTmp.Reset();
                PurchInvHeader_lRecTmp.SetFilter("No.", '');
                if PurchInvHeader_lRecTmp.FindFirst() then begin
                    for i_Int := 1 to 5 do begin
                        if Exit_lBln then
                            break;

                        if DivisionBreakdown_gTxtArr[i_Int] = '' then begin
                            DivisionBreakdown_gTxtArr[i_Int] := 'BLANK';
                            DivisionBreakdownVal_gDecArr[i_Int] := PurchInvHeader_lRecTmp."Currency Factor";
                            Exit_lBln := true;
                        end;
                    end;
                end;
            end;
        }
        add("Purch. Inv. Line")
        {
            column(Shortcut_Dimension_1_Code; "Shortcut Dimension 1 Code")
            {

            }
            column(No_; GLAccNo_gCod)
            {

            }
            column(GLAccName_gTxt; GLAccName_gTxt)
            {

            }
        }
        modify("Purch. Inv. Line")
        {
            trigger OnAfterAfterGetRecord()
            var
                GLAcc_lRec: Record "G/L Account";
            begin
                Clear(GLAcc_lRec);
                Clear(GLAccName_gTxt);
                if "Purch. Inv. Line".Type = "Purch. Inv. Line".Type::"G/L Account" then begin
                    GLAccNo_gCod := "Purch. Inv. Line"."No.";
                    if GLAcc_lRec.Get("Purch. Inv. Line"."No."then
                        GLAccName_gTxt := GLAcc_lRec.Name;
                end;
            end;
        }
    }


    requestpage
    {

    }
    var
        DivisionBreakdown_gTxtArr: array[5of Text[50];
        DivisionBreakdownVal_gDecArr: array[5of Decimal;
        GLAccName_gTxt: Text;
        GLAccNo_gCod: Code[20];
        CurrSign_gTxt: Text;

}


in business central publish and extension and you can see the published layout in built-in list





Preview of  report - new field added in std repot


Thank you for reading.....
Keep Sharing...Keep Growing....

No comments:

Post a Comment