Internal rate of return

Published on November 2016 | Categories: Documents | Downloads: 51 | Comments: 0 | Views: 529
of 28
Download PDF   Embed   Report

Comments

Content

Internal rate of return
From Wikipedia, the free encyclopedia

This article needs additional citations for verification.
Please help improve this article by adding reliable references. Unsourced material may be challenged and removed. (March 2009)

The internal rate of return (IRR) is a rate of return used in capital budgeting to measure and compare the profitability of investments. It is also called the discounted cash flow rate of return (DCFROR) or simply the rate of return (ROR).[1] In the context of savings and loans the IRR is also called the effective interest rate. The term internal refers to the fact that its calculation does not incorporate environmental factors (e.g., the interest rate or inflation).
Contents
[hide] • • •

1 Definition 2 Uses 3 Calculation


3.1 Example
 

3.1.1 Numerical solution 3.1.2 Numerical Solution for Single Outflow and Multiple Inflows

• • • • • •

4 Problems with using internal rate of return 5 Mathematics 6 See also 7 References 8 Further reading 9 External links

[edit]Definition

Showing the position of the IRR on the graph of NPV(r) (r is labelled 'i' in the graph)

The internal rate of return on an investment or project is the "annualized effective compounded return rate" or discount rate that makes the net present value(NPV) of all cash flows (both positive and negative) from a particular investment equal to zero. In more specific terms, the IRR of an investment is the interest rate at which the net present value of costs (negative cash flows) of the investment equals thenet present value of the benefits (positive cash flows) of the investment. Internal rates of return are commonly used to evaluate the desirability of investments or projects. The higher a project's internal rate of return, the more desirable it is to undertake the project. Assuming all projects require the same amount of up-front investment, the project with the highest IRR would be considered the best and undertaken first. A firm (or individual) should, in theory, undertake all projects or investments available with IRRs that exceed the cost of capital. Investment may be limited by availability of funds to the firm and/or by the firm's capacity or ability to manage numerous projects. [edit]Uses Important: Because the internal rate of return is a rate quantity, it is an indicator of the efficiency, quality, or yield of an investment. This is in contrast with the net present value, which is an indicator of the value or magnitude of an investment. An investment is considered acceptable if its internal rate of return is greater than an established minimum acceptable rate of return or cost of capital. In a scenario where an investment is considered by a firm that has equity holders, this minimum rate is the cost of capital of the investment (which may be determined by the risk-adjusted cost of capital of alternative investments). This ensures that the investment is supported by equity holders since, in general, an investment whose IRR exceeds its cost of capital adds value for the company (i.e., it is economically profitable). [edit]Calculation Given a collection of pairs (time, cash flow) involved in a project, the internal rate of return follows from the net present value as a function of the rate of return. A rate of return for which this function is zero is an internal rate of return. Given the (period, cash flow) pairs (n, Cn) where n is a positive integer, the total number of periods N, and the net present value NPV, the internal rate of return is given by r in:

Note that the period is usually given in years, but the calculation may be made simpler if r is calculated using the period in which the majority of the problem is defined (e.g., using months if most of the cash flows occur at monthly intervals) and converted to a yearly period thereafter. Note that any fixed time can be used in place of the present (e.g., the end of one interval of an annuity); the value obtained is zero if and only if the NPV is zero. In the case that the cash flows are random variables, such as in the case of a life annuity, the expected values are put into the above formula. Often, the value of r cannot be found analytically. In this case, numerical methods or graphical methods must be used. [edit]Example If an investment may be given by the sequence of cash flows Year (n) Cash Flow (Cn) 0 then the IRR r is given by 1 2 3 . In this case, the answer is 14.3%. [edit]Numerical solution Since the above is a manifestation of the general problem of finding the roots of the equation NPV(r), there are many numerical methods that can be used to estimate r. For example, using the secant method, r is given by 4 −4000 1200 1410 1875 1050

. where rn is considered the nth approximation of the IRR. This r can be found to an arbitrary degree of accuracy. The convergence behaviour of the sequence is governed by the following:
 

If the function NPV(i) has a single real root r, then the sequence will converge reproducibly towards r. If the function NPV(i) has n real roots converges. when NPV0 > 0 or , then the sequence will converge to one of the roots and changing the values of the initial pairs may change the root to which it



If function NPV(i) has no real roots, then the sequence will tend towards +∞. when NPV0 < 0 may speed up convergence of rn to r.

Having

[edit]Numerical Solution for Single Outflow and Multiple Inflows

Of particular interest is the case where the stream of payments consists of a single outflow, followed by multiple inflows occurring at equal periods. In the above notation, this corresponds to: C0 < 0,Cn ≥ 0 for n ≥ 1. In this case the NPV of the payment stream is a convex, strictly decreasing function of interest rate. There is always a single unique solution for IRR. Given two estimates r1 and r2 for IRR, the secant method equation (see above) with n = 2 will always produce an improved estimate r3. This is sometimes referred to as the Hit and Trial (or Trial and Error) method. There is however a much more accurate estimation formula, given by:

where

. In this equation, NPVn,in and NPVn − 1,in refer to the NPV's of the inflows only (that is, set C0 = 0 and compute NPV). For example, using the stream of payments {-4000, 1200, 1410, 1875, 1050} and initial guesses r1 = 0.1 and r2 = 0.2 gives NPV1,in = 4382.1 and NPV2,in = 3570.6. The accurate formula estimates IRR as 14.35% (0.3% error) as compared to IRR = 14.7% (3% error) from the secant method. If applied iteratively, either the secant method or the improved formula will always converge to the correct solution. Both the secant method and the improved formula rely on initial guesses for IRR. The following initial guesses may be used:

r2 = (1 + r1)p − 1
where

A = sum of inflows = C1 + ... + CN
. Further discussion and a performance comparison of IRR estimation methods may be found in.[2] [edit]Problems

with using internal rate of return

As an investment decision tool, the calculated IRR should not be used to rate mutually exclusive projects, but only to decide whether a single project is worth investing in.

NPV vs discount rate comparison for two mutually exclusive projects. Project 'A' has a higher NPV (for certain discount rates), even though its IRR (=x-axis intercept) is lower than for project 'B' (click to enlarge)

In cases where one project has a higher initial investment than a second mutually exclusive project, the first project may have a lower IRR (expected return), but a higher NPV (increase in shareholders' wealth) and should thus be accepted over the second project (assuming no capital constraints). IRR assumes reinvestment of interim cash flows in projects with equal rates of return (the reinvestment can be the same project or a different project). Therefore, IRR overstates the annual equivalent rate of return for a project whose interim cash flows are reinvested at a rate lower than the calculated IRR. This presents a problem, especially for high IRR projects, since there is frequently not another project available in the interim that can earn the same rate of return as the first project. When the calculated IRR is higher than the true reinvestment rate for interim cash flows, the measure will overestimate — sometimes very significantly — the annual equivalent return from the project. The formula assumes that the company has additional projects, with equally attractive prospects, in which to invest the interim cash flows.[3] This makes IRR a suitable (and popular) choice for analyzing venture capital and other private equityinvestments, as these strategies usually require several cash investments throughout the project, but only see one cash outflow at the end of the project (e.g., via IPO or M&A). Since IRR does not consider cost of capital, it should not be used to compare projects of different duration. Modified Internal Rate of Return (MIRR) does consider cost of capital and provides a better indication of a project's efficiency in contributing to the firm's discounted cash flow.

In the case of positive cash flows followed by negative ones and then by positive ones (for example, + + - - - +) the IRR may have multiple values. In this case a discount rate may be used for the borrowing cash flow and the IRR calculated for the investment cash flow. This applies for example when a customer makes a deposit before a specific machine is built. In a series of cash flows like (-10, 21, -11), one initially invests money, so a high rate of return is best, but then receives more than one possesses, so then one owes money, so now a low rate of return is best. In this case it is not even clear whether a high or a low IRR is better. There may even be multiple IRRs for a single project, like in the example 0% as well as 10%. Examples of this type of project are strip mines and nuclear power plants, where there is usually a large cash outflow at the end of the project. In general, the IRR can be calculated by solving a polynomial equation. Sturm's theorem can be used to determine if that equation has a unique real solution. In general the IRR equation cannot be solved analytically but only iteratively. When a project has multiple IRRs it may be more convenient to compute the IRR of the project with the benefits reinvested.[3] Accordingly, MIRR is used, which has an assumed reinvestment rate, usually equal to the project's cost of capital. It has been shown[4] that with multiple internal rates of return, the IRR approach can still be interpreted in a way that is consistent with the present value approach provided that the underlying investment stream is correctly identified as net investment or net borrowing. See also [5] for a way of identifying the relevant value of the IRR from a set of multiple IRR solutions. Despite a strong academic preference for NPV, surveys indicate that executives prefer IRR over NPV.[6] Apparently, managers find it easier to compare investments of different sizes in terms of percentage rates of return than by dollars of NPV. However, NPV remains the "more accurate" reflection of value to the business. IRR, as a measure of investment efficiency may give better insights in capital constrained situations. However, when comparing mutually exclusive projects, NPV is the appropriate measure. [edit]Mathematics Mathematically the value of the investment is assumed to undergo exponential growth or decay according to some rate of return (any value greater than -100%), with discontinuities for cash flows, and the IRR of a series of cash flows is defined as any rate of return that results in a net present value of zero (or equivalently, a rate of return that results in the correct value of zero after the last cash flow). Thus internal rate(s) of return follow from the net present value as a function of the rate of return. This function is continuous. Towards a rate of return of -100% the net present value approaches infinity with the sign of the last cash flow, and towards a rate of return of positive infinity the net present value approaches the first cash flow (the one at the present). Therefore, if the first and last cash flow have a different sign there exists an internal rate of return. Examples of time series without an IRR:  Only negative cash flows - the NPV is negative for every rate of return.


(-1, 1, -1), rather small positive cash flow between two negative cash flows; the NPV is a quadratic function of 1/(1+r), where r is the rate of return, or put differently, a quadratic function of thediscount rate r/(1+r); the highest NPV is -0.75, for r = 100%.

In the case of a series of exclusively negative cash flows followed by a series of exclusively positive ones, consider the total value of the cash flows converted to a time between the negative and the positive ones. The resulting function of the rate of return is continuous and monotonically decreasing from positive infinity to

negative infinity, so there is a unique rate of return for which it is zero. Hence the IRR is also unique (and equal). Although the NPV-function itself is not necessarily monotonically decreasing on its whole domain, it is at the IRR. Similarly, in the case of a series of exclusively positive cash flows followed by a series of exclusively negative ones the IRR is also unique.

Net present value
From Wikipedia, the free encyclopedia

In finance, the net present value (NPV) or net present worth (NPW)[1] of a time series of cash flows, both incoming and outgoing, is defined as the sum of the present values (PVs) of the individual cash flows. In the case when all future cash flows are incoming (such as coupons and principal of a bond) and the only outflow of cash is the purchase price, the NPV is simply the PV of future cash flows minus the purchase price (which is its own PV). NPV is a central tool in discounted cash flow (DCF) analysis, and is a standard method for using the time value of money to appraise long-term projects. Used for capital budgeting, and widely throughout economics, finance, and accounting, it measures the excess or shortfall of cash flows, in present value terms, once financing charges are met. The NPV of a sequence of cash flows takes as input the cash flows and a discount rate or discount curve and outputs a price; the converse process in DCF analysis - taking a sequence of cash flows and a price as input and inferring as output a discount rate (the discount rate which would yield the given price as NPV) - is called the yield, and is more widely used in bond trading.
Contents
[hide] • • • • • • • •

1 Formula 2 The discount rate 3 NPV in decision making 4 Example 5 Common pitfalls 6 History 7 Alternative capital budgeting methods 8 References

[edit]Formula

Each cash inflow/outflow is discounted back to its present value (PV). Then they are summed. Therefore NPV is the sum of all terms,

where t - the time of the cash flow i - the discount rate (the rate of return that could be earned on an investment in the financial markets with similar risk.) Rt - the net cash flow (the amount of cash, inflow minus outflow) at time t. For educational purposes, R0 is commonly placed to the left of the sum to emphasize its role as (minus) the investment. The result of this formula if multiplied with the Annual Net cash in-flows and reduced by Initial Cash outlay will be the present value but in case where the cash flows are not equal in amount then the previous formula will be used to determine the present value of each cash flow separately. Any cash flow within 12 months will not be discounted for NPV purpose.[2]
[edit]The

discount rate

Main article: Discount rate The rate used to discount future cash flows to the present value is a key variable of this process. A firm's weighted average cost of capital (after tax) is often used, but many people believe that it is appropriate to use higher discount rates to adjust for risk or other factors. A variable discount rate with higher rates applied to cash flows occurring further along the time span might be used to reflect the yield curve premium for long-term debt. Another approach to choosing the discount rate factor is to decide the rate which the capital needed for the project could return if invested in an alternative venture. If, for example, the capital required for Project A can earn five percent elsewhere, use this discount rate in the NPV calculation to allow a direct comparison to be made between Project A and the alternative. Related to this concept is to use the firm's Reinvestment Rate. Reinvestment rate can be defined as the rate of return for the firm's investments on average. When analyzing projects in a capital constrained environment, it may be appropriate to use the reinvestment rate rather than the firm's weighted average cost of capital as the discount factor. It reflects opportunity cost of investment, rather than the possibly lower cost of capital. An NPV calculated using variable discount rates (if they are known for the duration of the investment) better reflects the real situation than one calculated from a constant discount rate for the entire investment duration. Refer to the tutorial article written by Samuel Baker[3] for more detailed relationship between the NPV value and the discount rate. For some professional investors, their investment funds are committed to target a specified rate of return. In such cases, that rate of return should be selected as the discount rate for the NPV calculation. In this way, a direct comparison can be made between the profitability of the project and the desired rate of return. To some extent, the selection of the discount rate is dependent on the use to which it will be put. If the intent is simply to determine whether a project will add value to the company, using the firm's weighted average cost of capital may be appropriate. If trying to decide between alternative investments in order to maximize the value of the firm, the corporate reinvestment rate would probably be a better choice. Using variable rates over time, or discounting "guaranteed" cash flows differently from "at risk" cash flows may be a superior methodology, but is seldom used in practice. Using the discount rate to adjust for risk is often difficult to do in practice (especially internationally), and is difficult to do

well. An alternative to using discount factor to adjust for risk is to explicitly correct the cash flows for the risk elements using rNPV or a similar method, then discount at the firm's rate.
[edit]NPV

in decision making

NPV is an indicator of how much value an investment or project adds to the firm. With a particular project, if Rt is a positive value, the project is in the status of discounted cash inflow in the time of t. IfRt is a negative value, the project is in the status of discounted cash outflow in the time of t. Appropriately risked projects with a positive NPV could be accepted. This does not necessarily mean that they should be undertaken since NPV at the cost of capital may not account for opportunity cost, i.e. comparison with other available investments. In financial theory, if there is a choice between two mutually exclusive alternatives, the one yielding the higher NPV should be selected.
If... It means... Then... NPV > the investment would add value to the the project may be accepted 0 firm NPV < the investment would subtract value 0 from the firm the project should be rejected

NPV = the investment would neither gain nor We should be indifferent in the decision whether to accept or reject the project. This project adds no monetary value. Decision should be 0 lose value for the firm based on other criteria, e.g. strategic positioning or other factors not explicitly included in the calculation. [edit]Example

A corporation must decide whether to introduce a new product line. The new product will have startup costs, operational costs, and incoming cash flows over six years. This project will have an immediate (t=0) cash outflow of $100,000 (which might include machinery, and employee training costs). Other cash outflows for years 1–6 are expected to be $5,000 per year. Cash inflows are expected to be $30,000 each for years 1–6. All cash flows are after-tax, and there are no cash flows expected after year 6. The required rate of return is 10%. The present value (PV) can be calculated for each year:
Year T=0 Cash flow Present value -$100,000

T=1

$22,727

T=2

$20,661

T=3

$18,783

T=4

$17,075

T=5

$15,523

T=6

$14,112

The sum of all these present values is the net present value, which equals $8,881.52. Since the NPV is greater than zero, it would be better to invest in the project than to do nothing, and the corporation should invest in this project if there is no mutually exclusive alternative with a higher NPV. The same example in Excel formulae:
 

NPV(rate,net_inflow)+initial_investment PV(rate,year_number,yearly_net_inflow) 



More realistic problems would need to consider other factors, generally including the calculation of taxes, uneven cash flows, and Terminal Value as well as the availability of alternate investment opportunities.
[edit]Common


pitfalls

If, for example, the Rt are generally negative late in the project (e.g., an industrial or mining project might have clean-up and restoration costs), then at that stage the company owes money, so a high discount rate is not cautious but too optimistic. Some people see this as a problem with NPV. A way to avoid this problem is to include explicit provision for financing any losses after the initial investment, that is, explicitly calculate the cost of financing such losses. Another common pitfall is to adjust for risk by adding a premium to the discount rate. Whilst a bank might charge a higher rate of interest for a risky project, that does not mean that this is a valid approach to adjusting a net present value for risk, although it can be a reasonable approximation in some specific cases. One reason such an approach may not work well can be seen from the following: if some risk is incurred resulting in some losses, then a discount rate in the NPV will reduce the impact of such losses below their true financial cost. A rigorous approach to risk requires identifying and valuing risks explicitly, e.g. by actuarial or Monte Carlo techniques, and explicitly calculating the cost of financing any losses incurred. Yet another issue can result from the compounding of the risk premium. R is a composite of the risk free rate and the risk premium. As a result, future cash flows are discounted by both the risk-free rate as well as the risk premium and this effect is compounded by each subsequent cash flow. This compounding results in a much lower NPV than might be otherwise calculated. The certainty equivalent model can be used to account for the risk premium without compounding its effect on present value.[citation needed]







Another issue with relying on NPV is that it does not provide an overall picture of the gain or loss of executing a certain project. To see a percentage gain relative to the investments for the project, usually, Internal rate of return or other efficiency measures are used as a complement to NPV.

[edit]

The Layout File
While the template layout file is a PHP file, it is written mostly in HTML with only a few snippets of PHP. You do not have to be a master of PHP to write a template file. All you need to be able to do is learn where to place the key "hooks" into the Joomla templating engine. Within the HTML framework you place "windows" that look into the database behind your web site. There are typically several small windows called Modules and usually one larger opening (like a frontdoor) for a Component. You are encouraged to write templates in XHTML. While there is debate over whether XHTML *is* the way of the future, it is a well formed XML standard, whereas HTML is a loose standard. Future versions of Joomla will rely more and more on XML so it is wise to adopt this model now. The index.php file for a typical 3-column layout would look like the following in a skeletal form:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: <?php $iso = explode( '=', _ISO ); echo '<?xml version="1.0" encoding="' . $iso[1] . "\"?>\n"; /** ensure this file is being included by a parent file */ defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="<?php echo _LANGUAGE; ?>"> <head> <title><?php echo $mosConfig_sitename; ?></title> <meta http-equiv="Content-Type" content="text/html; <?php echo _ISO; ?>" /> <?php if ($my->id) { initEditor(); } ?> <?php mosShowHead(); ?>

18: <link href="<?php echo $mosConfig_live_site;?>/templates/basic_template/css/template_css.css" rel="stylesheet" type="text/css" /> 19: </head> 20: <body> 21: <table cellspacing="0" cellpadding="5" border="0"> 22: <tr> 23: <td colspan="3"> 24: <?php echo $mosConfig_sitename; ?> 25: </td> 26: </tr> 27: <tr> 28: <td colspan="3"> 29: <?php mosLoadModules ( 'top', 1 ); ?> 30: </td> 31: </tr> 32: <tr> 33: <td width="20%" valign="top"> 34: <?php mosLoadModules ( 'left' ); ?> 35: </td> 36: <td width="60%" valign="top"> 37: <?php mosMainBody(); ?> 38: </td> 39: <td width="20%" valign="top"> 40: <?php mosLoadModules ( 'right' ); ?> 41: </td> 42: </tr> 43: <tr> 44: <td colspan="3" valign="top"> 45: <?php mosLoadModules ( 'bottom' ); ?> 46: </td> 47: </tr> 48: </table> 49: </body> 50: </html>

Let's have a look at the main features. We are assuming you already know a bit about HTML pages so things like head tags, body tags, tables, etc will be skipped over. Line 1-3: Defines the file as a valid XML file. _ISO is a special constant defining the character set encoding to use. It is defined in your language file.

Line 5: Prevents direct access to this file. It is essential that you include this line in your template. Lines 7-8: Set up the XHTML standard for the page. Line 10: Prints out the Site Name configuration variable with the opening and closing title tags. Line 11: _ISO is used again to define the character set to use. Line 12-16: $my->id is a script variable that is non-zero if a user is logged in to your site. If a user is logged in then the nominated WYSIWYG editor is pre-loaded. You may, if you wish, always pre-load the editor, but generally an anonymous visitor will not have the need to add content. This saves a little script overhead for normal browsing of your site. Line 17: Inserts several metadata blocks. Lines 18: Loads the CSS stylesheet. $mosConfig_live_site is a configuration variable that holds the absolute URL of your site. Line 24: This prints the Site Name in a table cell (spanning the three columns). Line 29: This loads any modules that are published in the "top" position. The second argument, "1", indicates that the modules are to be aligned horizontally. Line 34: This loads any modules that are published in the "left" position. These modules will be displayed in a single column. Line 37: This loads the component into your template. The component is set by the URL, for example, index.php? option=com_content will display the Content Component in this area. Line 40: This loads any modules that are published in the "right" position. These modules will be displayed in a single column. Line 45: This loads any modules that are published in the "bottom" position.
Last Updated ( Tuesday, 17 January 2006 )

Chapter 2 . Introducing Report Layout
The layout window defines the format and content of report output. It typically contains one or more layout areas, named spaces whose contents are output at runtime. A layout area can only be invoked through a print node in the report structure; the timing and sequence of the layout area's output depends on execution of its print node. A layout area outputs data through the widgets that populate it. Each widget's properties determine the source and format of its data; the widget's position within the layout area determines where that output appears in relation to other output from the same layout area. A layout area is defined by a layout area widget, which set the area's boundary and name. The layout area spans the width of the layout window and extends to the layout area widget above it or to the window's border. The layout window also contains an unnamed area whose contents are not subject to output. For example, the following layout window contains three layout areas for detail, page header, and page footer output, defined as data, page_header, and page_footer, respectively:

Figure 2-1 A layout window contains layout areas and an unnamed area. The following report structure contains three print nodes that specify when to output the layout areas shown earlier:

Figure 2-2 Print nodes specify which layout areas to output, and when.

Creating Layout Areas
You define a layout area by creating a layout area widget:

1. Give the layout window focus. Choose Create Layout Area or the corresponding toolbox button. 1. Point and click where you want the new area to appear in the layout window. Prolifics creates an unnamed layout area widget, which defines the area between it and the layout area widget above it. Because layout areas can only be invoked by name, you should always set a new layout area's Name property (under Identity). Like other widgets, layout area names within the same report file must be unique. For information about Prolifics naming conventions, refer to "Naming Conventions" in Using the Editors.
1.

Managing the Layout Window
You can modify the view of report layouts by collapsing some or all of the layout areas, or by changing their relative positions. This can help maximize the amount of working space available for a given area and lets you rearrange the window's contents in a way that makes sense to you. You can also manipulate a layout area widget in order to change the area's size. How to Collapse and Expand Layout Areas 1. Select the layout areas that you want to collapse or expand. 1. From the Edit menu, bring up the Arrange submenu and choose the desired option: ○ Collapse—Reduces each selected area to a single line and hides its contents. ○ Expand—Restores the selected layout areas to their full dimensions. ○ Collapse All—Reduces all layout areas to a single line; the unnamed area at the window's bottom is unaffected.


Expand All—Restores all layout areas to their full dimensions.

Note: When you save or preview a report, Prolifics automatically restores all collapsed layout areas to full view. How to Move Layout Areas 1. Select the desired layout area widgets. 1. From the Edit menu, bring up the Arrange submenu and choose the desired option: ○ Move Up moves the selected areas above the areas previously above them. ○ Move Down moves the selected areas below the areas previously below them. Note: Rearranging layout areas in the layout window has no effect on report output. How to Change Layout Area Dimensions • To enlarge a layout area, select the layout area widget and drag it down as far as needed. • To reduce a layout area, select the layout area and drag it up. You can move the layout area widget up only as far as the first widget inside that area. To reduce the area further, you must first move up the widgets inside it. In both cases, changing the dimensions of one layout area has no effect on the others. Note: You can only change a layout area's height; all layout areas occupy the entire width of the report page.

Editing Layout Area Properties

Each layout area has a set of properties that are described below. These properties set format and behavior parameters for the entire layout area. Select the layout area widget and bring the Properties window into focus. Name Only named layout areas can be specified for output in the report. Layout area names must be unique among all other named widgets and nodes in the report file. Refer to "Naming Conventions" in Using the Editorsfor more information about widget naming conventions and requirements. Inherit From Defines the source of inheritance—the name of the repository report followed by the name of the parent object in this format:
repository_entry!widget_name

For more information about inheritance, refer to "Controlling Inheritance" in Using the Editors. Memo Text Provides up to nine lines of text for comments or programmatic use. Start Row Specifies the layout area widget's position relative to the layout window's grid. Vertical Anchor Specifies how the layout area widget aligns itself to the layout window's grid when you choose Edit Grid Align or Options Snap To Grid: • Middle (default)—The layout area widget snaps to the middle of the nearest vertical coordinate. • Top—The layout area snaps to the top of the nearest vertical coordinate. • Bottom—The layout area snaps to the bottom of the nearest vertical coordinate. Font properties Sets the default font properties—Font Name, Point Size, and so on—for all widgets in this layout area. If the layout area's font properties are set to Default, at runtime Prolifics resolves which fonts to apply according to what is set at a higher level. For more information about how fonts are set, refer to "Using Fonts."

Populating Layout Areas
In general, Prolifics outputs the data of all widgets in an invoked layout area. Two widget types are responsible for most report output: • dynamic output widgets get their data at runtime—for example, from a database or from other widgets. • static output widgets have their data set in the editor; their data remains constant. For example, the following layout window contains three layout areas—page_header, page_footer, and data:

is output as the report's page header. It contains two dynamic output widgets for the report title and system date. It also contains static output widgets that at runtime appear over columns of data; their values are fixed. • page_footer is output as the report's page footer. It includes a widget that outputs page numbers. • data contains dynamic output widgets that at runtime display the film data—name, genre, and so on; these widgets are initially empty and get their data at runtime, usually from a database. A report that uses this layout might yield the following output:

page_header

A layout area's output includes white space. The height of the layout area determines the amount of space the layout area uses. White space is reduced or eliminated only in the case of shrinkage (see "Shrinking Layout Areas") and consolidation (see "Consolidating Blank Space"). A layout area can also include other widgets: graph widgets let you present data as a pie or bar graph; box and line widgets can be used to enhance a report's appearance. For example, page_header contains a horizontal line that underlines the column labels in the actual report. Copying Widgets to a Layout Window You can create widgets directly from the Create menu or toolbox, or you can copy them from the layout window of another open report or a screen. When you copy widgets from a screen, Prolifics checks their type and makes the following adjustments: • Line, box, and graph widgets are copied directly to the target layout window with no changes. • Static labels are converted to static output widgets. • Grid frame widgets cannot be copied to a report. • All other widget types are converted to dynamic output widgets. When you copy widgets from a repository entry, Prolifics sets the widget's Inherit From property and applies rules of inheritance to the copied widgets. A widget that is copied directly from a repository entry inherits the properties of its source. If you copy an object from a screen or from another report, any properties that it inherits are propagated to the copy. Inheritance helps ensure that a widget is consistent in its appearance and behavior wherever it appears in the report or elsewhere in the application. For example, you might want all monetary values to conform to the same format. Setting the appropriate properties in repository objects lets you propagate this format to output widgets in your reports.

For more information about inheritance, refer to Chapter 11, "Creating and Using a Repository," in Application Development Guide or "Controlling Inheritance" in Using the Editors. Positioning Widgets By default, a widget's position is fixed in relation to its layout area. If widgets that are on the same line are wider than the data that they actually output, you can eliminate the unused space and thereby make their data contiguous. Set their Placement property (under Composition) to one of these values: • Left Float—Trim the width of the previous widget to its actual output; float this widget's start position left by the number of trimmed characters. • Right Float—Trim leading blanks from the next widget; float this widget's start position right by the number of trimmed characters. Prolifics floats widgets only to the extent that their own widths are trimmed. The actual amount of white space between widgets remains unaffected. Note: To make sure that widgets float towards each other, align them horizontally so that their Start Row properties have the same value. If Start Row properties are not the same, Prolifics might use their absolute (fixed) positions. The screen editor provides a number of options for aligning and spacing widgets within a layout window—for example, Edit arranging widgets, refer to"Arranging Widgets" in Using the Editors. Align and Options Snap to Grid. For more information about

Chapter 3 . Introducing Report Structure
The Prolifics editor offers two views into a report file: the physical layouts used by a report are shown in the layout window, while specifications for report generation are schematically rendered in the report structure window. This chapter focuses on report structure components and their properties. The report structure for any report is available by choosing View Report Structure.

Report Structure Window
The report structure window schematically shows how a report executes. Stages of report execution are depicted in a vertical hierarchy composed of nodes. The topmost node defines a report; when this report runs, all nodes below and subordinate to it execute in top-down order. For example, the following column report sorts orders from video store outlets by distributor name and order number:

Figure 3-1 Column report by distributor name and order numbe Figure 3-2 shows how execution of this report is viewed through the report structure window and its corresponding layout window. The two windows offer complementary views into the same report definition:

Figure 3-2 Structure of report that outputs video outlet orders. Figure 3-2 shows a report structure composed of these node types: • The topmost unnamed node is a report node; it represents the desired report. All nodes attached to it comprise the report's definition. The report structure window can contain multiple reports, each beginning with a report node and representing separate report definitions. Of these, only the first report can be unnamed. • A page format node follows the report node; it specifies page dimensions and orientation. Attached to it are two print nodes, which specify the layout areas to use for page header and footer output—page_headerand page_footer, respectively. Because page headers and footers are above and below all other page output, these two nodes enclose the detail and group nodes. • A detail node specifies the source of report data. In this case, the report relies upon Prolifics's transaction manager to use the table views and link widgets stored with this report to fetch the required data. Attached to this node is a single print node, which outputs each instance of the detail data.

Three group nodes are attached to the detail node; these tell Prolifics how to organize data in the report. Each group node has a print node in its footer section, which outputs subtotals for its group. Node Classes and Types Nodes belong to one of two classes—structure nodes and action nodes: • Each structure node determines an aspect of the report definition—for example, a page format node sets page dimensions and orientation, while a detail node determines how the report gets its data. • Action nodes are attached to a structure node and determine report output and processing for that structure node—for example, a print node that is attached to a group node's footer section specifies the layout area to print after a break occurs within that group; a call node specifies a function to call; and so on. Table 3-1 lists the different node types and summarizes their purpose:


Table 3-1 Report structure node types Type Purpose More Information...

Structure nodes: Report Defines a report. "Defining a Report" "Setting Page Format" "Processing One-Time Events" "Fetching Report Data"

Page Format Specifies page format and orientation. Instance Detail Group Action nodes: Print Call Subreport End Page Outputs a layout area. Calls a function. Invokes a subreport. Forces a page break and starts a new page. Provides an all-purpose hook for one-time execution of the attached action nodes. Specifies the source of report data and actions to perform at each fetch.

Specifies how to group data and the processing to perform when a new group is generated. "Creating Groups"

"Outputting Detail Data" "Calling Functions" "Invoking Subreports" "Forcing Page Breaks"

You can attach any number and type of action nodes to all structure nodes except a report node. Action nodes can be attached in any order. Node Hierarchy The order of a report's structure nodes is summarized in this formula:

A report structure conforms to these rules: • The first node in a structure must be a report node. • A report node must be followed by a page format node, whose properties set page dimensions and orientation. A report can have multiple page format nodes; this lets you change a report's format at different stages of execution. • After the page format node, a report can contain one or more instance and detail nodes in any order. Each detail node can have one or more group nodes. Typically, a report uses one set of data and has only one detail node. • Each structure node except a report node can have one or more action nodes attached to it. Action nodes can be of any type and placed in any order. The flexibility offered by report structures lets you create almost any flavor of report with as many levels of complexity as needed. Editing the Report Structure You can modify the report structure by adding, removing, and moving nodes. You can also control the amount of detail shown by collapsing and expanding portions of the structure's hierarchy.
How to Add a Node

1. Select the node type from either of the following: ○ Create menu—Select a node type from the list. ○ Tool box—Select the desired icon.

1. Select the node that is above the position desired for the new node.
How to Delete or Remove a Node

Select a node and do one of the following:


Choose Edit Cut or the Cut button from the toolbar. This places the removed node and its attachments in the structure's clipboard. You can then paste the node wherever its placement is valid in the report structure. The cut node remains in the clipboard until it is overwritten by the next Cut or Copy operation. Choose Edit Delete or press the Delete key. The selected node and its attachments are removed from the structure and from memory; they can only be restored by choosing Undo.



How to Copy a Node

Select the node to copy and choose Edit Copy or the Copy button from the toolbar. This places a copy of the node and its attachments in the structure's clipboard. You can then paste the copy anywhere its placement is valid in the report structure. The copy remains in the clipboard until it is overwritten by the next Cut or Copy operation.
How to Paste a Node

Choose Edit Paste or the Paste button from the toolbar. 1. Select the node that is above the position desired for the pasted node.
1.

How to Move a Node

Select the node that you want to move. Do either of the following: From the Edit menu, choose Arrange Move Up or Arrange Move Down. • Press the Move Up or Move Down key. The logical keys for Move Up and Move Down are EXTU and EXTD, respectively. These are mapped by default, in both X and Windows, to the physical keys shift-uparrow and shift-downarrow, respectively. Note: You can move a node up and down only within its current level in the report structure hierarchy. For example, a call node that is subordinate to an instance node can be moved above or below other action nodes that belong to the same instance node; it cannot be moved anywhere else in the report structure. To move a node elsewhere in the hierarchy, use Cut and Paste.


How to Collapse and Expand the Structure View

Click on a node's type ID button to toggle all attached nodes in and out of view; or from the Edit menu, choose Arrange expand portions of the report structure.

Expand or Arrange

Contract. Figure 3-3 shows how you can collapse and

Figure 3-3 Click on a node's type ID button to collapse and expand the view of its subordinate nodes. You can also collapse or expand the entire structure. From the Edit menu, bring up the Arrange submenu and choose the desired option: • Contract All—Hides all nodes in the structure window except report nodes. • Expand All—Restores view of all nodes in the structure window. Editing Node Properties Through the Properties window, you can edit the properties of any selected node. To bring the Properties window into focus for the current node, give focus to the node. An arrow marks the selection; you can bring the Properties window forward by double-clicking on this arrow. Each node type has one or more properties that are unique to it; these are discussed in later sections. Nodes also share a common set of Identity properties; these are discussed below. Name A node's Name property identifies it for programmatic access. Named nodes can be accessed at runtime in order to change their properties. For example, naming a print node lets you access its area property and set it according to the runtime context:
if amount < 0 { detail_output->area = "debit_entry" } else { detail_output->area = "credit_entry" }

Report nodes must be named in order to be explicitly invoked—for example, by another report or from the command line. Refer to "Naming Conventions" in Using the Editors for more information about widget naming conventions and requirements. Inherit From

Defines the source of inheritance for this report—the name of the repository report followed by the name of the parent object in this format:
repository-entry!widget-name

A node can inherit any properties that are set in its source, such as Break On and Orientation. However, nodes cannot inherit their relationships to each other as specified by their relative order in the repository entry's report structure. For more information about inheritance, refer to "Controlling Inheritance" in Using the Editors. Comments By including a brief description of a node, you can save information about this node and its purpose: 1. Select the node. 2. Under Identity, select the Comments property. The Comments dialog box opens. 3. Enter or edit text through one of these actions: ○ Type the text directly in the text area.


Choose Editor to access your local editor as defined by setup variable SMEDITOR.

○ Choose Read File to read in an external file located on your system. ○ Choose Save File to save the comments to an external file. 4. Choose OK to save the comments and return to the Properties window. Viewing Node Links You can review dependencies between a node and widgets in the layout window by selecting that node and choosing Report Show Property Links. The Property Links dialog displays, which contains two types of entries: • prop-name -> widget-name shows that this node's prop-name property is set to widget-name. For example, the links for a print node might include this entry:
Area -> distrib_name_footer

This entry shows that the print node's Area property specifies to output layout area distrib_name_footer. • prop-name <- widget shows that a widget in the layout window specifies this node in its prop-name property. If widget is an unnamed widget, it is identified as Field number. For example, the links for a detail node might include this entry:
Update In <- Tdistrib_name_qty

#n,

where n is its field

This entry shows that the detail node is referenced by total widget Tdistrib_name_qty's Update In property. Note that group and detail nodes can be linked to a total or history widget's Initialize In and Update In properties even when those properties are blank. Prolifics infers the default for these properties from the node in which the widget is output. For example, this dialog shows the links for a group node:

Figure 3-4 Property Links dialog shows the widgets that are specified in a node's properties. Note: The Property Links dialog only shows links to existing widgets; if a property specifies a widget or node that does not exist—either because it is not yet created or it is included at runtime—the dialog omits this link.
Going to a Property Link

When you display the Property Links dialog, you can give focus to the widget or node specified in the selected entry by choosing Go To, or by double-clicking on the entry. If the widget is in the layout window, this window gets focus.

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close