Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

Unable to link Sales Header Archive and Sales Line Archive

Posted on by 60

Hi team, 

I am trying to create a new document print on an Archive sales order, trying to link with the sales order archive header, and  Line getting the below error. Pls guide how I can solve this issue 

pastedimage1666852556864v1.png

refer the code 

================================

report 60120 Salesorderarchive
{
Caption = 'SalesOrder Archive';
UsageCategory = ReportsAndAnalysis;
ApplicationArea = All;

dataset
{
dataitem("Sales H Archive"; "Sales Header Archive")
{
PrintOnlyIfDetail = true;
column(Hno; "Sales H Archive"."No.") { }
column(Hdate; "Sales H Archive"."Order Date") { }
column(Hcustomer; "Sales H Archive"."Sell-to Customer No.") { }
column(HCustname; "Sales H Archive"."Sell-to Customer Name") { }
column(HSPeron; "Sales H Archive"."Salesperson Code") { }
column(HDocType; "Sales H Archive"."Document Type") { }
column(HVersion_No; "Sales H Archive"."Version No.") { }

// column(Sales_Header_Archive_Document_Type; "Document Type")
// column(Sales_Header_Archive_No_; "No."){}


}
// Archive Line item // -- Start

dataitem("Sales Line Archive"; "Sales Line Archive") // "Sales Line Archive"; "Sales Line Archive"
{

DataItemLink = "Document Type" = FIELD("Document Type"), "Document No." = FIELD("No.");
DataItemLinkReference = "Sales Header Archive";
DataItemTableView = SORTING("Document Type", "Document No.", "Line No.");

column(Alineno; "Sales L Archive"."No.") { }
column(ALinedocno; "Sales L Archive"."Document No.") { }
column(AlinedocType; "Sales L Archive"."Document Type") { }
column(Alinedesciption; "Sales L Archive".Description) { }
column(ALineUnitofMeasure; "Sales L Archive"."Unit of Measure") { }
column(Quantity_SalesLine; "Sales L Archive".Quantity) { }
column(ALineUnitPrice; "Sales L Archive"."Unit Price") { }
column(AlLineDiscountAmt; "Sales L Archive"."Line Discount Amount") { }
column(TotalAmount; TotalAmount) { }
column(ALineVATAmount; "Amount Including VAT" - Amount) { }
column(AlineAmount_SalesLine; "Sales L Archive".Amount) { }
column(AllineAmountIncludingVAT_SalesLine; "Sales L Archive"."Amount Including VAT") { }
column(CI; CI) { }

trigger OnAfterGetRecord()
begin

CI += 1;
TotalAmount := (("Sales L Archive"."Unit Price") * ("Sales L Archive".Quantity)) - "Sales L Archive"."Line Discount Amount";
TotalAmount += "Sales L Archive"."Amount Including VAT";
RepCheck.InitTextVariable;
RepCheck.FormatNoText(NoText, TotalAmount, "Sales H Archive"."Currency Code");
AmountInWords := NoText[1];
end;

trigger OnPreDataItem()
begin
TotalAmount := 0;
CI := 0;
end;

} // Sales Line End


}

requestpage
{
layout { }

actions { }

}

// rendering
// {
// layout(LayoutName)
// {
// Type = RDLC;
// LayoutFile = 'mylayout.rdl';
// }
// }

var
myInt: Integer;
AmountInWords: Text;
RepCheck: Report "Check";
TotalAmount: Decimal;
NoText: array[2] of Text;
CI: Integer;
}

Categories:
  • Verified answer
    YUN ZHU Profile Picture
    YUN ZHU 73,565 Super User 2024 Season 2 on at
    RE: Unable to link Sales Header Archive and Sales Line Archive

    Hi, It looks like there is something wrong with the structure and variable names.
    I modified it slightly, but haven't debugged it.

    report 50111 Salesorderarchive
    {
        Caption = 'SalesOrder Archive';
        UsageCategory = ReportsAndAnalysis;
        ApplicationArea = All;
    
        dataset
        {
            dataitem("Sales H Archive"; "Sales Header Archive")
            {
                PrintOnlyIfDetail = true;
                column(Hno; "Sales H Archive"."No.") { }
                column(Hdate; "Sales H Archive"."Order Date") { }
                column(Hcustomer; "Sales H Archive"."Sell-to Customer No.") { }
                column(HCustname; "Sales H Archive"."Sell-to Customer Name") { }
                column(HSPeron; "Sales H Archive"."Salesperson Code") { }
                column(HDocType; "Sales H Archive"."Document Type") { }
                column(HVersion_No; "Sales H Archive"."Version No.") { }
    
                // column(Sales_Header_Archive_Document_Type; "Document Type")
                // column(Sales_Header_Archive_No_; "No."){}
    
    
    
                // Archive Line item // -- Start
    
                dataitem("Sales L Archive"; "Sales Line Archive") // "Sales Line Archive"; "Sales Line Archive"
                {
    
                    DataItemLink = "Document Type" = FIELD("Document Type"), "Document No." = FIELD("No.");
                    DataItemLinkReference = "Sales H Archive";
                    DataItemTableView = SORTING("Document Type", "Document No.", "Line No.");
    
                    column(Alineno; "Sales L Archive"."No.") { }
                    column(ALinedocno; "Sales L Archive"."Document No.") { }
                    column(AlinedocType; "Sales L Archive"."Document Type") { }
                    column(Alinedesciption; "Sales L Archive".Description) { }
                    column(ALineUnitofMeasure; "Sales L Archive"."Unit of Measure") { }
                    column(Quantity_SalesLine; "Sales L Archive".Quantity) { }
                    column(ALineUnitPrice; "Sales L Archive"."Unit Price") { }
                    column(AlLineDiscountAmt; "Sales L Archive"."Line Discount Amount") { }
                    column(TotalAmount; TotalAmount) { }
                    column(ALineVATAmount; "Amount Including VAT" - Amount) { }
                    column(AlineAmount_SalesLine; "Sales L Archive".Amount) { }
                    column(AllineAmountIncludingVAT_SalesLine; "Sales L Archive"."Amount Including VAT") { }
                    column(CI; CI) { }
    
                    trigger OnAfterGetRecord()
                    begin
    
                        CI  = 1;
                        TotalAmount := (("Sales L Archive"."Unit Price") * ("Sales L Archive".Quantity)) - "Sales L Archive"."Line Discount Amount";
                        TotalAmount  = "Sales L Archive"."Amount Including VAT";
                        RepCheck.InitTextVariable;
                        RepCheck.FormatNoText(NoText, TotalAmount, "Sales H Archive"."Currency Code");
                        AmountInWords := NoText[1];
                    end;
    
                    trigger OnPreDataItem()
                    begin
                        TotalAmount := 0;
                        CI := 0;
                    end;
    
                } // Sales Line End
            }
    
    
        }
    
        requestpage
        {
            layout { }
    
            actions { }
    
        }
    
        // rendering
        // {
        // layout(LayoutName)
        // {
        // Type = RDLC;
        // LayoutFile = 'mylayout.rdl';
        // }
        // }
    
        var
            myInt: Integer;
            AmountInWords: Text;
            RepCheck: Report "Check";
            TotalAmount: Decimal;
            NoText: array[2] of Text;
            CI: Integer;
    }

    Hope this helps.

    Thanks.

    ZHU

  • Verified answer
    DAnny3211 Profile Picture
    DAnny3211 9,272 Super User 2024 Season 1 on at
    RE: Unable to link Sales Header Archive and Sales Line Archive

    hi

    try setting the archive row properties like this

    DataItemLink = "Document No.=FIELD(No.),Doc. No. Occurrence=FIELD(Doc. No. Occurrence),Version No.=FIELD(Version No.);

    DataItemLinkReference = "Sales H Archive";

    DataItemTableView = SORTING("Document Type", "Document No.", "Line No.");

    if my answer was helpful, please check it

    DAniele

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans