cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

whilereadingrecords and whileprintingrecords

Former Member
0 Likes
28,941

Hi All, I am trying to figured out the difference between while reading records and whileprintingrecords.

I created two formulas for running totals like this.Both are giving same result.

WhileReadingRecords;

numbervar x:=x+1;

WhileprintingRecords;

numbervar x:=x+1;

Please suggest what is the difference

Accepted Solutions (0)

Answers (4)

Answers (4)

abhilash_kumar
Active Contributor
0 Likes

Hi Divya,

Before getting into the details about formulae that contain 'whileprintingrecords' and 'whilereadingrecords', I would suggest that you should try to understand CR's 'multi-pass' engine.

Both the formulae you posted above will 'execute at different times' in the report's lifecycle. The first will execute when the records are being read from the database and hence numbers each record one by one (due to x := x + 1).

The second one executes 'after' the above stage completes evaluation.

The only time you'll really see a difference in results from the above formulae is when you add a group and then do a Top N sort or add a Group Selection formula.

P.S: Please do read the CR User Guide too if trying to understand the fundamentals.

-Abhilash

Former Member

Hi Abhilash,

Can you please explain this with one example.

The only time you'll really see a difference in results from the above formula is when you add a group and then do a Top N sort or add a Group Selection formula.

0 Likes

Dear Abhilash sir,

I have a doubt in crystal report. I got the formula for superscript and subscript from you itself in the earlier stage. Now my problem is its not refreshing (not clearing or reassigning). if first time whats the formula value appearing the same is repeating all the fields.

the first image is the entry form, in Gen Limit, three lines in the grid, with values (i with Superscript and other one is normal)

in my second image is the SAP crystal report, with the entered values..but in all the lines the first value is repeating. I used 'WhilePrintingRecords' after searching from google..but its not clearing the variable. Please help..

in my report formula, i used these in starting :

stringvar s;

WhilePrintingRecords;

s:= {TMPMASREP.FL13};//getting the input value from this field to variable s

stringvar subS:= '<sub>'; // beginning of a subscript

stringvar subE:= '</sub>'; // end of a subscript

stringvar supS:= '<sup>'; // beginning of a superscript

stringvar supE:= '</sup>'; // end of a superscript

etc..coding

Regards,

Sajeesh

former_member319241
Participant
0 Likes

WhileReadingRecords

Forces the program to evaluate the formula while it is reading database record data.

If you try to include a group in this formula, you will get an error message.

WhilePrintingRecords

Forces the program to evaluate the formula while it is printing database record data.

You are using a simple numbervar x,so it will not matter in this formula.

Former Member
0 Likes

Hi Divya,

To understand better, go in crystal help and read Crystal Reports Pass overview.

Whilereadingrecords;

These formulas are those that contain database

fields but do not contain references to subtotals or summary information. This

evaluation time is known as "WhileReadingRecords."

"WhilePrinting Records."

These are formulas that contain references to subtotals or summary
information, also known as "PrintTime" formulas. This evaluation time is known
as "WhilePrinting Records."

In your case you are not referring any database fields.  Try this example with database fields and summaries.

-Sastry

Former Member
0 Likes

you would not notice any difference in such a formula, since the variable x is simply incremented and it does not matter which pass is being used.

however, if you prefix a running total evaluation-formula (that typically sums up cumulative group summaries) with whilereadingrecords, it will show 'this formula needs to be evaluated at a later pass' error. It will need a whileprintingrecords since the group-summaries are calculated in pass-1 whereas whilereadingrecords is executed in pre-pass 1.

I am guessing that you are preparing for an interview, is it the case?

If yes, then please use the learning resources avaialble at the left-hand side menu.

If no, then please post the issue that you're facing in the report with snapshots.

-Prathamesh

Former Member
0 Likes

Hi Prathamesh,

I am not preparing for any interview.In my report I created two formulas for WRR and WPR.

If I kept WPR formula alone I am getting correct result.If I kept WRR and WPR I am getting WPR as a continoution of WRR.

I Just want to know what is happening here.

PFA

abhilash_kumar
Active Contributor
0 Likes

That's because the value of x is '14' before the WPR formula starts evaluating.

-Abhilash