Chapter 2. Structure of the report file. Sage 2015 Flexible Report Writer
Διαφήμιση
Διαφήμιση
Chapter 2. Structure of the
report file
When you write a report file, it is important that you structure the report code correctly. A good structure will make your report file easy to read and will help you detect errors.
The report file's structure
Each report file generally contains the following components:
Report header – causes HandiLedger 2015 to print the same basic information at the top of each page. For example, the top of a trial balance generally prints the client's name, report name, and column headings.
Report body – contains details of the account codes that HandiLedger 2015 must use to create the report.
Report footer – causes HandiLedger 2015 to print the same basic information at the bottom of each page.
Developing good habits
When you write a report file it is crucial that you make the report code as easy to understand as possible. Remember that you or someone else in your practice may need to modify the report file later. The person who modifies the report file may not be very familiar with it.
The following methods and techniques will make your report file easier to modify in the future:
GroupStart()…GroupEnd() statements
Consider the format files that can be used
Comments
A comment is a notation made within the report code. HandiLedger 2015 ignores comments when it runs the report file.
Add comments into your report files to identify the report file, the various sections of the report, and the aim of that section of report code. Use comments to make the report code more understandable.
Syntax
! [comment text]
Where:
[comment text] - Text information making up the comment
© HandiSoft Software Pty Ltd
21
Chapter 2. Structure of the report file Flexible Report Writer 2015
Example
! Print the rental income accounts
PrintAccounts (#RevRent, Cr)
In the above example:
Line One contains a comment. HandiLedger 2015 ignores the comment and would immediately move to Line Two.
Line Two prints all of the accounts in the #RevRental alias range.
GroupStart() … GroupEnd() statements
The GroupStart() … GroupEnd() statements have two uses:
1. Show the logical grouping of the report code. For example, if you were writing a Profit and
Loss report, you would place the report code for the revenue section within a GroupStart()
… GroupEnd() statement. You would do the same for the expenses section of the report code.
2. Prevent report code from being executed where it does not result in the printing of a value.
For example, if you had a report that printed a heading "Income", and then printed each income account, you would only want the "Income" heading to print if the client had income.
For detailed information on the GroupStart()…GroupEnd() statement, see Chapter 6,
"Statements".
Indentation
Indent the text of your report file to indicate the hierarchy of your report code. Compare the following two samples of report code. Both samples of code achieve the same result, however
Sample 2 is far easier to read than Sample 1.
Example
As you will learn in Chapter 6, "Statements", report code contained within an
statement is only executed if the selected entity meets specific conditions.
Sample One
If (IsCompany) then
AddText ("This is a company.")
Else
AddText ("The entity is not a company.")
EndIf
Sample Two
If (IsCompany) then
AddText ("This is a company.")
Else
AddText ("The entity is not a company.")
EndIf
The above two samples of report code do exactly the same thing. The only difference between the two samples is that Sample Two uses indentation. In Sample Two it is far easier to see which lines of report code will be executed in different circumstances. (Line Two is executed only if the entity is a company, and Line Four is executed only where the entity is not a company).
You will learn about all of the report commands contained in the above report samples within this manual. For those of you who want to understand the above report code now:
Line One checks to see if the selected entity is a company.
Where the entity is a company, the IsCompany condition has been met, and HandiLedger
2015 will go to Line Two.
22
© HandiSoft Software Pty Ltd
Flexible Report Writer 2015 Developing good habits
Where the entity is not a company then the condition has not been met. HandiLedger 2015 will go directly to Line Three, skipping the report code that lies between the "If…" line and the "Else" line.
Line Two prints the text "This is a company."
Line Two (and any other report code that lies between the "If…" line and the "Else" line) is executed only if the "If…" condition in Line One has been met.
Line Three indicates the start of the report code that HandiLedger 2015 is to execute where the condition in the "If…" line was not met.
Line Four prints the text "The entity is not a company."
Line Four (and any other report code that lies between the "Else" line and the "EndIf" line) is executed only if the "If…" condition in Line One was failed.
Line Five indicates the end of the If…EndIf statement.
A word of caution
When you write your own report files, it is important that you remember that users may generate a report by combining your report file with any number of format files. Consequently, you must ensure that your report file works correctly with the various format files. Different format files can produce reports with vast differences in appearance.
This is illustrated in the following scenario .
Scenario
Results using the DCP format file (the report was printed for periods 1 to 3):
Description $
Revenue calculated with AddAccounts
Revenue calculated with AddClosingBalance
30.00
30.00
Results using the P13_1-3 format file (the report was printed for periods 1 to 3):
Jul
$
Aug
$
Sept
$
Jul –
Sept
$
30.00 Revenue calculated with AddAccounts function
Revenue calculated with AddClosingBalance function
10.00
10.00
10.00
20.00
10.00
30.00 30.00
Notice that for each monthly column, the
function includes transactions for
function only considers transactions falling into the date
range for that column.
© HandiSoft Software Pty Ltd
23
Chapter 2. Structure of the report file Flexible Report Writer 2015
Report code
Rev1 = AddAccounts (#RevAll, Cr)
Rev2 = AddClosingBalance (#RevAll, Cr)
PrintValue ("Revenue calculated with AddAccounts", Rev1, Cr)
PrintValue ("Revenue calculated with AddClosingBalance", Rev2, Cr)
The above report code does the following:
Line One adds the total value of the #RevAll account range using the AddAccounts function. The value that HandiLedger 2015 calculates is then stored in the Rev1 variable.
Line Two adds the closing balance of the #RevAll alias account range using the
AddClosingBalance function. The value that HandiLedger 2015 calculates is then stored in the Rev2 variable.
Line Three prints a description, "Revenue calculated with AddAccounts". It also prints the value that is stored in the Rev1 variable.
Line Four prints a description, "Revenue calculated with AddClosingBalance". It also prints the value that is stored in the Rev2 variable.
24
© HandiSoft Software Pty Ltd
Λήψη
Διαφήμιση