Skip to main content

Notifications

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

Why are integer tables used in reports for BLOB fields?

Posted on by 115

Hello everyone,

can someone explain to me why standard reports use integer tables to display the text from BLOB fields. Such as the work description in sales quotes:

report 1304 "Standard Sales - Quote"
{
    ...

    dataset
    {
        dataitem(Header; "Sales Header")
        {
            ...

            dataitem(WorkDescriptionLines; "Integer")
            {
                DataItemTableView = SORTING(Number) WHERE(Number = FILTER(1 .. 99999));
                column(WorkDescriptionLineNumber; Number)
                {
                }
                column(WorkDescriptionLine; WorkDescriptionLine)
                {
                }

                trigger OnAfterGetRecord()
                begin
                    if WorkDescriptionInstream.EOS then
                        CurrReport.Break();
                    WorkDescriptionInstream.ReadText(WorkDescriptionLine);
                end;

                trigger OnPostDataItem()
                begin
                    Clear(WorkDescriptionInstream)
                end;

                trigger OnPreDataItem()
                begin
                    if not ShowWorkDescription then
                        CurrReport.Break();

                    Header."Work Description".CreateInStream(WorkDescriptionInstream, TEXTENCODING::UTF8);
                end;
            }

            ...

            trigger OnAfterGetRecord()
            begin
                ...

                CalcFields("Work Description");
                ShowWorkDescription := "Work Description".HasValue;

                ...
            end;
        }
    }

    ...

    var
        WorkDescriptionInstream: InStream;
        WorkDescriptionLine: Text;
        ShowWorkDescription: Boolean;
    
    ...
}

Why not just use the Sales Header's GetWorkDescription function, like the card page does:

report 1304 "Standard Sales - Quote"
{
    ...

    dataset
    {
        dataitem(Header; "Sales Header")
        {
            ...

            column(WorkDescription; Header.GetWorkDescription())
            {
            }

            ...
        }
    }

    ...
}

I would be interested to know what advantages you (or Microsoft) see in the first variant. Or what disadvantages I overlook in my proposal.

Thank you for your help and best regards
Nico

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 72,941 Super User 2024 Season 2 on at
    RE: Why are integer tables used in reports for BLOB fields?

    Hi, I agree with Rahul, there is nothing wrong with the second method.

    And the following is a brief introduction about Integer Dataitems, hoping to give some hints.

    http://harikiran-in-nav.blogspot.com/2020/01/why-and-when-do-we-need-to-use-integer.html

    Thanks

    ZHU

  • Verified answer
    NAV_with_Narang Profile Picture
    NAV_with_Narang 2,234 Super User 2024 Season 1 on at
    RE: Why are integer tables used in reports for BLOB fields?

    If the method you described is giving you the desired result then go for it. There can be multiple ways to reach a destination, with each having it's own pros & cons. To the best of my understanding, not just this instance, but Microsoft uses a lot of Integer in a lot of reports. It can be due to a handful of reasons:

    1. Probably a report is carried forward/migrated from the earliest of NAV days - I am talking about 1990's. Yes such reports exist, in which the design of the overall report has not changed but minor tweaks have been added. Probably in those early days of C/AL the best way to retrieve such records was only through the Integer dataitem, so it has been used till date. You ask why? - You don't change the code until it works!

    2. Many a times, Microsoft keeps in mind efficiency to the top most. In your code, the result will appear 2 seconds later than what Microsoft has written, probably not! But largely, the purpose of MS using integers is to loop through dataitems really quickly as unlike other dataitems, integers don't have any additional columns to deal with when reading a table, it just skims fast giving the report a "feel" of iterating through a table record without actually doing so

    Other community members may also chime in with their views, however the real reason behind the design may stay mystery

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 229,918 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans