Reg: Code Unit for designing reports

Hi…can anyone say how to write code to calculate Tax % for designing reports.

Welcome to DUG!!!

What Report you are designing and what you required???

Purchase order report… In that report i want to calculate tax %.

Purchase order report…In that report i want to calculate tax % …

For that you don’t required to Calculate Tax as there is already field available in Purchase line Table i.e Tax% ,Tax Amount

ok…but my requirement is if tax % is available then it should display that value…if not it should not display 0 or that field…for example tax % … 0 …

Then create 2 sections

1 with Tax%

2 without Tax%

Based on the Tax% value show the section…

Then Take a variable and put tax% in that variable and show that variable in section

Write a code like

If Tax%<>0 then

var Tax:=Tax%


ok thank you…

Hi amol sir…should i write that code in purchase line dataitem? If u dont mind please give me the detailed description of that code…

Create a text variable for the VAT % label and give a value to the variable only if the “VAT %” is <> 0

The “VAT %” field has a property BlankZero and should be set to Yes.

So now, you can control what is displayed.

You can find out if the VAT amount for the order is zero or not:

CALCFIELDS(Amount,“Amount Including VAT”);
IF Amount <>“Amount Including VAT” then
VAT%Label := ‘VAT %’;

You Can write code on onAftergetrecord trigger of purchase line

As well as you can write code on Section (But it is not feasible option because if anybody delete the section then code will also gone)

Go to the C/AL Code of the Body Section, if the “Tax Amount” is the field that you want to hide if its zero then,

IF “Tax Amount” = ’ ’ THEN




hi elisha…for the above code i can hide only " Tax Amount" field if it zero…but i want to hide along with “Tax%” and label field .

plz suggest if any one know.

Did you try this?

Hi mohana…Can u please explain in detail ?

Header 1

<field 1> <field 2> <tax %>

Header 2

<Field 1> <field 2>

Show Header 1 if tax % is not equal to 0

Show header 2 if tax % equal to 0

Did you get?

Hi mohana…can u please explain in detail.

Sorry…I cannot explain more in detail than this…


Hi mohana…can u plz explain in detail?