Skip to main content

Notifications

Announcements

No record found.

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

Why are integer tables used in reports for BLOB fields?

(0) ShareShare
ReportReport
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 74,115 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,236 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

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 Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans