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:

[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 . r is given by 4 −4000 1200 1410 1875 1050 . the answer is 14. In this case. 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. For example. The convergence behaviour of the sequence is governed by the following:   If the function NPV(i) has a single real root r. If the function NPV(i) has n real roots converges. numerical methods or graphical methods must be used. there are many numerical methods that can be used to estimate r. when NPV0 > 0 or . then the sequence will converge reproducibly towards r.3%. This r can be found to an arbitrary degree of accuracy. Note that any fixed time can be used in place of the present (e. [edit]Numerical solution Since the above is a manifestation of the general problem of finding the roots of the equation NPV(r). such as in the case of a life annuity.g. the value of r cannot be found analytically.. 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 +∞. In this case. where rn is considered the nth approximation of the IRR.. Having [edit]Numerical Solution for Single Outflow and Multiple Inflows . using the secant method. Often.Note that the period is usually given in years. when NPV0 < 0 may speed up convergence of rn to r. but the calculation may be made simpler if r is calculated using the period in which the majority of the problem is defined (e. the expected values are put into the above formula.g. using months if most of the cash flows occur at monthly intervals) and converted to a yearly period thereafter.

1200.6.1 and r2 = 0. + CN .[2] [edit]Problems with using internal rate of return As an investment decision tool. Further discussion and a performance comparison of IRR estimation methods may be found in.7% (3% error) from the secant method. If applied iteratively. In this equation. but only to decide whether a single project is worth investing in. the secant method equation (see above) with n = 2 will always produce an improved estimate r3.35% (0.in and NPVn − 1. There is always a single unique solution for IRR.in = 4382.in refer to the NPV's of the inflows only (that is. Given two estimates r1 and r2 for IRR. Both the secant method and the improved formula rely on initial guesses for IRR. NPVn. This is sometimes referred to as the Hit and Trial (or Trial and Error) method.Cn ≥ 0 for n ≥ 1. either the secant method or the improved formula will always converge to the correct solution. 1410. using the stream of payments {-4000. The following initial guesses may be used: r2 = (1 + r1)p − 1 where A = sum of inflows = C1 + .3% error) as compared to IRR = 14. strictly decreasing function of interest rate. this corresponds to: C0 < 0. the calculated IRR should not be used to rate mutually exclusive projects. 1050} and initial guesses r1 = 0.in = 3570. The accurate formula estimates IRR as 14. given by: where .Of particular interest is the case where the stream of payments consists of a single outflow.1 and NPV2.2 gives NPV1. In the above notation. . In this case the NPV of the payment stream is a convex.. There is however a much more accurate estimation formula. For example. set C0 = 0 and compute NPV).. 1875. followed by multiple inflows occurring at equal periods.

The formula assumes that the company has additional projects. Since IRR does not consider cost of capital. as these strategies usually require several cash investments throughout the project. . with equally attractive prospects. the first project may have a lower IRR (expected return). 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. via IPO or M&A). especially for high IRR projects.[3] This makes IRR a suitable (and popular) choice for analyzing venture capital and other private equityinvestments. When the calculated IRR is higher than the true reinvestment rate for interim cash flows.NPV vs discount rate comparison for two mutually exclusive projects. This presents a problem. 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. 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).g.. in which to invest the interim cash flows. but a higher NPV (increase in shareholders' wealth) and should thus be accepted over the second project (assuming no capital constraints). Therefore. since there is frequently not another project available in the interim that can earn the same rate of return as the first project. but only see one cash outflow at the end of the project (e. 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. Project 'A' has a higher NPV (for certain discount rates). the measure will overestimate — sometimes very significantly — the annual equivalent return from the project. it should not be used to compare projects of different duration.

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

in present value terms. both incoming and outgoing. and accounting. the net present value (NPV) or net present worth (NPW)[1] of a time series of cash flows.is called the yield. so there is a unique rate of return for which it is zero. is defined as the sum of the present values (PVs) of the individual cash flows. and is a standard method for using the time value of money to appraise long-term projects. NPV is a central tool in discounted cash flow (DCF) analysis. the converse process in DCF analysis . Used for capital budgeting. . Similarly. 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. 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). Although the NPV-function itself is not necessarily monotonically decreasing on its whole domain. 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. Hence the IRR is also unique (and equal). Therefore NPV is the sum of all terms. it is at the IRR. and widely throughout economics. the free encyclopedia In finance.negative infinity. it measures the excess or shortfall of cash flows. in the case of a series of exclusively positive cash flows followed by a series of exclusively negative ones the IRR is also unique. and is more widely used in bond trading.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) . once financing charges are met. finance. Then they are summed. the NPV is simply the PV of future cash flows minus the purchase price (which is its own PV). Net present value From Wikipedia.

for example. 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. 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. When analyzing projects in a capital constrained environment. In such cases. and is difficult to do . For some professional investors. that rate of return should be selected as the discount rate for the NPV calculation. R0 is commonly placed to the left of the sum to emphasize its role as (minus) the investment. 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.the discount rate (the rate of return that could be earned on an investment in the financial markets with similar risk. If trying to decide between alternative investments in order to maximize the value of the firm.the time of the cash flow i . Any cash flow within 12 months will not be discounted for NPV purpose. use this discount rate in the NPV calculation to allow a direct comparison to be made between Project A and the alternative. the selection of the discount rate is dependent on the use to which it will be put. using the firm's weighted average cost of capital may be appropriate.where t . but is seldom used in practice. Refer to the tutorial article written by Samuel Baker[3] for more detailed relationship between the NPV value and the discount rate. A firm's weighted average cost of capital (after tax) is often used. It reflects opportunity cost of investment. their investment funds are committed to target a specified rate of return. a direct comparison can be made between the profitability of the project and the desired rate of return. For educational purposes. 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. it may be appropriate to use the reinvestment rate rather than the firm's weighted average cost of capital as the discount factor. the corporate reinvestment rate would probably be a better choice. To some extent.[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.the net cash flow (the amount of cash. or discounting "guaranteed" cash flows differently from "at risk" cash flows may be a superior methodology. rather than the possibly lower cost of capital. inflow minus outflow) at time t. If the intent is simply to determine whether a project will add value to the company. Related to this concept is to use the firm's Reinvestment Rate. In this way.) Rt . Using the discount rate to adjust for risk is often difficult to do in practice (especially internationally). Using variable rates over time. If. Reinvestment rate can be defined as the rate of return for the firm's investments on average. the capital required for Project A can earn five percent elsewhere. but many people believe that it is appropriate to use higher discount rates to adjust for risk or other factors.

and employee training costs). and there are no cash flows expected after year 6. The required rate of return is 10%.000 per year. strategic positioning or other factors not explicitly included in the calculation. It means. the one yielding the higher NPV should be selected.g.000 T=1 $22. All cash flows are after-tax. if Rt is a positive value. if there is a choice between two mutually exclusive alternatives. This does not necessarily mean that they should be undertaken since NPV at the cost of capital may not account for opportunity cost. the project is in the status of discounted cash inflow in the time of t. operational costs. and incoming cash flows over six years. e. This project will have an immediate (t=0) cash outflow of $100.783 . The present value (PV) can be calculated for each year: Year T=0 Cash flow Present value -$100. the project is in the status of discounted cash outflow in the time of t. This project adds no monetary value.. If. In financial theory... Then. Other cash outflows for years 1–6 are expected to be $5.727 T=2 $20. With a particular project. then discount at the firm's rate.000 each for years 1–6. 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... The new product will have startup costs.well. [edit]Example A corporation must decide whether to introduce a new product line.. Cash inflows are expected to be $30. Decision should be 0 lose value for the firm based on other criteria. Appropriately risked projects with a positive NPV could be accepted.661 T=3 $18. 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. IfRt is a negative value. [edit]NPV in decision making NPV is an indicator of how much value an investment or project adds to the firm.000 (which might include machinery. comparison with other available investments.e. i.

075 T=5 $15. and the corporation should invest in this project if there is no mutually exclusive alternative with a higher NPV. it would be better to invest in the project than to do nothing.523 T=6 $14. which equals $8.T=4 $17. Since the NPV is greater than zero.112 The sum of all these present values is the net present value.881.year_number.yearly_net_inflow)  .net_inflow)+initial_investment PV(rate.52. The same example in Excel formulae:   NPV(rate.

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

The index. All you need to be able to do is learn where to place the key "hooks" into the Joomla templating engine.org/1999/xhtml" lang="<?php echo _LANGUAGE. usually. You do not have to be a master of PHP to write a template file. 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. Future versions of Joomla will rely more and more on XML so it is wise to adopt this model now. /** ensure this file is being included by a parent file */ defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed. You are encouraged to write templates in XHTML. ?>" /> <?php if ($my->id) { initEditor(). <?php echo _ISO. } ?> <?php mosShowHead(). Within the HTML framework you place "windows" that look into the database behind your web site.org/TR/xhtml1/DTD/xhtml1-transitional. There are typically several small windows called Modules and usually one larger opening (like a frontdoor) for a Component.w3. ?> . ?>"> <head> <title><?php echo $mosConfig_sitename. ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.dtd"> <html xmlns="http://www. $iso[1] .' ).0 Transitional//EN" "http://www. it is written mostly in HTML with only a few snippets of PHP. echo '<?xml version="1. it is a well formed XML standard.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( '='. whereas HTML is a loose standard. [edit] The Layout File While the template layout file is a PHP file. While there is debate over whether XHTML *is* the way of the future. "\"?>\n". _ISO ). To see a percentage gain relative to the investments for the project.w3. Internal rate of return or other efficiency measures are used as a complement to NPV.0" encoding="' . ?></title> <meta http-equiv="Content-Type" content="text/html.

tables.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. 1 ). etc will be skipped over. We are assuming you already know a bit about HTML pages so things like head tags. ?> 25: </td> 26: </tr> 27: <tr> 28: <td colspan="3"> 29: <?php mosLoadModules ( 'top'. _ISO is a special constant defining the character set encoding to use. ?> 30: </td> 31: </tr> 32: <tr> 33: <td width="20%" valign="top"> 34: <?php mosLoadModules ( 'left' ). body tags. ?> 35: </td> 36: <td width="60%" valign="top"> 37: <?php mosMainBody().?>/templates/basic_template/css/template_css. It is defined in your language file.18: <link href="<?php echo $mosConfig_live_site. . ?> 38: </td> 39: <td width="20%" valign="top"> 40: <?php mosLoadModules ( 'right' ). Line 1-3: Defines the file as a valid XML file. ?> 46: </td> 47: </tr> 48: </table> 49: </body> 50: </html> Let's have a look at the main features. ?> 41: </td> 42: </tr> 43: <tr> 44: <td colspan="3" valign="top"> 45: <?php mosLoadModules ( 'bottom' ).

Line 37: This loads the component into your template. It is essential that you include this line in your template. named spaces whose contents are output at runtime. if you wish. page header. respectively: . Line 11: _ISO is used again to define the character set to use. This saves a little script overhead for normal browsing of your site. Line 40: This loads any modules that are published in the "right" position. defined as data. Line 12-16: $my->id is a script variable that is non-zero if a user is logged in to your site. It typically contains one or more layout areas. A layout area is defined by a layout area widget. Lines 18: Loads the CSS stylesheet. These modules will be displayed in a single column. but generally an anonymous visitor will not have the need to add content. The component is set by the URL. 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. index. Last Updated ( Tuesday. the following layout window contains three layout areas for detail. the widget's position within the layout area determines where that output appears in relation to other output from the same layout area. Line 34: This loads any modules that are published in the "left" position. For example. The layout window also contains an unnamed area whose contents are not subject to output. A layout area can only be invoked through a print node in the report structure. Introducing Report Layout The layout window defines the format and content of report output. which set the area's boundary and name. $mosConfig_live_site is a configuration variable that holds the absolute URL of your site. and page footer output. Line 45: This loads any modules that are published in the "bottom" position. Line 17: Inserts several metadata blocks. page_header. and page_footer. If a user is logged in then the nominated WYSIWYG editor is pre-loaded. always pre-load the editor. Line 10: Prints out the Site Name configuration variable with the opening and closing title tags. The second argument. Line 29: This loads any modules that are published in the "top" position.Line 5: Prevents direct access to this file. Lines 7-8: Set up the XHTML standard for the page. for example. These modules will be displayed in a single column.php? option=com_content will display the Content Component in this area. Line 24: This prints the Site Name in a table cell (spanning the three columns). 17 January 2006 ) Chapter 2 . indicates that the modules are to be aligned horizontally. A layout area outputs data through the widgets that populate it. the timing and sequence of the layout area's output depends on execution of its print node. "1". Each widget's properties determine the source and format of its data. You may.

Figure 2-1 A layout window contains layout areas and an unnamed area. Creating Layout Areas You define a layout area by creating a layout area widget: . 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.

From the Edit menu. 1. 1. Prolifics creates an unnamed layout area widget. Give the layout window focus. Point and click where you want the new area to appear in the layout window. ○ Expand All—Restores all layout areas to their full dimensions. Select the layout areas that you want to collapse or expand. Because layout areas can only be invoked by name. all layout areas occupy the entire width of the report page. ○ Collapse All—Reduces all layout areas to a single line. select the layout area widget and drag it down as far as needed. Note: Rearranging layout areas in the layout window has no effect on report output. you must first move up the widgets inside it. For information about Prolifics naming conventions. Managing the Layout Window You can modify the view of report layouts by collapsing some or all of the layout areas. ○ Move Down moves the selected areas below the areas previously below them. the unnamed area at the window's bottom is unaffected. From the Edit menu. layout area names within the same report file must be unique. Prolifics automatically restores all collapsed layout areas to full view. How to Collapse and Expand Layout Areas 1. bring up the Arrange submenu and choose the desired option: ○ Collapse—Reduces each selected area to a single line and hides its contents. Note: When you save or preview a report. Select the desired layout area widgets. bring up the Arrange submenu and choose the desired option: ○ Move Up moves the selected areas above the areas previously above them. How to Move Layout Areas 1. In both cases. You can move the layout area widget up only as far as the first widget inside that area. changing the dimensions of one layout area has no effect on the others. 1. select the layout area and drag it up. refer to "Naming Conventions" in Using the Editors. Choose Create Layout Area or the corresponding toolbox button. 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. or by changing their relative positions. you should always set a new layout area's Name property (under Identity). 1. How to Change Layout Area Dimensions • To enlarge a layout area. You can also manipulate a layout area widget in order to change the area's size. • To reduce a layout area. Like other widgets. Note: You can only change a layout area's height. ○ Expand—Restores the selected layout areas to their full dimensions. Editing Layout Area Properties .1. which defines the area between it and the layout area widget above it. To reduce the area further.

For more information about how fonts are set. Point Size. Select the layout area widget and bring the Properties window into focus. their data remains constant. 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. Start Row Specifies the layout area widget's position relative to the layout window's grid. For example. and data: . Memo Text Provides up to nine lines of text for comments or programmatic use. at runtime Prolifics resolves which fonts to apply according to what is set at a higher level. Two widget types are responsible for most report output: • dynamic output widgets get their data at runtime—for example. These properties set format and behavior parameters for the entire layout area. page_footer. from a database or from other widgets. refer to "Controlling Inheritance" in Using the Editors. Name Only named layout areas can be specified for output in the report." Populating Layout Areas In general. • static output widgets have their data set in the editor. • Top—The layout area snaps to the top of the nearest vertical coordinate. Layout area names must be unique among all other named widgets and nodes in the report file. refer to "Using Fonts. • Bottom—The layout area snaps to the bottom of the nearest vertical coordinate. Font properties Sets the default font properties—Font Name. 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 "Naming Conventions" in Using the Editorsfor more information about widget naming conventions and requirements. the following layout window contains three layout areas—page_header. and so on—for all widgets in this layout area.Each layout area has a set of properties that are described below. If the layout area's font properties are set to Default. Prolifics outputs the data of all widgets in an invoked layout area.

usually from a database. and so on.is output as the report's page header. A report that uses this layout might yield the following output: • page_header . It contains two dynamic output widgets for the report title and system date. genre. It also contains static output widgets that at runtime appear over columns of data. their values are fixed. these widgets are initially empty and get their data at runtime. • 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.

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

If Start Row properties are not the same. Prolifics might use their absolute (fixed) positions. "Creating and Using a Repository." in Application Development Guide or "Controlling Inheritance" in Using the Editors. all nodes below and subordinate to it execute in top-down order.For more information about inheritance. Edit arranging widgets. Set their Placement property (under Composition) to one of these values: • Left Float—Trim the width of the previous widget to its actual output. The actual amount of white space between widgets remains unaffected. float this widget's start position left by the number of trimmed characters. float this widget's start position right by the number of trimmed characters. Note: To make sure that widgets float towards each other. The report structure for any report is available by choosing View Report Structure. you can eliminate the unused space and thereby make their data contiguous. refer to Chapter 11. For example. when this report runs. 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. Report Structure Window The report structure window schematically shows how a report executes. The screen editor provides a number of options for aligning and spacing widgets within a layout window—for example. Positioning Widgets By default. align them horizontally so that their Start Row properties have the same value. Prolifics floats widgets only to the extent that their own widths are trimmed. This chapter focuses on report structure components and their properties. while specifications for report generation are schematically rendered in the report structure window. • Right Float—Trim leading blanks from the next widget. Align and Options Snap to Grid. For more information about Chapter 3 . The topmost node defines a report. Stages of report execution are depicted in a vertical hierarchy composed of nodes. If widgets that are on the same line are wider than the data that they actually output. the following column report sorts orders from video store outlets by distributor name and order number: . a widget's position is fixed in relation to its layout area. refer to"Arranging Widgets" in Using the Editors.

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: .

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

Table 3-1 lists the different node types and summarizes their purpose: • Table 3-1 Report structure node types Type Purpose More Information. • Action nodes are attached to a structure node and determine report output and processing for that structure node—for example.. Node Hierarchy The order of a report's structure nodes is summarized in this formula: . "Defining a Report" "Setting Page Format" "Processing One-Time Events" "Fetching Report Data" Page Format Specifies page format and orientation. Calls a function. a call node specifies a function to call. Specifies how to group data and the processing to perform when a new group is generated. Forces a page break and starts a new page. Structure nodes: Report Defines a report. "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. and so on. Instance Detail Group Action nodes: Print Call Subreport End Page Outputs a layout area. Each group node has a print node in its footer section. Invokes a subreport. Provides an all-purpose hook for one-time execution of the attached action nodes.Three group nodes are attached to the detail node. Specifies the source of report data and actions to perform at each fetch. Action nodes can be attached in any order. 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. 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. these tell Prolifics how to organize data in the report. while a detail node determines how the report gets its data. a page format node sets page dimensions and orientation..

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

Do either of the following: From the Edit menu. The copy remains in the clipboard until it is overwritten by the next Cut or Copy operation. For example. respectively. Choose Edit Delete or press the Delete key. • Press the Move Up or Move Down key. 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. The selected node and its attachments are removed from the structure and from memory. How to Paste a Node Choose Edit Paste or the Paste button from the toolbar. This places a copy of the node and its attachments in the structure's clipboard. Figure 3-3 shows how you can collapse and . 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. The logical keys for Move Up and Move Down are EXTU and EXTD. 1. To move a node elsewhere in the hierarchy. in both X and Windows. The cut node remains in the clipboard until it is overwritten by the next Cut or Copy operation. Select the node that is above the position desired for the new node. 1. • 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. Note: You can move a node up and down only within its current level in the report structure hierarchy. respectively. This places the removed node and its attachments in the structure's clipboard. These are mapped by default. choose Arrange Move Up or Arrange Move Down. • How to Copy a Node Select the node to copy and choose Edit Copy or the Copy button from the toolbar. Select the node that is above the position desired for the pasted node. or from the Edit menu.1. You can then paste the node wherever its placement is valid in the report structure. it cannot be moved anywhere else in the report structure. use Cut and Paste. Expand or Arrange Contract. How to Move a Node Select the node that you want to move. choose Arrange expand portions of the report structure. to the physical keys shift-uparrow and shift-downarrow. they can only be restored by choosing Undo. You can then paste the copy anywhere its placement is valid in the report structure.

Editing Node Properties Through the Properties window.Figure 3-3 Click on a node's type ID button to collapse and expand the view of its subordinate nodes. Refer to "Naming Conventions" in Using the Editors for more information about widget naming conventions and requirements. Each node type has one or more properties that are unique to it. Named nodes can be accessed at runtime in order to change their properties. From the Edit menu. these are discussed in later sections. 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. Nodes also share a common set of Identity properties. You can also collapse or expand the entire structure. Inherit From . give focus to the node. you can edit the properties of any selected node. by another report or from the command line. Name A node's Name property identifies it for programmatic access. 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. these are discussed below. To bring the Properties window into focus for the current node. For example. An arrow marks the selection. you can bring the Properties window forward by double-clicking on this arrow.

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.widget shows that a widget in the layout window specifies this node in its prop-name property. 3. it is identified as Field number. Comments By including a brief description of a node. ○ Choose Read File to read in an external file located on your system. ○ Choose Editor to access your local editor as defined by setup variable SMEDITOR. refer to "Controlling Inheritance" in Using the Editors. 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. Select the node. The Property Links dialog displays. For example. However. • prop-name <. nodes cannot inherit their relationships to each other as specified by their relative order in the repository entry's report structure. Prolifics infers the default for these properties from the node in which the widget is output. select the Comments property. where n is its field This entry shows that the detail node is referenced by total widget Tdistrib_name_qty's Update In property. 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. 4. For more information about inheritance. Choose OK to save the comments and return to the Properties window.Tdistrib_name_qty #n. the links for a detail node might include this entry: Update In <. The Comments dialog box opens. 2. you can save information about this node and its purpose: 1. Under Identity. which contains two types of entries: • prop-name -> widget-name shows that this node's prop-name property is set to widget-name.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. ○ Choose Save File to save the comments to an external file. For example. If widget is an unnamed widget. such as Break On and Orientation. Enter or edit text through one of these actions: ○ Type the text directly in the text area. For example. this dialog shows the links for a group node: .

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.Figure 3-4 Property Links dialog shows the widgets that are specified in a node's properties. Going to a Property Link When you display the Property Links dialog. 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. . this window gets focus. Note: The Property Links dialog only shows links to existing widgets. If the widget is in the layout window.

Sign up to vote on this title
UsefulNot useful