Totaling lines?

Hello.

How do I add up the number of rows in a raport? I’ll choose the “total field-coustomer number”?

sum of money can I get out of the total because it’s figures. But if I want to get the number of rows.

example. I want calculatet that this is 3 people.

Jane Andersson 75,522
Jim Petersen 4.555
andrew sharlton 10,154

3 101,015 (Example)

Define a variable, set it to 0 initially, and then add 1 to it OnAfterGetRecord.

There is another method (though I can’t see what advantage it has), where you define a variable, called Num (for example). OnAfterGetRecord, set Num := 1. In OnPreDataItem, use the following code:

CurrReport.CREATETOTALS(Num);

OR

Define Var = RecordCount (Integer)

In PreDataItemTrigger
RecordCount := Rec.COUNT;

In Footer Section for Totals add text box and lable for RecordCount.

[:)]

The problem with that is that it tells you how many records are in the table, not how many are displayed.

If the report is changed so that some records are not displayed (using CurrReport.SKIP, or CurrReport.SHOWOUTPUT(FALSE) ), the methods I explained can be tweaked to cater for that.

Hi Emil

Just create two variables for example Count as an integer second one is Total as Decimal

Now OnPreDataItem() write the below code

Count := 0;

Total:=0;

Now write the below code at OnAfterGetRecord()

Count := Count +1;

Total:=Total+(Amount field of your data item);

Now make customer no as your Request field;

Note This will work only if customer No field is primary key in that table.( example customer table…)

if you use other than customer table for example sales line table

then follow the below steps

1.Group your report By customer number

2.Now place Count := 0; ,Total:=0; OnPreSection() of header

3.Now place below code at Count := Count +1; Sales Line OnPreSection() of group header

4.Now place at Total:=Total+(Amount field of your data item); OnPreSection() of Sales line Body

5.Make Sell to cuatomer no as your request field

6.place Customer No at Header,Amount at body,Count and Total at footer

7.Now your report will be

No Amount (Header)

0001 (Group Header)

100 (Body)

200 { Body}

0002 (Group Header)

300 { Body}

400 { Body}


2 1000 {Footer}

Do not use count as your variable name

Thanks

Jerome Marshal.J

That’s absolutley correct but the count should be correct if you apply filtering and selection before you process the data item.

Jerome,

I would only ever recommend manipulating data in Data Items and never in the Print Sections because that’s the way the standard objects work and that’s the way I learnt to program Navision.

Strange isn’t it…

Hi

Can u help me to count the Lines of item. One Record has two lines so in a page i need to show only 3 tiems of records may hold 3 to 6 lines.

Incase i have 4 items to show fourth should go to secong page.

Example

Item1 Name Desc 1 Amt

Desc2 remark

Item 2 Name Desc 1 Amt

Desc2 remark

So in a page im allowed to show 3 items. I try using your above codes but it showing Error as “The return value should be used for this function” as soon as i declared count = 0 on Header in Onpresection().

Hi Jammy

how many sections you are using in your report and in which section your printing the records

Thanks

Jerome Marshal. J

Jerome,

Can u explain abt the sections, Im new to NAV. If im not wrong im using 2 sections.

Printing the records in Detail section.

Ok jammy

At least i what are the tables you are using then only to generate the report the only i can able

Thanks

Jerome Marshal

Two tables are used to generate the report.

SalesInvoiceLine Table is used to get the data

And SalesHeader is Used to filter the doc Type

Hi jammy

you are trying to print all the invoice lines, if a invoice have 6 lines then first 3 lines have to be printed in one page and next 3 lines have to moved to next page this is your requirement am i correct ?

No Jerome,

Printing the Item from Line but in a page i should print only 3 items. Each Item wil have 2 line of Insertsion.

ITEM1 name Des1 amt

desc 2 remrk

ITEM2 name Des1 amt

ITEM3 name Des1 amt

desc 2 remrk

so, in a page 3 items and 5 lines should show. so in a page Max 6 lines and mininum in 3 lines can b displayed. only 3 items in a page.