text
stringlengths
0
5.42k
source
stringclasses
1 value
Writing Remote Com pliant TDL Reports 192 Example: [Report : Final Led Report] Form : Final Led Report Fetch Object : Ledger : Ledger Name : Name,Ledger Contact,+ Ledger Phone,TBal Opening, TBal Closing 7. 2 Repeating Lines over a Collection The following techniques are used to optimize the performance, when a line is repeated over a collection in a report to be displayed on the client. Fetching the Methods Whenever a collection is referred to in a Report, the required methods need to be explicitly fetched from the server. It is mandatory to specify 'Fetch' in the Collection for all t he methods which are used in the fields. If 'Fetch' is not used, then the data will not be displayed in the field. [Part : Led Report] Line : Led Report Details Repeat : Led Report Details : Ledger Scroll : Vertical [Line : Led Report Details] Fields : Led Name Right Field : Led Closing Balance [Field : Led Name] Use : Name Field Set as : $Name [Field : Led Closing Balance] Use : Amount Forex Field Set as : $Closing Balance [#Collection : Ledger] Fetch : Name, Closing Balance Function inside the 'Repeat' When Lines are repeated over a Collection and a function is use d at the field level, then each 'Repeat' will trigger an additional server request for function call. In this scenario, the entire function call logic can be moved to ' Compute ' of the repeated Collection. The later approach will do only one server request. Hence, performance is drastically i mproved.
TDL_Reference_Manual.pdf
Writing Remote Compliant TDL Reports 19 3 [Part : Led Report] Lines : Led Report Details Repeat : Led Report Details : Ledger Scroll : Vertical [Line : Led Report Details] Fields : Led Name Right Fields : Led Closing Balance, Led Sales Total [Field : Led Name] Use : Name Field Set as : $Names [Field : Led Closing Balance] Use : Amount Forex Field Set as : $Closing Balance [Field : Led Sales Total] Use : Amount Forex Field Set as : $Ledger Sales Total [#Collection : Ledger] Fetch : Name, Closing Balance Compute : Ledger Sales Total : + $$As Req Obj : $$Filter Amt Total : Led Vouchers : My Party : $Amount Repeating over Period Collection In Reports where lines are repeated over Period Collection and values of each column is calculated over a period for the required object, e. g., in Sale s Register, value of each column is calculated based on a period and object Voucher Type. In this scenario, an additional computational method needs to b e added to the Period Collection to fetch the values for each column. [#Collection : Period Collection] Compute : TBal Debits : $TBal Debits : Voucher Type : #Voucher Type Name Compute : TBal Credits : $TBal Credits : Voucher Type : #Voucher Type Name Compute : TBal Closing : $TBal Closing : Voucher Type : #Voucher Type Name
TDL_Reference_Manual.pdf
Writing Remote Com pliant TDL Reports 194 7. 3 Using the same Collection in more than one Report When more than one Report requires different methods of the Obj ects of the same Collection, then using the same collection with all the methods fetched in it reduces the performance. This can be improved in the following ways: Fetching the required methods locally at Report In the following code snippet, Sample Report1 requires Opening Balance of a Ledger whereas Sample Report2 requires Closing Balance. Instead of modifying the Collection to fetch both Opening Balance and Closing Balance, the same is localized in r espective Reports. [Report : Sample Report1] Local : Collection : Ledger : Fetch : Opening Balance [Report : Sample Report2] Local : Collection : Ledger : Fetch : Closing Balance Separate Collections for fetching different methods In the following code snippet, two Collections are created for fetching the opening balance and the closing balance. Later, the first Collection can be utilize d in Sample Report1 and the second one in Sample Report2. [Collection : Fetch Opening Balance] Type : Ledger Fetch : Opening Balance [Collection : Fetch Closing Balance] Type : Ledger Fetch : Closing Balance
TDL_Reference_Manual.pdf
195 General and Collection Enhancements Introduction In T ally. ERP 9, major changes have been provided by the platfor m to enhance the TDL capabilities to help the programmer to develop and deploy solut ions with ease. Major improvements have taken place in terms of language usage standardisation and perf ormance improvements. There have been breakthrough enhancements at Collection level t o provide Remoting and Advanced Reporting capabilities. Collection is now a complete D ata Processing Artefact in TDL. This chapter provides in depth knowledge of the various enhance ments in attributes, modifiers, method formula syntax and symbol prefixes. The foremost focus i s towards the enhancements at the collection level for providing the capabilities for aggrega tion, usage as tables, XML collection and dynamic object creation support for HTTP-XML based informat ion interchange. 1. Definition, Attribute and Modifier Enhancements In T ally. ERP 9, new attributes and modifiers have been introduced to support t he new capabilities. The behaviour of some of the existing attributes and modifiers has also changed. 1. 1 Attribute Enhancements New Attributes New attributes that have been introduced are explained in this section. Field Attribute-Set By Condition The attribute Set By Condition is similar to a conditional 'Set' at Field level. If multiple ' Set By Condition' are mentioned under a Field, then the last satisfied Set By Condition will be executed. Syntax Set By Condition : <Condition> : <Value> Where, <Condition> is any logical formula. <Value> is any string or a formula. Example: [Field : Sample Setby Condition] Set as : “Default Value” Setby Condition : ##Condition1 : "Set by Condition 1" The Field Sample Setby Condition will contain the value 'Set by Condition1' if the expression Condition1 returns TRUE, else the Field will contain the value 'Default V a lue'.
TDL_Reference_Manual.pdf
General and Collection Enhancements 196 Field Attribute-Tool Tip As the name suggests, the value specified with this attribute is displayed when the mouse pointer is placed on a particular field. This means that, in addition t o the static information displayed by 'Info' or 'Set As' attributes, we can provide additional meanin gful information using this attribute. In other words, when the user hovers the mouse pointer over the Field, a small hover box appears with supplementary information regarding the item being pointed over. As against attributes 'Info' or 'Set As', this attribute value is independent of the Field W idth. Syntax Tool Tip : <Value> Where, <Value> can be a String or a Formula. Example: [Field : Led Name] Storage : Name Tool Tip : “Please Enter the Name of the Ledger” Report Attribute-Full Screen It helps to control the display of command window/calculator pa ne. It is a logical type of attribute. Syntax Full Screen : Yes/No If it is set to YES, the command window will be hidden, providi ng extra space when the report is displayed. The default value of this attribute is YES. In case of Sub-Report/Auto Report, if the value of this attribute is not specified, the default value is NO. Example: [Report : My Report] Full Screen : Yes Part Attribute-Retain Focus It indicates that the part should retain information about the line which is currently in focus, even if the focus is moved to other part. This allows the part to make the same line as the current line when it gets back the focus. Syntax Retain Focus : Yes/No Example: [Part : Led Part] Retain Focus : Yes
TDL_Reference_Manual.pdf
General and Collection Enhancements 19 7 Part Attribute-Default Line It is used to highlight the appropriate line which satisfies th e given condition. All the methods of the object associated with the line can be used while specifyin g the condition. Syntax Default Line : <Condition> When the Report is invoked, the Line for which the condition is TRUE, is highlighted by default. Example:If the Line is repeated over the collection of Legers, then the following code will highlight the line of Cash Ledger. [Part : The Main Part] Default Line : $Name = “Cash” Collection Attribute-Sub Title Along with the T able title, sub titles for the columns can also be given. The attribute 'S ub Title' has been introduced in the 'Collection' definition for the same. Syntax Sub Title : <List of Comma Separated Strings> Where, <List of Comma Separated Strings> are Strings separated by comma, with respect to the number columns. 'Sub Title' is a List type attribute. Example: [Collection : Debtors Led Table] Type : Ledger Child Of : $$Group Sundry Debtors Format : $Name, 15 Format : $Opening Balance, 10 Title : $$Locale String : "Table Sub-Titles" Sub Title : $$Locale String : "Name" Sub Title : $$Locale String : "Op. Balance" It displays a table with two columns. Column titles are also di splayed, using attribute Sub Title. Instead of using Sub Title attribute multiple times, a comma se parated list can be given as follows: Sub Title : $$Locale String : "Name", $$Locale String : "Op. Balance"
TDL_Reference_Manual.pdf
General and Collection Enhancements 198 Behavioural Changes of Attributes Enhancements have been done in the behaviour of the following a ttributes: Attributes 'Set As' and 'Info' As of Release 2. x, the attributes 'Set as' and 'Info' were trea ted as the same attribute with aliases. When 'Info' was used, it had a special Skip and Prompt privileg e. If both were specified, the last specification would override the previous specification and wou ld be the effective specification. T ally. ERP 9 onwards, this behaviour has been modified to treat both as individual attributes. When both these attributes are specified in a field, 'Info' tak es precedence and 'Set as' is ignored. Attribute 'Format' When a collection is a union of collections, the 'Format' attri bute in the collection behaves as a place holder for the columns. It is mandatory to specify 'Forma t' attribute in individual collections, when a collection is a union of collections. Example: [Collection : Led Table] Collection : Debtors Led Table, Creditors Led Table Format : A, 20 Format : B, 25 Here, A and B act as dummy identifiers, and the second paramete r is width. The collections Debtors Led T able and Creditors Led T able are defined as follows: [Collection : Debtors Led Table] Type : Ledger Child Of : $$Group Sundry Debtors Format : $Name, 15 Format: $State Name, 15 [Collection : Creditors Led Table] Type : Ledger Child Of : $$Group Sundry Creditors Format : $Name, 15 Format : $State Name, 15 It displays a table of two columns. The width of first column i s 20 and of second column is 25. Attribute 'Sync' The behaviour of the attribute 'Sync' of 'Part' definition is c hanged. The first line of next part is selected, as the default of Sync attribute is now set to NO. If the Part further contains parts, then the value of Sync attribute specified at Parent level overrides the value specified at child level.
TDL_Reference_Manual.pdf
General and Collection Enhancements 19 9 Example: [Part : Main Part] Parts : Sub Part1, Sub Part 2 Sync : Yes [Part : Sub Part 1] Sync : No [Part : Sub Part 2] Sync : Yes As a result of the default value of 'Sync' attribute being set to NO, in the above code snippet, the Sync attribute finally has the value as YES. Attribute 'Child Of'-to support Voucher Type 'Child Of' attribute is enhanced further to support Voucher Typ e. Now, a Collection of Vouchers of a particular Voucher Type can be constructed. Prior to this relea se, the same could be achieved by applying Filters to the Collection. But, the enhanced approach will improve the performance. Further, the Collection attribute 'Belongs T o' can be used in a ddition to 'Child of', to construct the Collection of Vouchers of a particular pre-defined Voucher Type, including related user-defined Voucher Types. Syntax [Collection : <Coll Name>] Type: Vouchers : Voucher Type Childof : <String Formula> Belongs To : <Logical Value> Where, <Coll Name> is the name of the Collection. <String Formula> can be a formula which results into the name of the Voucher Typ e <Belongs T o> is an optional attribute, which if used, takes <Logical Value>,i. e., YES or NO. Example: 1 [Collection : Sales Vouchers] Type : Voucher Type Child of : $$Vch Type Sales 'Sales Vouchers' is a collection of Vouchers, whose Voucher Typ e is the predefined voucher type 'Sales'.
TDL_Reference_Manual.pdf
General and Collection Enhancements 200 Example: 2 [Collection : Sales Vouchers] Type : Voucher Type Child of : $$Vch Type Sales Belongs To : Yes 'Sales Vouchers' is a Collection of Vouchers, whose Voucher Typ e is pre-defined voucher type 'Sales', or any other user defined Voucher Type whose 'Type of Voucher' is 'Sales'. 1. 2 Modifier Enhancements In TDL, attribute modifiers are classified as Static/Load time or Dynamic/Run-Time modifiers. Use, Add, Delete, Replace/Change are Static/Load Time modifiers. Option, Switch and Local are Run Time modifiers. The sequence of evaluation is generalized ac ross all the definitions in TDL. Sequence of Attribute Evaluation:1. Use 2. Normal Attributes 3. Delayed Static/Load Time modifier 4. Dynamic/Run-Time modifier New Modifiers Modifier-Switch A new attribute modifier 'Switch' has been incorporated from T a lly. ERP 9 onwards. This attribute is similar to the 'Option' attribute, but reduces code complexi ty and improves the performance. The modifier 'Option' compulsorily evaluates the conditions for a l l t h e o p t i o n s p r o v i d e d i n t h e description code, and applies all the option statements which s atisfy the evaluation conditions. This means that it is not easy to write the code where you just want one of the options to be applied. Y ou have to make sure that other options are not applied using a negative condition. The new attribute modifier 'Switch' has been provided to support th ese types of scenarios, where evaluation is carried out only up to the point where the first evaluation process has been cleared. Apart from this, 'Switch' statements can be grouped using a lab el. Therefore, multiple switch groups can be created and zero or one of the switch cases would be applied from each group. Syntax Switch : <Label> : <Definition Name> : <Condition> Switch : <Label> : <Definition Name> : <Condition> If multiple 'Switch' statements are mentioned within a single d efinition, then the evaluation will be carried out up to the point where the first condition is satisf ied for the given label. Example: 1 [Field : Sample Switch] Set as : "Default Value"
TDL_Reference_Manual.pdf
General and Collection Enhancements 20 1 Switch : Case1 : Sample Switch1 : ##Sample Switch1 Switch : Case1 : Sample Switch2 : ##Sample Switch2 Here, out of multiple switch statements having same label, zero or one statement is executed. Example: 2 [Field : Sample Switch] Set as : "Default Value" ;; If none of the condition is TRUE then Field will have Default Value Switch : Case1 : Sample Switch1 : ##Sample Switch1 Switch : Case1 : Sample Switch2 : ##Sample Switch2 Switch : Case2 : Sample Switch3 : ##Sample Switch3 Switch : Case2 : Sample Switch4 : ##Sample Switch4 Here, multiple switch groups are created, and zero or one of th e switch cases would be applied from each such group or label. Behavioral Changes for Attribute Modifiers The behaviour of the following attribute modifiers has been enh anced. Changed precedence of Use Behaviour of the attribute 'USE', which is used to inherit the properties from other definitions, has now changed. Irrespective of the order of specification of attr ibutes within a definition, USE will be evaluated first. In other words, the order in which USE is spec ified is immaterial, as in any case, it will be evaluated first. If multiple USE attributes are specified in a single definitio n, they are evaluated in the order of their occurrence. Example: [Field : Attr Use1] Set as : "This shows the changed behavior of 'Use' attribute" Style : Large Bold Use : Name Field The Field Attr Use1 uses existing Field Name Field. Since USE is having higher precedence over other attributes, Field Attr Use1 will inherit all the attributes of Name Field. But, the style Large Bold at the Field Attr Use1 will override the inherited Style within the Field Name Field. Changed behaviour of Delayed Attribute Modifiers “Add/Delete/Replace” Static/Load Time modifiers like Add, Delete and Replace can be called as Delayed Attribute modifiers, as they are having least precedence among Delayed St atic/Load Time modifiers. Now these modifiers are generali zed across all definitions. Ear lier for definitions Report, Key, Color, Style, Border and Variable, the delayed attributes were applied in their sequence of
TDL_Reference_Manual.pdf
General and Collection Enhancements 202 appearance in the definition description. If more than one delayed attribute is used under any definition, then the attributes will be applied as they appear. This has been done to bring consistency across the definitions. Example: 1 [Report : Test Report] Form : Form1Delete : Form Form : Form2 The report T est Report won't have any Form, as the attribute 'Delete', which is evalua ted last, deletes all the existing forms. Example: 2 [Report : Test Report1] Form : Form1 Delete : Form Add : Form : Form2 As a result of this code snippet, the Report T est Report1 will have one Form Form2, since, on deletion of all the Forms, Delayed attribute modifier Add is used to add a new Form Form2. Enhanced Syntax of Delayed Attribute “Local” Delayed attribute modifier 'Local', which is used to locally mo dify the attributes of any child definition, is now enhanced to accept nested Locals. Syntax Local : <Definition Type1> : <Definition Name1> [: <Definition Type2> + : <Definition Name2> :... ] : <Attribute> : <Value> Where, <Definition T ype> can be a Form, a Part, a Line or a Field. <Definition name> is the name of the definition type. <Attribute> is the attribute of the Definition of which, the value needs to be altered, and <Value> is the value assigned to this attribute within the current Repo rt or Form or Part or Line. Example: [Report : Custom Report] Local : Line : Title Line : Local : Field : Amt Field :Set as : “Sales Amount” The Field Amt Field is localized at the Report Custom Report, by using nested locals.
TDL_Reference_Manual.pdf
General and Collection Enhancements 20 3 1. 3 Behavioral change in System Definitions System Definitions overriding without '#' are treated as warnin gs now, instead of errors. #, ! or * modifications to [System : Menu Keys], [System : Form Keys], [Sy stem :Formula] and [System:UDF] were shown as errors. They have now been converted to warnings. In T ally. ERP 9, overriding System Formula/V ariable, without pre fixing a # have been treated as an Error. The usage of #, * and ! prefix to System Definitions like Menu Keys, Form Keys and UDF were not allowed and treated as errors. Many existing Codes have stopped working due to this behavioral change. Hence, in order to maintain backward compatibility, these have been enabled & treated as warnings and in some cases ignored, so that existing TDL Codes continue to work, wit hout any changes required for the same. These warnings are thrown only by the compiler, during the compilation using TD9. However, it is advisable to use # for existing System Formula alteratio n, and refrain from using # for System Menu Keys, Form Keys and UDF Definition, or using ! for any system descriptions. 1. 4 Partial Attribute Support Prior to T ally. ERP 9, all descriptions supported partia l search on their attribute w ords. For example, 'Set as' could have been written as Set a, Set or Se, which wou ld allow minimum number of characters to be present to an extent where another attribut e does not start with those characters. This behaviour is now removed as it is not practical to use par tial words. But, multiple aliases are now supported to allow meaningful attribute names. Example: 'Set as' can be written as 'Set' 'Float Bottom Lines' at Part Definition can be written as 'Floa t' 'T op Part' can be written as 'Part', 'Parts' or 'T op Parts' Since these aliases have been introduced, most of the existing TDL will work without any changes. In case of Partial words /Non-meaningful words used in any TDL, T ally would throw an error, which needs to be corrected in TDL. 1. 5 Change in usage of 'BLANK' Keyword in Menu Items T o insert empty line between Menu Items, BLANK keyword was used. Also 'Item' Attribute without any "V alue" used to be considered as BLANK prior to T ally. ERP 9. For consistency in TDL coding, the later is now disallowed. Only BLANK keyword can now be used to indicate empty Menu Item. 2. Enhanced Special Symbols In T ally. ERP 9, some new symbols have been introduced and the b ehaviour of the definition modifier '#' has been enhanced. 2. 1 Multi-line commenting in T DL source code u sing /* and */ Multi-line commenting is a new feature in this release, which r enders the TDL code more user-friendly and easy to maintain. A simple Multi-line comment woul d look like: /* <Comment Line 1><Comment Line 2> */
TDL_Reference_Manual.pdf
General and Collection Enhancements 204 2. 2 Extension of modifying definitions using # Scope of modifying definitions using # is extended to System Fo rmula definition, that is, to alter the value of the existing system formula. It helps to improve the p erformance with optimized formulae. Example: [#System : Formula] Name Width : 40 Max Name Width : 60 Here, the values specified to Formulae Name Width and Max Name Width in Def TDL, are changed. 2. 3 '*' (Reinitialize) Definition modifier The definition modifier “*” overwrites the existing content of definition. The “*” modifier is very useful when there is a need to completely replace the existing definition content with a new code. Syntax [*<Definition Type> : <Definition Name>] Example: [Field : Sample Re Initialize] Info : "Original Value" Style : Large Bold Color : Blue [*Field : Sample Re Initialize] Info : "Re Initialized-All the attribute values deleted + & newlydefined" Lines : 1 3. Method Formula Syntax with Relative Object Specification '$' operator has been enhanced with new capabilities. It allows d irect access to any object method, including its sub-collections to any level, with a dott ed notation framework. Using this new capability, there is no need to repeat a line over a sub-collection to acc ess it. V alues from any object, anywhere, can be accessed without making the object as the current object in context. Suffixing of Primary Obj Type : Obj Name Formula is still supported for backward compatibility. I n cases where both are specified, the enhanced new primary object specification will be considered. The earlier syntax to access a Method was: $Method Name OR $Method Name : Primary Obj Type : Obj Name Formula
TDL_Reference_Manual.pdf
General and Collection Enhancements 20 5 The enhanced method formula Syntax has been introduced to suppo rt access out of the scope of the Primary Object and to access Sub object at any level using (. ) dotted notation with index and condition support. The new enhanced syntax is: $<Primary Object Spec>. <Sub Object Path Spec>. Method Name Where, <Primary Object Spec> can be (<Primary Object Type Keyword>, <Primary Object Identifi er Formula>) <Sub Object Path Spec> is given as Collection Name [<Index Formula>, [<Condition>]] <Method Name> refers to the name of the method in the specified path. <Index Formula> should return a number which acts as a position specifier in th e Collection of Objects satisfying the given <condition>. Example: Following are evaluated assuming Voucher as the current object 1. T o get the Ledger Name of the first Ledger Entry from the cur rent Voucher, Set as : $Ledger Entries[1]. Ledger Name 2. T o get the amount of the first Ledger Entry on the Ledger 'Sa les' from current voucher, Set as : $Ledger Entries[1,@Ledger Condition]. Amount Ledger Condition : $Ledger Name = “Sales” 3. T o get the first Bill Name of the first Ledger entry on the P arty Ledger from the current voucher, Set As : $Ledger Entries[1,@@Ledger Condition]+ . Bill Allocations[1]. Name Ledger Condition : $Ledger Name = @@Inv Party Name 4. T o get the Opening Balance of the first Bill for the Party, Acme Corp, Set As : $(Ledger,@@Party Ledger). Bill Allocations[1]+ . Opening Balance Party Ledger : “Acme Corp” Primary Object specification is optional. If not specified, the current object will be considered as primary object. Sub-Collection specification is optional. If no t specified, methods from the current or specified primary obj ect will be available. Index specifies the position of the Sub-Object to be picked up from the Sub-Collection. Condition is the filter whic h is checked on the objects of the specified Sub-Collection. <Primary Object Id entifier Formula>, <Index Formula> and Condition can be a value or formula. <Index Formula> can be any formula evaluating to a number. Positive Number indi cates a forward search and negative number indicates backward search. T his can also be keyword First or Last which is equivalent to specifying 1 or-1 respectively.
TDL_Reference_Manual.pdf
General and Collection Enhancements 206 If both Index and Condition are specified, the index is applica ble on the Object(s) which satisfy the condition, so one gets the nth Object which clears the conditio n. Let's say for example, if the Index specified is 2 and Condition is Name = “Sales”, then the second object which matches the name Sales will be picked up. Primary Object Path Specification can either be relative or abs olute. Relative Path is referred using empty parenthesis () or Dotted path to refer to the Paren t object relatively. SINGLE DOT denotes the current object, DOUBLE DOT the Parent Object, TRIPLE DOT the Grand Parent Object, and so on, within an Internal Object. Absolute Path ref ers to the path in which the Primary Object is explicitly specified. T o access the Methods of Primary Object using Relative Path fol lowing syntax is used: $(). Method Name or $..Method Name or $... Method Name Example: Being in the context of 'Ledger Entries' Object within the 'Vouc her' Object, the following has to be written to access the Date from its Parent Object, which is the 'Voucher' Object. $..Date T o access the Methods of Primary Object using Absolute Path: $(Ledger, “Cash”). Opening Balance 4. Enhancements-Object Association In TDL, any Interface object exists in the context of any data object. Every Interface object needs to be associated with some data object. In the absence of any e xplicit object association, Interface object will get associated with 'Anonymous' object. TDL program mer can explicitly associate Interface objects like Report, Part, Line and Field with a data object. In T ally. ERP 9, Object association has become more natural and simpler. 4. 1 Report Level Ob ject Association A Report normally will be associated with a data object, which it gets from the previous Report, or will be associated with anonymous object. From Tally. ERP 9 onwards, the syntax for association has been e nhanced to override the default association as well. The Report attribute 'Object' has been enh anced to take an additional optional value 'Object Identifier Formula'. Syntax Object : <Object Type> [: <Object Identifier Formula>] Where, <Object T ype> is the Type of any Primary Object, and <Object Identifier Formula> is any formula which evaluates to the name of a Primary Object. It is optional.
TDL_Reference_Manual.pdf
General and Collection Enhancements 20 7 Example: Prior to Tally. ERP 9 [#Form : Sales Color] Delete : Print Add : Print : New Sales Format [Report : New Sales Format] Object : Voucher Default 'Sales color' Form is modified to have new print format 'New Sales Format'. This Report gets the 'Voucher' object from the previous Report. Example: In Tally. ERP 9 [Report : Sample Report] Object : Ledger : “Cash” Ledger 'Cash' is associated to the Report 'Sample Report'. Now, the components of 'Sample Report', by default, inherit this ledger object association. 4. 2 Part Level Object Association By default, Part inherits the Object from Report/Part/Line. Thi s can be overridden in two ways: Using 'Object' attribute specification in 'Part' definition. Syntax: Prior to Tally. ERP 9 Object : <Supplier Collection> : <Seek Type Keyword> [:<Seek Condition>] Where, <Supplier Collection> is the name of the Collection of secondary Objects. <Seek T ype Keyword> can be First or Last, which denotes the position index, and <Seek Condition> is a filter condition to the supplier collection. It is optional. Example: Part in the context of Voucher Object [Part : Sample Part] Line : Sample Line Object : Inventory Entries:First:@@Stk Name Filter Scroll : Vertical [System : Formula] Stk Name Filter : $Stock Item Name = "Tally Developer” The first inventory entry which has the stock Item “T ally Devel oper” is associated with the Part 'Sample Part'.
TDL_Reference_Manual.pdf
General and Collection Enhancements 208 Using 'Object Ex' attribute specification in 'Part' definition From T ally. ERP 9 onwards, data object can be associated to Part by using the new attribute 'Object Ex'. Now, even Primary Object can also be associated to a Part, which wa s not possible in the earlier Part level data object association. Also, data Obje ct associated to some other Interface Object can also be associated to a Part. This aspect will be el aborated in the section “Object Access via Interface Object”. Syntax: In Tally. ERP 9 Object Ex : <Method Formula Syntax> Where, <Method formula syntax> is, <Absolute Spec>. [<Sub Object Spec>] <Absolute Specification> is (<Object Type>, <Object Identifier Formula>). If only Absolute Spec is given, it should end with dot ('. '). <Sub Object Specification> is Collection Name[Index,<Condition>]Example: 1 [Part : Sample Part] Object Ex : (Ledger, "Customer 1"). Ledger object “Customer 1” is associated to the Part 'Sample Pa rt'. Since only absolute specification is used, the Object specification ends with '. '. Example: 2 [Part : Sample Part] Object Ex : (Ledger,"Customer"). Bill Allocations [1,@@Condition1] [System : Formula] Condition1 : $Name = "Bills 2" Secondary Object 'Bill Allocations' is associated with the Part 'Sample Part'. 4. 3 Line Level Object Association An object can associated to a Line by Part attribute “Repeat'. Now, the Part attribute 'Repeat' has been enhanced to support the following: a. Extraction of collection from any Data object b. Extraction of collection from Interface Object associated Dat a object. This aspect will be elaborated in the section “Object Access via Interface Object”. Repeat Syntax: Prior to T ally. ERP 9 Repeat : <Line Name>: <Coll Name>: [<Supplier Coll>+ :<Seek Type Keyword>:<Seek Condition>] Where, <Coll Name> is the name of the Collection. If the Collection is present one level down in the object hierarchy, then the Supplier Collection needs to be mentioned.
TDL_Reference_Manual.pdf
General and Collection Enhancements 20 9 <Supplier Collection> is the name of the Collection of secondary Objects, <Seek T ype Keyword> can be First or Last, which denotes the position index, and <Seek Condition> is an optional value and is a filter condition to the supplier collection. Example: Part in the context of Voucher Object [Part : Sample Part] Line : Sample Line Repeat : Sample Line : Bill Allocations:Ledger Entries : First : + @@Led Formula [System : Formula] Led Formula : $Ledger Name = “Customer” The Line 'Sample Line' is repeated over Bill Allocations of first object of ledger entries which satisfies the given condition. In T ally. ERP 9-Repeat Syntax Repeat : Line Name : Method Formula Syntax [:Supplier Collection : + Seek Type Keyword : Seek Condition] Where, <Method Formula Syntax> is <Absolute Spec>. <Sub Object Spec> <Absolute Spec> is (<Object Type>, <Object Identifier Formula>) <Sub Object Spec> is Collection Name[Index,<Condition>] and Supplier Collection syntax is provided just for the backwar d compatibility. Example: [Part : Sample Part] Line : Sample Line Repeat : Sample Line : (Ledger, “Customer”). Bill Allocations 4. 4 Field Level O bject Association By default, a field inherits the object from the parent line or Field (if field inside a field). This cannot be overridden. However Field also allows Object specification s yntax. This association, if specified, acts as the 'Secondary Context Object' for the Field. During any formula evaluation, if the formula/method fails in the context of primary object, the seco ndary object is tried then.
TDL_Reference_Manual.pdf
General and Collection Enhancements 210 5. Enhancements-Object Access via Interface Object From T ally. ERP 9 onwards, data objects in association with Inte rface objects can be accessed using the new Interface object access syntax. Data object, whic h is associated to Interface Object, can be accessed with the following 2-step procedure: 1. Identifying Part and Line Interface object with 'Access Name' 2. V alue/Collection Extraction 5. 1 Identifying Part and Line I nterface object with 'Access Na me' Part and Line can be identified by a unique access name. For th is purpose, a new attribute 'Access Name' is introduced for 'Part' and 'Line' definitions. Syntax Access Name : Access Name Formula Where, <Access Name Formula> can be a formula which evaluates to a string. Example: 1-Access Name at Part Definition [Part : Sample Part] Line : Sample Line1 Access Name : “Sample Part” Example: 2-Access Name at Line Definition [Line : Sample Line] Field : Sample Fld1, Sample Fld2 Access Name : "Repeated Line" + $$String:$$Line When Line 'Sample Line' is repeated over a collection, every Li ne is identified by a unique Access Name. 5. 2 Value Extraction Once Part and Line Interface objects are able to uniquely ident ify by 'Access Name', then the data object can be accessed by either the new function $$Object Of or 'New method formula syntax'. Value Extraction by function $$Object Of Methods of data object, which is associated to Interface Object, can be extracted by using the function $$Object Of. Syntax $$Object Of : <Definition Type> : <Access Name Formula> : <Evaluation Formula> Where, <Definition T ype> may be 'Part' or 'Line' <Access Name Formula> is a string through which a Part or Line can be uniquely identi fied, and
TDL_Reference_Manual.pdf
General and Collection Enhancements 21 1 <Evaluation Formula> is a method that needs to evaluated. Example:Line 'Sample Line' has Access Name as 'Sample Acc Name' and is in association with Ledger Object. [Field : Sample Field] Set as : $$Objectof : Line : ”Sample Acc Name” : $Name Field 'Sample Field' displays the name of the object Ledger whi ch is associated with a Line whose access name is “Sample Line Acc Name”. Value Extraction by using new method formula Methods of data object, which is associated to Interface Object, can also be extracted by using new method formula. With this approach, sub object's methods ca n be extracted. Example:Line 'Sample Line' has Access Name as 'Sample Acc Name' and in association with Ledger Object. [Field : Sample Field] Set as : $(Line,“My Line Access Name”). Bill Allocations[1]. Opening Balance Field 'Sample Field' displays the name opening balance of a led ger which is associated with a Line whose access name is “Sample Line Acc Name”. Repeat Syntax Using Access Name Collection inside the data object, which is associated to the I nterface Object, can be extracted by using the new method formula. Syntax-Enhanced Repeat Repeat : Line Name : Method Formula Syntax [:Supplier Collection : + Seek Type Keyword : Seek Condition] Where, <Method Formula Syntax> is <Absolute Spec>. <Sub Object Spec> <Absolute Spec> is (<Object Type>, <Object Identifier Formula>)<Sub Object Spec> is Collection Name[Index,<Condition>]and Supplier Collection syntax is provided just for the backwar d compatibility. Example: [Part : Sample Part] Repeat : Sample Line:(Part, “My Part Access Name”). Inventory Entries Part having access name 'My Part Access Name' is under the context of 'Voucher' Object. We can repeat a line “Sample Line” over Inventory Enries of the Vouche r Object, which is associated with the Part having the access name “My Part Access Name”
TDL_Reference_Manual.pdf
General and Collection Enhancements 212 6. Bracket support in TDL Prior to T ally. ERP 9, usage of TDL language token bracket ('(' and ')') was restricted as mathematical operator only. From this release onwards, brackets can be used in following scenarios: 1. During the function call to enclose the function parameter 2. In the language syntax for nesting formulas 3. As a Mathematical Operator 6. 1 During the Function Call Prior to T ally. ERP 9, when a parameter for a function required expression and that expression contained any language token, then the TDL programmer was forced to replace the expression b y a formula. This can now be achieved by enclosing the expression in a bracket. The expression inside the bracket is evaluated first and the result is used as the parameter for the function. Nesting can be performed up to any level. Brackets can also be used in places where the function parameter expects an identifier or a constant value. Example: 1Field 'Sample Fld' displays the first 5 characters of currently loaded Company's email address. Prior to T ally. ERP 9In this case, the First parameter to the function $$String Part is an expression that contains the language token ':'. So, a formula needs to be created. [Field : Sample Fld] Set As : $$String Part : @Cmp Email Address : 0 : 5 Cmp Email Address : $Email : Company : ##SVCurrent Company In T ally. ERP 9 [Field : Sample Fld] Set As : $$String Part : ($Email:Company : ##SVCurrent Company) : 0 : 5 Example: 2 If the last object in the collection 'Ledger' is a Sundry Credi tor, then the Field 'Sample Fld' will have logical value YES else NO. Prior to T ally. ERP 9In this case, the condition contains language token ':' and con stant value '-1'. So, a formula needs to be created. [Field : Sample Fld] Set as : $$Collection Field : @@Group Check : @@Index Position : Ledger [System : Formula] Group Check : $Parent:Ledger:$Name = $$Group Sundry Creditors
TDL_Reference_Manual.pdf
General and Collection Enhancements 21 3 Index Position :-1 In T ally. ERP 9 [Field : Sample Fld] Set As : $$Collection Field:($Parent:Ledger:$Name = + $$Group Sundry Creditors):(-1):(Ledger) 6. 2 In the language synt ax for nesting formulas Prior to T ally. ERP 9, whenever an expression was a part of lang uage syntax, language tokens were not permitted. This restriction led to the necessity of ad ditional formulas, even when the formulas were not used more than once. With this enhancement, expressions can be used in language synt ax by enclosing them in brackets. Brackets can also be used when attribute value expects identif ier or constant value. Example: 1If the given condition is satisfied, then the Field 'Sample Fld ' will display “Cash Accounts” Prior to T ally. ERP 9In this case, the condition contains language token ':'. So, a formula needs to be created. [Field : Sample Fld] Set By Condition : @Is Ledger Is Cash : "Cash Accounts" Is Ledger Is Cash : ($Name:Ledger:##SVLedger) = "Cash" In T ally. ERP 9 [Field : Sample Fld] Set By Condition : ($Name : Ledger : ##SVLedger)= "Cash" : "Cash Accounts" Example: 2 [Part : Sample Part] Line : Sample Line Repeat : (Sample Line) : My Collection First parameter for 'Repeat' attribute is using bracket for ide ntifier. 6. 3 As a Mathematical Operator In TDL, brackets are used as mathematical operator to set the p recedence of evaluation. Example: [Field : Sample Fld] Set As : 4*(5+6) If parentheses are not used, then the Field 'Sample Fld' will d isplay 26, otherwise 44.
TDL_Reference_Manual.pdf
General and Collection Enhancements 214 7. Action Enhancements Some of the existing actions have been enhanced to support the multi-line selection capabilities. Several new actions have also been introduced in TDL. 7. 1 Enhancements in Key Actions Key action is enhanced to perform various operations on multipl e lines. For example, multiple vouchers can be selected/unselect ed and various actions such as deletion, modification, etc., can be performed on the selected vouchers only. T o achieve this, t w o a t t r i b u t e s Scope and Selectable have been introduced. Scope attribute is introduced in Key definition and Selectable attribute is available at Part and Line definitions. Attribute 'Scope' introduced in 'Key' definition Through this attribute, scope for the Action(s) can be specifie d. Syntax Scope : <Scope Keyword> Where, <Scope Keyword> can have any of the following possible values:-Current Line/Line, All Lines, Selected Lines, Unselected Lines and Report. Attribute 'Selectable' introduced in 'Part' and 'Line' definiti ons Part Definition At Part level, the attribute 'Selectable' indicates whether the lines owned by the particular Part are selectable or not, and the default value for the same is YES. Syntax Selectable : <Logical Formula> Line Definition At Line level, the attribute 'Selectable' indicates whether the line (or lines within the line) is selectable or not. The default value of attribute 'Selectable' for repeated lines i s 'YES', and for non-repeated lines is 'NO'. The value is also inherited from Pa rent Part/Line, and the same can be overridden at Line level. Syntax Selectable : <Logical Formula> where, <Logical Formula> must return the value as Y es or No Following actions have been introduced/changed : T oggle Select-Selects/deselects a line Select All-Selects all the lines within a part Unselect All-Deselects all the lines within a part Invert Selection-Selects all t he unselected lines within a pa rt Modify Object-Modifies the val ues stored in the methods of an Object
TDL_Reference_Manual.pdf
General and Collection Enhancements 21 5 The behaviour of existing actions 'Cancel Object', 'Delete Obje ct', 'Remove Line' and 'Multi Field Set' have been modified to obey the scope specified in the Key description. The actions Print Report, Upload Report, Email Report and Export Report can be executed now on the Selected Line scope. In the resultant report, the select ed lines will be available as objects in the collection 'Parameter Collection'. This collection can b e used in the called report for displaying data. Actions like Cancel Object, Audit Object and Delete Object have been enhanced to work with 'Report' scope. 7. 2 New Actions Following new actions have been introduced in the language: Action-Modify Object The action 'Modify Object' has been enhanced to alter a method of an object at any level. 'Modify Object' also supports modifying multiple values of an object. M ultiple values can be specified as a comma separated list of <Method Name> : <V alue> pairs. Syntax Action : Modify Object : <Primary Object Spec>. <Sub Object Path Spec> + . Method Name : value>[,Method Name : <value>,... ]+ [,<Sub Object Path Spec>. Method Name : <value>,..... ] The specifications given for <Primary Object Spec>, <Sub Object Pat h Spec>, Method Name remain the same as described in the New Method syntax section. A single 'Modify Object' action cannot modify Multiple Objects, but can modify multiple values of an Object. 'Modify Object' is allowed to have Primary Object Specification only once, that is, for the first value. Further values permissible are optional Sub Objects and Method Specification only. Sub Object Specification is optional for second value and onwar ds. If Sub Object Specification is specified, the context is assumed to be the Primary Object spec ified for the first value. In absence of Sub Object Specification, the previous value specification's Leaf Object is considered as the context. Example: 1 [Key : Alter My Object] Key : Ctrl + ZAction : Modify Object :(Ledger,"My Ledger"). Bill Allocations + [First,$Name="My Bill"]. Opening Balance + : 100,..Address[Last]. Address : "Bangalore" Existing ledger My Ledger is being altered with new value for opening balance of existing bill bearing Name as My Bill and last line of Address. Key Alter My Object can be attached to any Menu or Form, clicking which, the above will be altered.
TDL_Reference_Manual.pdf
General and Collection Enhancements 216 Example: 2 [Key : Alter My Object] Key : Ctrl + Z Action : Modify Object :(Ledger,"My Ledger"). Bill Allocations[1]+ . Opening Balance : 1000, Name:”My New Bill”,..Address[First]+ . Address : "Hongasandra Bangalore", + Opening Balance : 5000 Existing ledger My Ledger is altered with new values for opening balance for existing bil l, opening balance of ledger and address. Key Alter My Object can be attached to any Menu or Form. Example: 3 [Key : Alter My Object] Key : Ctrl + Z Action : Modify Object : Ledger Entries[1]. Bill Allocations[1]. Name : + “Test1”, Amount :“1000. 00”,..Bill Allocations[2]. + Name : “Test2”, Amount : “2000. 00”, (). Date : “1. 4. 08” In a Voucher context, Key Alter My Object alters the Name, Amount and Date methods of the Sub object Bill Allocations in one line. Action 'Modify Object' in a Menu Definition In Menu definition, a button which has the action 'Modify Object', can be added. Example: [#Menu : Gateway of Tally] Add : Button : Alter My Object While associating a key with action 'Modify Object', the follow ing points should be considered: Since menu does not have any Data Objects in context, specifyin g Primary Object becomes mandatory. Since Menu cannot work on scopes l ike Selected Lines, Unselecte d Lines, etc., scopes specified are ignored. Any formula specified in the va lue is evaluated assuming Menu O bject as the requestor. Even Method values pertaining to Company Objects can be modifie d. A button can be added at the menu to specify the action Modify Object at the Menu level Action-Set Object Values This new action is similar to the action 'Modify Object'. The a ction 'Set Object V alues' works only in the 'Edit' mode of a Report, as it uses current context. Thi s action changes the values of the object from current context, as specified.
TDL_Reference_Manual.pdf
General and Collection Enhancements 21 7 Syntax Action : Set Object Values : <Sub Object Path Spec>. <Method Name> + : <Method Value> Where, <Sub Object Path Spec> is given as Collection Name [<Index Formula>, [<Condition>]] <Method Name> refers to the name of the method in the specified path, and <Method Value> is the value to be set for <Method Name>. This action alters the current object in memory. When the Primary object is saved, the changes will be updated in T ally database. Example: [Key : My Key] Action : Set Object Values : Opening Balance : ($$As Amount : 10) Action-Backup Company The action 'Backup Company' allows to take the backup of multip le companies. Syntax Backup Company : <parameter sep char> : <String Formula> Where, <Parameter Sep Char> is a character used to separate parameter. <String Formula> must evaluate to the value in the following order separated by the <Parameter Sep Char> : <Destination> <Source> <Company Name> <Company Number> <Destination> is the path where the backup file is to be stored. <Source> is the path from where the company data is to be taken for back up. <Company Name> is name of the Company. <Company Number> is number of the company. These four values must be specified for each company. They can be repeated for multiple companies. Example: Single Company [Button : My Cmp Bk Button] Title : Back Up Cmp Action : Back Up Company: “,” : “C:\,C:\Tally. ERP 9\Data,Global + Enterprises,10037”Key : Alt + G
TDL_Reference_Manual.pdf
General and Collection Enhancements 218 Example: Multiple Company [Button : My Cmp Bk Button] Title : Back Up Cmp Action : Back Up Company : “,” : “C:\,C:\Tally. ERP 9\Data,+ Global Enterprises,10037,C:\,C:\Tally. ERP 9\Data,+ TDL Demo,10027” OR [Button : My Cmp Bk Button] Title : Back Up Cmp Action : Back Up Company : “,” : @@My Cmp For [System : Formula] My Cmp For : “C:\,C:\Tally. ERP 9\Data,Global Enterprises,10037, + C:\,C:\Tally. ERP 9\Data,TDL Demo,10027” Action-Restore Company This action allows to restore multiple companies in one go. Syntax Restore Company : <parameter sep char> : <String Formula> Where, <Parameter Sep Char> is a character used to separate parameter. <String Formula> must evaluate to the value in the following order separated by the < Parameter Sep Char> : <Destination> <Source> <Company Name> <Company Number> <Destination> is the path where the backup file is to be stored. <Source> is the path where the backup file is available <Company Name> is the name of the Company. <Company Number> is the number of the company. These four values must be specified for each company. These can be repeated for multiple companies. Example: Single Company [Button : My Cmp Res Button] Title : Restore Cmp Action : Restore Company : “,” : “C:\Tally. ERP 9\Data,C:\,+
TDL_Reference_Manual.pdf
General and Collection Enhancements 21 9 Global Enterprises,10037” Example: Multiple Company [Button : My Cmp Res Button] Title : Restore Cmp Action : Restore Company : “,” : “C:\Tally. ERP 9\Data,C:\,+ Global Enterprises,10037,C:\Tally. ERP 9\Data,C:\,+ TDL Demo,10027” OR [Button : My Cmp Res Button] Title : Restore Cmp Action : Restore Company : “,” : @@My Cmp For [System : Formula] My Cmp For : “C:\,C:\Tally. ERP 9\Data,Global Enterprises,10037, + C:\,C:\Tally. ERP 9\Data,TDL Demo,10027” Action-Change Crypt Company This action allows to change the T ally V ault Password of multipl e companies in one click. Syntax Change Crypt Company : <parameter sep char> : <String Formula> Where, <Parameter Sep Char> is a character used to separate parameter. <String Formula> must evaluate to the value in the following order, separated by <Parameter Sep Char> : <Company Data Folder> <New Tally Vault Key> <Old Tally Vault Key> + <Company Name> <Company Number> <Company Data Folder> is the path of the company data folder. <New T ally Vault Key> is the new password of the company. <Old T ally Vault Key> is the old password of the company. <Company Name> is the name of the Company. <Company Number> is the number of the company. These 5 values must be specified for each company, and can be repeated for multiple companies.
TDL_Reference_Manual.pdf
General and Collection Enhancements 220 Example: [Button : Chg Pwd] Title : Change Pwd Key : Alt + b Action : Change Crypt Company : “,” : ”C:\Tally. ERP 9\Data\10037, + New Pwd,Old Pwd,Global Enterprises, 10037” Action-Browse URL It is used to open web browser with any URL formula passed as a parameter. A list of parameters separated by space can be specified, if the application accepts command line parameters. Exec Command is an alias for action Browse URL. Syntax Action : Browse URL : <URL Formula> [:<command line parms>] Where, <URL formula> is an expression which evaluates to any link to a web site. <command line parms> is the List of command line parameters, separated by space. 'Browse URL' Key Action can be used to open web browser with any URL Fo rmula. Example: [Button : Open Notepad] Title : $$Locale String:"Notepad" Key : ALT + N Action : Exec Command : Notepad : “Browse URL. Txt” [Form : Hyperlink] Parts : Hyperlink Button : Open Notepad Example: Field acting as a hyperlink [Key : Execute Hyperlink] Key : Left Click Action : Browse URL : “www. tallysolutions. com” [Field : Hyperlink Company] Color : Blue Border : Thin Bottom
TDL_Reference_Manual.pdf
General and Collection Enhancements 22 1 Key : Execute Hyperlink Set as : "Tally Solutions Pvt. Ltd" Local : Key : Execute Hyperlink : Action : Browse URL : + http://www. tally. co. in Action-HTTP Post A new Key/Button Action HTTP Post has been introduced which will help in exchanging data with external applications using web services. In other words, 'HTTP Post' Action can be used to submit data to a server over HTTP and gather the response. This will enable a TDL Report to perform a HTTP Post to a remote location. This Action will be discussed in detail under the topic HTTP XML Collection. Action-Refresh TDL A new Key/Button Action Refresh TDL has been introduced, which allows the TDL programmer to reload the active TDL Files, without having to restart T ally. Syntax Action : Refresh TDL Example: Field acting as a hyperlink [Key : Refresh TDLs] ;; Any Key can be assigned if Report already have F5 assigned Key : F5 Action : Refresh TDL ;; Refresh TDL will work from any Report [#Form : Default] Key : Refresh TDLs Existing Action Register Tally has been removed for generalization; which is now replaced with Action Browse URL.
TDL_Reference_Manual.pdf
General and Collection Enhancements 222 8. Events introduced T ally. ERP 9 Series A Release 1. 0 onwards, actions can also be c arried out based on certain events. On encountering these events, the given action or list of actions will be executed. Currently, two events have been introduced in T ally. ERP 9 On : Form Accept On : Focus 8. 1 Event-On Form Accept A new event On: Form Accept has been introduced that can be specified within the Form Definition. A list of actions can be executed when the form is accepted, which can also be based on some condition. Syntax On : Form Accept : <Condition>:Action : Action parameters Where, <Condition> should return a logical value. <Action> can be any one of the actions. <Action Parameters> are the parameters of the action specified. Example: [Form : Test Form] On : Form Accept:Yes:Http Post : @@SCURL : ASCII : SCPost New Issue : + SC New Issue Resp 8. 2 Event-On Focus A new Event On: Focus has been introduced, which can be specified within definitions Part, Line and Field. When Part, Line or Field receives focus, a list of actions get executed which can also be conditionally controlled. Syntax On : Focus : Condition : Action : Action parameters Where, <Condition> should return a logical value. <Action> can be any action. <Action Parameters> are parameters of the action specified. Since On : Focus is a list ty pe attribute, many actions can be specified, which will be executed sequentially. Example: [Part : Test Part1] On : FOCUS : Yes : HTTP Post : @@My Url : ASCII : Req Rep, Resp Rep
TDL_Reference_Manual.pdf
General and Collection Enhancements 22 3 [Part : Test Part2] On : FOCUS : Yes : CALL : SCSet Variables : $$Line 9. User Defined Function This is one of the breakthrough changes which has taken place a t the platform level. We all know that TDL is a definition language which provides capability for rapid development. But now, TDL is procedural as well. With the introduction of Functions/Procedur es as a part of T ally. ERP 9 family, the TDL capabilities have reached a new dimension. This will help the application programmers to develop their own functions for achieving business functionality. There will be a decrease in platform dependency for particular business function. The result would be faster development cycles for business modu les. The creation and usage of functions is discussed in detail in t he section III “User Defined Functions for T ally. ERP 9”. 10. New Functions Following functions have been introduced in the Language: 10. 1 Function-$$I s Object Belongs T o The existing function $$Is Belongs T o will only check if the current object belongs to a specified object. The new function $$Is Object Belongs T o has been introduced to provide more explicit control in the hands of the programmer, by allowing him to specify the object type and name, in addition to parentage against which it needs to be checked. Thi s function is very useful in the context of summarized objects, as they are not of any native ty pe and are just an aggregation of objects. This function allows an easy link back into the native object type, and walking up the chain. It is very useful when creating hierarchical reports on summarized collections. Syntax $$Is Object Belongs To : Obj Type : Obj Name : Belongs To Name Where, <Obj Type> denotes the Type of the Object. <Obj Name> denotes the Name of the Object. <Belongs To Name > denotes the name of the object Type. Example:Whether Group North Debtors belongs to Group Sundry Debtors or not, can directly or indirectly be checked using the following statement: $$Is Object Belongs To : Group : ”North Debtors” : $$Group Sundry Debtors
TDL_Reference_Manual.pdf
General and Collection Enhancements 224 10. 2 Function-$$Num Lines In Scope T ally. ERP 9 onwards, various operations can be performed on mul tiple lines. T o know how many lines were considered for any operation, the function $$Num Lines In Scope has been introduced. Syntax $$Num Lines In Scope : <Scope Keyword> Where, <Scope Keyword> can be All Lines, Selected Lines, Un Selected Lines, Current Line/Lines. Example: [Field : Sample Fld] Set As : $$Num Lines In Scope : Selected Lines Field Sample Fld displays the total number of selected lines in the Part to whic h it belongs. 10. 3 Function-$$Date Range A new Built-in function $$Date Range has been introduced to convert data types of the value from one form to due date format. Prior to this, only through Field' s format specification, conversion was possible. Now, the new function can be used inside User Defined Functions als o. Syntax $$Date Range:<Due Date Expression>:<Base Date Expression>:<Flag> Where, <Base Date Expression> is a String Expression, and evaluates to Due Date. <Due Date Expression> is a String Expression, and evaluates to Date. <Flag> is a logical expression, and decides whether to include date gi ven in second parameter. Example: SET VALUE: Order Due Date : $$Date Range: "10 Days" : $Date : True Method 'Order Due date' will have value as "1 0 Days" from $Date, with $Date also inclusive. When you export a voucher to XML with due date, the tag < orderduedate > contains two attributes called JD and P. JD is the Julian Day of the given date. P is the due date mentioned in the field. Julian Day (JD) value is calculated internally based on the cal culation method of Tally. All value extraction can now be achieved using Group By; hence $$Extract functions have been removed from T ally. ERP 9, e. g., $$Extract Grp Val, $$Extract Led Val, etc.
TDL_Reference_Manual.pdf
General and Collection Enhancements 22 5 10. 4 Function-$$Is Coll Src Obj Changed You can use the function $$Is Coll Src Obj Changed to know when the source object is changed to the next source object, while the Walk or Walk Ex attribute is b eing executed. Syntax $$Is Coll Src Obj Changed The return value of this function is Logical. It returns True for the source object and the first walked object. It will return False for the subsequent objects that are walked in the same source objects, till the source object is changed. This function is especially usef ul when you want to aggregate t he values for a source object while walking through multiple source object. This function will indi cate that a source object is changed to the Aggregation computation expression. Example : [Collection: TN Summary Counts] Source Collection : My Vouchers By : Summary : "Summary" Aggr Compute : Total Included : Sum : IF $$Is Coll Src Obj Changed + AND $Is VCHIncluded Then 1 Else 0Aggr Compute : Total Uncertain : Sum : IF $$Is Coll Src Obj Changed + AND $Is Vch Uncertain Then 1 Else 0 10. 5 Function-$$Coll Src Obj You might need to evaluate some expression from the source coll ection context while walking in the sub-collection context to compute some value. For this purp ose you can use the function Coll Src Obj evaluate expression in the context of source object while walk ing the current object. Syntax $$Coll Src Obj:<Expression> Where, Expression is any expression that needs to be evaluated in the context of the source object (methods, local formulae, and so on). Example: [Collection: TNAnnexure Summary Template] Source Collection : My Vouchers Walk : All Inventory Entries Compute : TNe VATVch No : $$Coll Src Obj:$Voucher Number
TDL_Reference_Manual.pdf
General and Collection Enhancements 226 Compute : TNe VATVch Dt : $$Coll Src Obj:$Date By :... Aggr Compute :... This function will work only when it is used in a collection co ntext. 11. Enhanced Collection Capabilities Collection, the data processing artefact of TDL, provides exten sive capabilities to gather data not only from T ally database, but also from external sources using ODBC, DLLs, HTTP, and so on. A set of new capabilities have been added to Collection, which pr ovides far more flexibility and power in the hands of the TDL programmer. This will allow writing significantly complex reports with ease, and still delivering enhanced perf ormance with high volume of data. 11. 1 Aggregation and Reporting T ally. ERP 9 onwards, Collection has been enriched with the foll owing capabilities: Data Roll up/Summarization Collection re-use, extraction and chaining Indexed or Searchable Collection on TDL defined keys Following attributes under 'Collection' have been introduced to achieve the above: Attribute-Source Collection In context of summary collection, i. e., to achieve Data roll up, this attribute is mandatory. Source Collection specifies the collections to be used for source data. Multiple Source Collections can be used, which can either be specified as a comma separated lis t OR listed in several lines. Syntax Source Collection : <Collection name>, <Collection Name>... Where, <Collection Name> is any predefined collection, the methods and sub-objects of wh ich are available to the current collection for further processing. Example: [Collection : Vouchers Collection] Type : Voucher [Collection : Summary Collection] Source Collection : Vouchers Collection The 'Summary Collection' uses 'V ouchers Collection' as source d ata.
TDL_Reference_Manual.pdf
General and Collection Enhancements 22 7 Attribute-Walk Attribute Walk allows specifying further elements to walk on the source. 'Walk ' is optional and if not specified, the methods pertaining to the source object only, are available to be used. Walk can be specified to any depth for within the source object. This gi ves enormous flexibility and power. The Walk list has to be specified in the order in which they oc cur in the source object. Syntax Walk : <Sub-Object Type/Sub-Collection>[, <Sub-Object Type/ + Sub-Collection>... ] Where, <Sub-Object T ype/Sub-Collection> is the name of the Sub-Object/ Sub Collection. Example: [Collection : Vouchers Collection] Type : Voucher [Collection : Summary Collection] Source Collection : Vouchers Collection Walk : Inventory Entries In the Summary Collection, by saying Walk : Inventory Entries, only methods within the 'Inventory Entries' Object are available to the current collection. In case objects pertaining to Batch Allocations are required, t he Walk can be written as: Walk : Inventory Entries, Batch Allocations wherein, all the methods within Batch Allocations will be avail able to the current collection. Attribute-By Attribute By is mandatory and it allows to specify the criteria, based on wh ich the aggregation is done. In other words, it works like GROUP-BY. Aggregation criteria can be one or more. Syntax By : <Method-Name> : <Method-Formula> Example: [Collection : Vouchers Collection] Type : Voucher [Collection : Summary Collection] Source Collection : Vouchers Collection Walk : Inventory Entries By : Party Ledger Name : $Ledger Name
TDL_Reference_Manual.pdf
General and Collection Enhancements 228 By : Stock Item Name : $Stock Item Name In 'Summary Collection', Partywise Stock Items are clubbed, on which Aggregation, i. e., Sum/Min/ Max operations, would be performed. Attribute-Aggr Compute 'Aggr Compute' attribute is used for aggregation purpose based on the criteria(s) specified with attribute By. Aggregation can be done to find Sum, Minimum or Maximum, or th e Last value of the Method within the Grouped Method. The Method on which Aggregation has to be performed can be of Data Type 'Number', 'Quantity', 'Rate' or 'Amount'. Syntax Aggr Compute : <Method-Name> : <Aggr-Type> : <Method-Formula> Where, <Method-Name > refers to the method where the result can be stored and referre d to later. <Aggr-T ype > takes operation to be performed on the given method within the given criteria, i. e., Sum, Max, Min, or Last. <Method-Formula > should be evaluated to method names on which Aggregation operat ion needs to be performed. Example: [Collection : Vouchers Collection] Type : Voucher [Collection : Summary Collection] Source Collection : Vouchers Collection Walk : Inventory Entries By : Party Ledger Name : $Ledger Name By : Stock Item Name : $Stock Item Name Aggr Compute : Billed Qty : Sum : $Billed Qty Billed Qty method retains the result of Aggregation, i. e., Summation of me thod Billed Qty for a Stock Item within a particular Party. Attribute-Compute Apart from the ones used in By and Aggr Compute attributes, non e of the other methods can be accessed unless they are declared explicitly. One of the ways of declaring the required methods is by listing them using the attribute Compute. Syntax Compute : <Method-Name> : <Method-Formula>
TDL_Reference_Manual.pdf
General and Collection Enhancements 22 9 Example: Compute : Date : $Date Method Date is being declared and made available for subsequent use. Attribute-Re Walk and Re Compute Many a time, there are requirements where objects being walked in a collection need to be walked once for certain computation followed by, ensuring that these computations are reflected back as methods in all the objects. The attributes Re Walk and Re Compute are introduced for this purpose. The objects are being walked in the first iterati on with the values accumulated in some variable and if Rewalk is Yes, these objects are walked again so that the accumulated values are re-computed as methods along with objects Syntax Re Walk : <Logical Constant>Re Compute : <Method Name> : <Expression> Where, <Logical Constant> is either Yes or No. <Method Name> refers to the method where the result can be stored and referr ed to later. Example: /* Regular voucher collection for source */ [Collection: My Vouchers] Type : Vouchers /* Main Aggregate collection uses By with Walk and Re Walk for totling item amount Query to execute:Select $Item, $Total Amount, $Item Total Amount from Main Aggr Collection*/ [Collection: Main Aggr Collection] Source Collection : My Vouchers Walk : Inventory Entries ;; Compute var for keeping total from first walk (NOTE: Need to rese t this for every voucher) Compute Var : Walk Total : Amount: $$Nett Amount:##Walk Total:$Amount ;item name By : Item : $Stock Item Name ;; itemwise total Aggr Compute : Total Amount : Sum: $Amount
TDL_Reference_Manual.pdf
General and Collection Enhancements 230 ; rewalk Rewalk : Yes ;; must be same as total amount (but reflects for all entries) Re Compute : Item Total Amount : ##Walk Total Attribute-Fetch Another way of declaring required methods is by listing them in Fetch attribute. The only difference here is that the method names of the Objects within this collection have to be referred by the same name as in the Object. Syntax Fetch : <Existing-Method-Name-in-Source>... Where, <Existing-Method Name in source > refers to the methods of the source collection. Example: Fetch : Date, Narration ;;is equivalent to writing Compute : Date: $Date Compute : Narration : $Narration Fetch using wildcard characters: The two wild characters can be used in Fetch attribute * and ?. * is used T o fetch all the methods and collections of the curre nt object in context. ? is used T o fetch all the methods of current object in context. Example: T o fetch all methods of current Object within Walk. Fetch : ? T o fetch all methods and collection of current Object within Wa lk. Fetch : * T o fetch the methods Stock Item Name, Billed Qty, Amount and all the methods of collection Batch Allocation Fetch : Stock Item Name, Billed Qty, Amount, Batch Allocations. * Attribute-Source Fetch You can use the attribute Source Fetch to fetch methods from the source object context while in the current object context within Walk. Syntax Source Fetch: Method Syntax,...
TDL_Reference_Manual.pdf
General and Collection Enhancements 23 1 Where, Method Syntax is the method or collections to be fetched from the source obje ct context. Example: [Collection: TNAnnexure Summary Template] Source Collection : My Vouchers Walk : All Inventory Entries Source Fetch : Date By :... Aggr Compute :... Attribute Source Fetch is not relevant in a Simple Collection o r an Extract Collection without Walk and will be ignored. If the source collection does not have Walk or Walk Ex attribute s, then Source Fetch will be ignored. Source Fetch will also be ignored if the source collec tion of is of type native collection. Attribute -Prefetch and Source Prefetch When a collection is being gathered, Fetch is used to fetch the methods at source and also bring them to the target object. In TDL, we also define multiple exte rnal methods at object level which can also be fetched using the Fetch attribute. This ensures tha t the resultant method is created at source and is also pulled into the target object. Any further a ccess to these external methods using $ will provide the value directly, avoiding evaluation of method again. However, there are scenarios, where Compute Var variables are u sed to evaluate expressions containing these external methods. Since Fetch is always evalua ted after Compute Var, any access to external methods during Compute Var evaluation will e nd up evaluating again and again. To solve this problem, an attribute Prefetch is introduced to declare the methods that are required to be fetched prior to Compute Var such that these Methods are available for usage within the current context thereby not requiring to re-evaluate the same e xpression each time they are used. The sequence of methods declared in the Prefetch should be in t he order of dependency, for instance, if Method 3 uses Method 2, and Method 2 uses Method 1, then, the declaration order in Prefetch should be Method 1, Method 2. A similar Source Prefetch is provided for the case of Source object context. Syntax Pre Fetch: <Method1,... > Source Prefetch: <Method 1,... > Where, <Expression> is the value that needs to evaluated.
TDL_Reference_Manual.pdf
General and Collection Enhancements 232 Example: [Collection: LT_Summary Vch Coll_With_PF] Source Collection : LT_Simple Vch Coll Walk : Ledger Entries By : Ledger Name : $Ledger Name Aggr Compute : Amount : Sum : $Amount /* Two External Object Methods are pre-fetched so that these expressions get evaluated only once and used multiple times */ Prefetch : Ledger Parent, Is Led Debtor Creditor Compute Var : v Is Credit Allowed : Logical : If $$Is Empty:$Led Credit Per + then No else Yes Compute : Is Credit Allowed : ##v Is Credit Allowed [#Object: Ledger Entry] Ledger Parent : $Parent:Ledger:$Ledger Name Is Led Debtor Creditor : $Ledger Parent = $$Group Sundry Debtors OR + $Ledger Parent = $$Group Sundry Creditors Is Party Led Bill Wise On: If $Is Led Debtor Creditor then + $Is Bill Wise On:Ledger:$Ledger Name else No Led Credit Per : If $Is Led Debtor Creditor and $Is Party Led Bill Wise On then + $Bill Credit Period:Ledger:$Ledger Name else "" [Collection: LT_Simple Vch Coll] Type : VoucherSource prefetch is applicable only when the walk is provided. Prefetch is evaluated before Co mpute Var but after Source Var. Source Prefetch is evaluated before Source Var
TDL_Reference_Manual.pdf
General and Collection Enhancements 23 3 As we can observe, that the Method Ledger Parent is being prefet ched, as a result of which, while evaluating the subsequent Method Is Led Debtor Creditor, the value of Ledger Parent will be available and is not required to be re-evaluated. Similarly, si nce Is Led Debtor Creditor is prefetched, the subsequent methods Is Party Led Billwise On and Led Credit Per using this method are also using the prefetched value, without re-evaluating. Attribute-Keep Source The attribute Keep Source is used to store the source data in main memory. The default value of this attribute is NO. When the Source Collection from which the Summary Collection is being prepared has a large number of objects and 'Keep Source' is set to YES, then the sys tem goes out of memory since holding those objects in memory in one shot is not possible. When Keep Source is set to No, the source objects are not retai ned in memory and they are processed as they are collected. Syntax Keep Source : Yes/No/... Where, Each dot specifies the parent one level up. -Single dot retains the data of the source collection in curren t object...-Double Dot retains the data of the Source Collection in curren t object's parent....-Triple Dot retains the data of Source Collection in current ob ject's parent's parent, and so on. Example: Keep the source collection in the current owner Keep Source : Yes OR Keep Source :. Don't keep the source collection data Keep Source : No Keep the current source collections data in the current object' s parent Keep Source :.. Keep the current source collections data in current object's gr and parent Keep Source :... Please note that using the current object as a source-collection means that 'Keep Source' is not applicable, as there is no actual source collection created.
TDL_Reference_Manual.pdf
General and Collection Enhancements 234 Attribute-Search Key This attribute is used to create index dynamically where the TD L programmer can define the key and the Collection is indexed in the memory using the Key. Once the index is created, any object in the collection can be instantly searched without needing a scan, as in the case of a filter. Search Key is Case Sensitive. This attribute has to be used in conjunction with function $$Collection Field By Key. This function basically maps the Objects at the run time, with the Search Key s defined at the Collection. Syntax Attribute-Search Key Search Key : <Combination of Method name/s> Function-$$Collection Field By Key $$Collection Field By Key : Method-Name : Key-Formula : Collection Name Where, <Method-Name> is the name of the method, <Key-Formula > is a formula that maps to the methods defined in the search key, exactly in the same order. Attribute-Data Source Attribute 'Data Source' allows to specify XML file as data sour ce. The collection can be created directly from the specified XML file and the data in the XML fi le can be displayed in a report. Syntax Data Source : <Type> : <file path> : <Encoding> Where,<Type> specifies the type of data source-File Xml or HTTP XML <File Path> is the data source file path. <Encoding> is ASCII or UNICODE. It is Optional. The default value is UNICOD E. Example: 1 [Collection : My XML Coll] Data Source : File Xml : “C:\My File. xml” In this code snippet, the type of file is 'File XML' as the dat a source is XML file. The encoding is UNICODE by default, as it is not specified. Example: 2 [Collection : My XML Coll] Data Source : HTTP Xml : “http:\\localhost\My File. xml” : ASCII In this code snippet, the type of file is 'HTTP XML', as the da ta source is obtained through HTTP. The encoding of the file 'My File. XML' is ASCII.
TDL_Reference_Manual.pdf
General and Collection Enhancements 23 5 Data Roll up/summarization capability in TDL Collection Data roll up/ summarization capa bility facilitates creation of large summary collections of aggregations in a single scan, using the new attributes of the 'Collection' definit ion, as discussed above. Prior to T ally. ERP 9, all the totals were generated using funct ions like $$Coll Amt T ota l or $$Filter Amt T otal via collections. These have certain advantages and disadvantage s. While they provide excellent granularity and control, each call is largely an inde pendent activity to gather the data set and then aggregate it. This can make the code very complex and may not scale up if a large number of totals need to be generated, as in the case of most b usiness summary reports or a large underlying data set being used. Considering the object or iented nature of T ally data and existence of sub-objects up to any level, the task becomes even more complex. These functions require multiple data scans to produce a summary report with mu ltiple rows and columns. This methodology has now been complemented with a single scan t o get all totals including those based on User Defined Fields (UDFs). Native aggregation capabil ity has now been added to a collection itself. The overall effect is a reduction in TDL cod e complexity, resource requirement and enhanced performance by orders of magnitude especially conc erning reports generation. Example: 1 [Collection : My Source Collection] Type : Voucher [Collection : My Summary Collection] Source Collection : My Source Collection Walk : Ledger Entries By : My Ledge Name : $Ledger Name Aggr Compute : My Total : Sum : $Amount In this code snippet, My Summary Collection is created out of source collection My Source Collection where traversing is done to Ledger Entries using Walk, and Ledger Name is the method on which aggregation is performed to find the sum of the ledger am ount. Example: 2In some scenarios, current object itself is required as a Sourc e and aggregation is performed on collection obtained from it or its sub-collections. In such cir cumstances, if we use Source Collection as Voucher, then the entire vouchers within the company will be scanned Support for other data sources like ODBC, D LL, etc., will also be available in the future releases.
TDL_Reference_Manual.pdf
General and Collection Enhancements 236 unnecessarily to find the current one, which is a time consuming process. T o avoid this, we can use Source Collection: Default, which will assume the current voucher as a Source. [Collection : Ledger In Acc Allocations] Source Collection : Default Walk : Inventory Entries, Accounting Allocations By : Ledger Name : $Ledger Name Compute : Rate Of VA : $Rate Of VAT:Tax Classification:+ $Tax Classification Name Aggr Compute : Amount : Sum : $Amount Filter : Is VATLedgerin Acc [System: Formula] Is VATLedgerin Acc : $$Is Sys Name Equal:VAT:$Tax Type:Ledger:$Ledger Name While printing a voucher as an invoice, if an aggregation has t o be done on its tax ledgers to show as summary within the invoice, t his has to be collected from th e accounting allocations of the same voucher. Collection re-use, extraction and chaining support in TDL Colle ction A collection can extract informat ion from other collections, in cluding its sub-objects with the choice of method(s), f ilter(s) and sort-order. Source Collection within a collection/collection(s) can be chained. In other words, Summary Collection can be used as Source Collection for some other Collections, and so on. Example: [Collection : My Source Collection] Type : Voucher [Collection : My Summary Collection] Source Collection : My Source Collection Walk : Ledger Entries By : My Ledger Name : $Ledger Name Aggr Compute : My Total : Sum : $Amount [Collection: My Parent Summary Collection] Source Collection : My Summary Collection By : My Parent : $Parent:Ledger:$Ledger Name
TDL_Reference_Manual.pdf
General and Collection Enhancements 23 7 Aggr Compute : My Parent Total: Sum : $My Total In this code snippet, My Parent Summary Collection extracts a sub-set of information from a collection to an already summarized collection My Summary Collection. Indexed or Searchable Collection on TDL defined keys The capabilities discussed above extend the data gathering capa bilities of TDL. However, business reporting in general and in T ally uses hierarchical pr esentation or columnar presentation, rather than simple table representation. This cre ates a unique and natural experience of working with the product and business data. In case one simply repeats the summarized collection and gets t he desired report, everything works fine with the existing capabilities. However, if the Report is having two or more dimensions like Ledger, Cost Center and so on, a simple repeat on the summarized colle ction will not suffice. Let us understand the same with the help of an example. Example: When a Report is to be designed with ledgers as rows and cost c enters as columns, the following options are available: Use function(s) like $$Collection Field or $$Filter Value in each column. Create Summary Collection for each column. The first one will scan through the whole collection for every value required. The second one will scan the whole source data as many times as the number of colum ns. Both of them will take a significant hit on the scale and volume that it can handle, and affect the resultant performance. T o provide presentation capabilities beyond simple tables, a ne w capability has been added to the 'Collection' definition. A search key can be defined in the col lection using the 'Search Key' attribute. This implies that a unique key is created for every object, which can be used to instantly access the corresponding objects and their values without needi ng to scan or re-collect. The corresponding function created to access the same is $$Collection Field By Key. Example: [Collection : Led CC] Use : Voucher Collection Walk : Ledger Entries, Category Allocations, Cost Centre + Allocations By : Party Ledger Name : $Party Ledger Name By : Cost Centre Name : $Name Aggr Compute : Amount : $Amount Search Key : $Party Ledger Name + $Cost Centre Name [Field : My Rep Field] Set as : $$Collection Field By Key : $Amount : @My Search Key : Led CC
TDL_Reference_Manual.pdf
General and Collection Enhancements 238 My Search Key : #Led Name + #CCName In Collection Led CC, a search key is created for every object with the help of Ledg er Name and Cost Center. Now, on any row/column in the report, combination total is accessed using $$Collection Field By Key : $Amount : @My Search Key : Led CC Where, My Search Key is the formula to get the Ledger Name + Cost Center name at a particular point, Led Name is the Field having Ledger Name in current context, and CCName is the variable storing the Cost Centre Name in current context. 11. 2 The Summary Collection is available throu gh T ally ODBC In terface Now, Objects of the Summary Collection can be exposed to T ally ODBC Interface through Collection attribute 'Is ODBC T abl e'. The values of the Collect ion attributes “Fetch', 'Compute, 'By' and Aggr Compute' are available through T ally ODBC Interface. Syntax [Collection : <Name of Summ Coll>] Is ODBC Table : <Logical value> Where, <Name of Summ Coll> is the name of the Summary Collection <Logical value> can be either YES or NO. Example: [Collection : Source Collection] Type : Voucher [Collection : Summary Collection] Source Collection : My Source Collection Walk : Ledger Entries By : Ledger Name: $Ledger Name Aggr Compute : Total : Sum : $Amount Compute : Parent: $Parent:Ledger:$Ledger Name Is ODBC Table : Yes The values of methods of the 'Summary Collection', 'Ledger Name', 'T otal' and 'Parent' are exposed to the T ally ODBC interface.
TDL_Reference_Manual.pdf
General and Collection Enhancements 23 9 11. 3 HTTP XML Collection (GET a nd POST with and without Object Specification) Collection capability has been enhanced to gather live data fro m HTTP/web-service delivering XML. The entire XML is now automatically converted to TDL objects a nd is available natively in TDL reports as $ based methods. There is no need to access the data via speciali zed functions, like $$XML Value. Reports can be shown live from an HTTP server. Coupled with the new [OBJECT :] extensions and POST ac tion, you can also submit data back to the server almost operating T ally as a client to HTTP-XML web-services. HTTP-XML Collection Consider the following XML data stored in file T est XML. xml available at server Remote Server. <CUSTOMER> <NAME>Sapna Awasthi</NAME> <EMPID>1000</EMPID><PHONE> <OFFICENO>080-66282559</OFFICENO> <HOMENO>011-22222222</HOMENO><MOBILE>990201234</MOBILE> </PHONE> <ADDRESS> <ADDRLINE>C/o. Info Solutions</ADDRLINE> <ADDRLINE>Technology Street</ADDRLINE> <ADDRLINE>Tech Info Park</ADDRLINE> </ADDRESS> </CUSTOMER> This capability allows us to retrieve and store this data as ob jects in Collection. The attributes in collection for gathering XML-based data from a remote server ov er HTTP are Remote URL, Remote Request, XMLObject Path, and XMLObject. Whenever the colle ction is referred to, the data is fetched from the remote server and is populated in the collection. Syntax [Collection : <Collection Name>] Remote URL : http-url Remote Request :<request-report-name>,<pre-request-display-report> : + <encoding type>
TDL_Reference_Manual.pdf
General and Collection Enhancements 240 XMLObject Path : <Start-node> : <Path-to-start-node> XMLObject : <TDL-Object-Name> Where, Remote-URL attribute is used to specify the URL of the HTTP server deliver ing the XML data Remote Request attribute is used to specify the Report name which is to be sen t to the HTTP server as an XML Request. If the report requires user inputs, t hen it has to be accepted before the request is sent. Pre-request display report specifies the name of the report which accepts the user-input. XMLObject Path attribute is used when only a specific fragment of the response XML is required, and converts the same to TDL Objects in the Collection. By defa ult, it takes the root node. <Start-Node> allows you to specify the name and position of the XML node fro m which the data should be extracted. It takes two parameters as follows: <Node Name> : <Position> <Path-to-Start-Node> is used to specify the path to reach the <start node> from the root node. The path specification is: <Root-node> : <Child Node> : <Start Pos> : <Child Node> : <Start Pos>... XMLObject attribute is used to specify the TDL Object specification. The following s yntax is used for object specification: [Object : <Object Name>] Storage : <Name> : Type Collection : <Name> : Type /* The second Parameter in the Collection T ype can be a Object type in case of a complex collection or a simple data type in case of simple collection */ All these attributes cater to specific requirements based on th e GET request or POST request, and whether the obtained data is stored in T ally. Prerequisites for data transfer over HTTP In order to retrieve the data available in Te s t X M L. x m l file from a remote server (Pre-defined IP Address), ensure that web service is running on the machine. Ch eck for IIS Server Installation. The file T est XML. xml can be copied to the directory C:\Inetpub\wwwroot to be accessible at the root and then the URL can be specified as follows: http://localhost/T est XML. xml. If the XML request needs to be processed at the remote server b y a file (. asp,. php, etc. ), at least one web server (e. g., IIS, Apache etc) and PHP/ASP must be inst alled on the system. Simple GET Request If it is required to access the data (XML format) from remote s erver in a collection, it is sufficient to specify the URL of the server only. The attribute Remote URL is used. The data thus obtained is available in the collection as o bjects and can be accessed as n ative methods. The collection to populate XML Data available at the URL http://Remoteserver/T est XML. xml is created as follows:
TDL_Reference_Manual.pdf
General and Collection Enhancements 24 1 Example: [Collection : XML Get Collection] Remote URL : "http://Remote Server/Test XML. xml" This collection can be used in a TDL Report to display the data retrieved. The method names will be same as the XML T ag names. By default, all the data from XML file is made available in the collection. If only a specific data fragment is required, it can be obtained using the collection a ttribute XML Object Path. Example: From the XML file, if only the address is required, then the collection is defined as follows: [Collection : XML Get Coll Obj Path] Remote URL : "http://Remoteserver/Test XML. xml" XML Object Path : ADDRESS:1:CUSTOMER Consider that the XML file on the remote server contains multip le customer objects, with the hierarchy mentioned earlier. The file “T est XML. xml” has the following structure: <CUSTOMERS> <CUSTOMER>.. </CUSTOMER><CUSTOMER>.. </CUSTOMER><CUSTOMER>.. </CUSTOMER> </CUSTOMERS> If the address of the second Customer is required, then the col lection is defined as shown: [Collection : XML Get Coll Obj Path] Remote URL : "http://Remoteserver/Test XML. xml"
TDL_Reference_Manual.pdf
General and Collection Enhancements 242 XML Object Path : ADDRESS : 1 : CUSTOMERS : CUSTOMER : 2 Consider that the Address further contains data as shown: <CUSTOMER>.. <ADDRESS> <PHONE> 9902012345 </PHONE> <PHONE> 9902099020 </PHONE></ADDRESS>. </CUSTOMER> In this case, to retrieve the second phone number of the third customer, the collection is defined as follows: [Collection : XML Get Coll Obj Path] Remote URL : "http://Remoteserver/Test XML. xml"XML Object Path : PHONE : 2 : CUSTOMERS : CUSTOMER : 3 : ADDRESS : 1 Simple GET Request and mapping the response to TDL Object The data available in XML format is at the URL “http://Remotese rver/T est XML. xml”. The data is required to be mapped as TDL Objects. The collection attribute XML Object is used to specify the object name to which the obtained data is mapped. Example: [Collection : XML Get Collection] Remote URL : "http://Remoteserver/Test XML. xml" XML Object : Customer Data The Object specification for “Customer Data” is as follows: [Object : Customer Data] Storage : Name : String Storage : Emp Id : String Collection : Phone : XML Phone Coll ;; Complex Collection Collection : ADDRESS : XML Address Coll ;; Complex Collection
TDL_Reference_Manual.pdf
General and Collection Enhancements 24 3 [Object : XML Phone Coll] Storage : Office No : String Storage : Home No : String Storage : Mobile : String [Object : XML Address Coll] Collection : Addr Line : String ;; Simple collection A Simple POST If a TDL report is to be sent to the HTTP server as an XML requ est, and the XML response is to be obtained in the collection, then the collection attribute “R emote Request” is used. The attribute “Remote Request” takes a Report name as a parameter, which send s the request in XML format to the web page on the remote server. The response data received from the server is then available in the collection. Example: The T est. php page on the remote server accepts the data in the following XML format. <ENVELOPE> <REQUEST> <NAME>Tally</NAME> <EMPID>00000</EMPID> </REQUEST> </ENVELOPE> The following collection sends the request in the above XML for mat with the help of a TDL report XMLPost Req Rep. The encoding scheme selected is ASCII. [Collection : XML Post Collection] Remote URL : "http://Remoteserver/test. php" Remote Request : XMLPost Req Rep : ASCII XMLObject Path : CUSTOMER The report XMLPost Req Rep is automatically executed when the collection is referred. In the Report, the XML T ag attribute is used at 'Part' and 'Field' Definitions. [Part : XMLPost Req Rep] XML Tag : "REQUEST" Scroll : Vertical [Field : XMLPost Req Rep Name]
TDL_Reference_Manual.pdf
General and Collection Enhancements 244 XML Tag : "NAME" Set As : " Tally " [Field : XMLPost Req Rep Pwd] XML Tag : " EMPID "Set As : " 00000 " The XML T ag <Envelope> is added by T ally while sending the XML request. The response received from http://Remoteserver/test. php page is the same XML given previously. The data now available in the collection can be displayed in a report. Post Request with Pre-request Report A Pre-Request report is required when some inputs are to be acc epted from the user, and the XML Request is to be generated out of those inputs. In that case, a TDL report is used which has to be accepted first. If the data captured through pre request report has to be sent to remot e server for processing, then it has to be made available in the Request report. The input report name is specified as Pre-Request report. [Collection : XML Post Collection] Remote URL : "http://localhost/test. php" Remote Request : XMLPost Req Rep, XML Pre Req Rep : ASCII XMLObject Path : CUSTOMER Report XMLPost Req Rep sends the XML request to the page T est. php in the format described earlier. Before sending the XML request to the page, data entered in th e report XML Pre Req Rep must be accepted. The data entered in the Pre-Request report ca n also be sent to the remote server in the XML request. Both the reports are triggered when the collection is referred. Action-HTTP POST A new Key/Button Action HTTP Post has been introduced which will help in exchanging data with external applications using web services. In other words, 'HTTP Post' Action can be used to submit data to a server over HTTP and gather the response. This will enable a TDL Report to perform an HTTP Post to a remote location. Syntax [Key : <Key Name>] Key : <Key Combination> Action : HTTP Post : <URL Formula> : <Encoding> : + <Request Report>: <Error Report> : <Success Report > Where, <URL Formula> can be any string formula which resolves as an URL, and is defi ned under System Definition. <Encoding> is the encoding scheme, which can be ASCII or UNICODE.
TDL_Reference_Manual.pdf
General and Collection Enhancements 24 5 <Request Report> is the name of TDL Report used for generating the XML Request t o be sent. <Error Report > is displayed in case of failure. <Success Report> is displayed when the post is successful. Details pertaining to URL (at the receiving end), Encoding Form at, Request Report, Error Report and Success Report should be specified along with HTTP Post Action. Universal Resource Locator ( URL), for which information is intended, has to be specified throu gh a System Formula. Encoding Format specifies the encoding to be used while transmi tting information to the receiving end. The valid encoding formats are ASCII and UNICODE. UNICODE is s et by default. Request Report is the name of the TDL Report which will be used for generating XML Request to be sent. Error Report and Success Reports are optional, and wil l enable the programmer to display a Report with the details of the XML response received. Success or failure is determined by <ST A TUS> tag in the standar d message format. If it is 1, it is a success, otherwise it is a failure. Based on the value of the < ST A TUS> tag (0/1), the error report and success report are executed, respectively. It will not close or accept the form, if status is not equal to 1. Both Request as well as Response are exchanged in X ML format. Example: [Key : XMLReq Resp] Key : Ctrl + RAction : HTTP Post : @@My Url : ASCII : Req Rep: ERRResp Rep : Succ Rep Scope : Selected Lines ;;URL Specification must be done as a system formula [System : Formula] My Url : http://127. 0. 0. 1:9000 The defined Key XMLReq Resp in the code snippet must be attached to an initial Report. When the report is activated and this Key is pressed, the Action HTT P Post activates a defined report Req Rep, which generates the request XML. The response data is m ade available in the collection called Parameter Collection. The reports ERRResp Rep and Succ Rep can use the Parameter Collection to display the error message/data in the Report. 11. 4 Usage As T ables A Collection in TDL, as we all understand, can populate the data from a wide range of sources, which are available as Objects in the Collection. The various sources of Objects in Collection are:The XML response received for the action HTTP POST must be in the T ally compatible XML format. The file “XML for HTTP POST” shows the format received as a reponse from the PHP application file “CXMLResponse as per T ally”.
TDL_Reference_Manual.pdf
General and Collection Enhancements 246 External Objects, i. e., Objects created by the TDL programmer. Internal Objects, i. e., All Internal Objects provided by the platform, and store d in the T ally DB. For example, Ledger, Group, Voucher, Cost Centre, Stock Item, etc. Objects populated in the collection from an external database u sing ODBC, referred to as ODBC Collection. Objects populated in collection from an XML file present on the remote server over HTTP. This collection is referred to as an XML Collection. Objects obtained after aggregation of data from lower level in the hierarchy of internal objects. T ables are based on Collections. Prior to this release, not all collection types, as given above, could be used as tables. Not all internal objects were availabl e in the T able. Only the masters, i. e., Groups, Ledgers, Stock Items, etc., could be displayed in the T able. Using Vouchers in the table was not possible. Data from ODBC Collection was also not possib le to be displayed. From this Release onwards, all limitations pertaining to the us age of Collections as T ables have been completely eliminated. Any Collection which can be created in TDL can be displayed as a table now. Collection with Aggregation and XML Collections can also be us ed as T ables. Prior to this release, the following types of Collections could not be used as T ables : Voucher Collection As T able Collections with Aggregation As T able Displaying information at lower levels in Object hierarchy in a T able Displaying aggregate methods in T able Displaying ODBC Collection As T able Displaying XML Collection As T able Let us consider the following examples to understand the capabi lity in a better way: V oucher Collection As T able Now, the Vouchers can be displayed as table in a field. Example: Voucher Collection as Table [Collection : Vch Collection] Type : Voucher Filter : Purc Filter Format : $Voucher Number, 10Format : $Voucher Type Name, 25 Format : $Party Ledger Name, 25 Format : $Amount, 15 [System : Formula]
TDL_Reference_Manual.pdf
General and Collection Enhancements 24 7 Purc Filter : $$Is Purchase : $Voucher Type Name ;;Field displaying Table [#Field : EI Order Ref] Table : Vch Collection Show Table : Always Collection with Aggregation As T able Example: Displaying Inventory Entries (lower level information in Voucher) As Table [Collection : Vch Collection] Type : Voucher Filter : Purc Filter [Collection : Summ Collection] Source Collection : Vch Collection Walk : Inventory Entries By : Name : $Stock Item Name [System : Formula] Purc Filter : $$Is Purchase:$Voucher Type Name ;; Field displaying Table [#Field : EI Order Ref] Table : Summ Collection Show Table : Always Example: Displaying Collections with aggregate methods As Table [Collection : Vch Collection] Type : Voucher Filter : Purc Filter [Collection : Summ Collection] Source Collection : Vch Collection Walk : Inventory Entries By : Name : $Stock Item Name Aggr Compute : Billed Qty : Sum : $Billed Qty
TDL_Reference_Manual.pdf
General and Collection Enhancements 248 Aggr Compute : Amount : Sum : $Amount Format : $Name, 25 Format : $Billed Qty, 25 Format : $Amount, 25 [System : Formula] Purc Filter : $$Is Purchase : $Voucher Type Name ;;Field displaying table [#Field : EI Order Ref] Table : Summ Collection Show Table : Always ODBC Collection As T able Example: Data fetched from Excel file in Collection displayed a s Table In this example, the excel file “Sample Data. xls” containing data is present in the path “C:\Sample Data. xls ”. If the complete path is not specified, it locates the Excel file in T ally application folder. [Collection : ODBC Excel Collection] ODBC : "Driver= {Microsoft Excel Driver (*. xls)};DBQ= C: + \Sample Data. xls"SQL : "Select * From [Ledgers$]" Format : $_1, 25 Format : $_2, 20Format : $_3, 15 Format : $_4, 25 ;; Field displaying table [#Field : EI Order Ref] Table : ODBC Excel Collection Show Table : Always XML Collection as T able This refers to XML Data fetched from Remote URL in Collection a s T able. Following is the XML Data Sample to be retrieved from the Remote URL: <CUSTOMER>
TDL_Reference_Manual.pdf
General and Collection Enhancements 24 9 <NAME>Keshav</NAME> <ADDRESS> <ADDRLINE>Line1</ADDRLINE> <ADDRLINE>Line2</ADDRLINE><ADDRLINE>Line3</ADDRLINE> </ADDRESS> <ADDRESS> <ADDRLINE>Line1</ADDRLINE> <ADDRLINE>Line2</ADDRLINE> <ADDRLINE>Line3</ADDRLINE> </ADDRESS> </CUSTOMER> In this example, the complete URL of the file is http://localhost/XMLData. xml. Here, the file XMLData. xml is located in the local machine. Instead of local host, the IP Address of the machine or 127. 0. 0. 1 can be specified. The web service should be installed in the machine. Example: [Collection : XML Table] Remote URL : "http://localhost/XMLData. xml"XMLObject Path : CUSTOMERFormat : $NAME, 25 ;; Field displaying Table [#Field : EI Order Ref] Table : XML Table Show Table : Always 11. 5 Dynamic Object support for HTTP-XML Information Interchan ge When a Collection is used for editing (alter/create), objects a re dynamically added to the collection when a new line is repeated over the same. The type of the object added depends on the specification in the TYPE attribute. In case the TYPE attribute has not been specified, it defaults to adding a standard empty object. So if the TYPE is ledger, a ledger object would be added, and so on. However, the following hold true for a COLLECTION, keeping in mind the latest enhancements:
TDL_Reference_Manual.pdf
General and Collection Enhancements 250 It can be made up of multiple types of objects (say Ledgers and Groups). It can have TDL defined objects which are retrieved from XML fi le. They are specified using XML Object. It can have aggregated objects. Depending solely on the TYPE attr ibute for deciding the object type is a constraint with respect to the above facts. This is now being removed with the introduction of a new attri bute which will independently govern the type of object to be added to the coll ection on-the-fly. The following is now supported in collection: NEWOBJECT : type-of-object : condition Whenever a new object is to be added at the collection level, i t will walk through the NEWOBJECT attribute specification and validate the condition specified. T he first one which is satisfied, decides the type of object to be added. The object c an be a schema defined internal object or a TDL defined object [OBJECT : MYOBJECT]. The capability to use objects defined in TDL is being separatel y enhanced and shown here for completeness of the NEW OBJECT attribute. As of now, these TDL defined objects can be used only for HTTP-XML based exchange with other systems to take inp ut and send requests or receive XML and operate them like TDL objects. They cannot be p ersisted or saved into the T ally company database. Please refer the following code snippet for Object specificatio n: Example: This collection can be used in a Report opened in 'Alt er' Mode. [Collection : Coll Customer] New Object : Customer Data ;; New TDL Object Defined [Object : Customer Data] Storage : Name : String Storage : Cust Id : String Collection : Phone Coll : Phone ;; Complex Collection Collection : Address Coll : Address ;; Complex Collection [Object : Phone] Storage : Office No : String Storage : Home No : String Storage : Mobile : String [Object : Address] Storage : Addr Line1 : String Storage : Addr Line2 : String
TDL_Reference_Manual.pdf
General and Collection Enhancements 25 1 In case there is no NEW OBJECT specified, the existing behavior will continue for backward compatibility. In case of Sub-Objects like Ledger Entries, the same behaviour continues, since they are added by their parent objects and not by the Collection. 12. Collection Capabilities for Remoting Enabling access to your organizational data 'any-time, any-wher e', and yet being truly usable, is what T ally. ERP 9 is capable of. With remote access through Tall y. NET Server, it will be possible for any authorized user to access T ally. ERP 9 from anywhere. Major Enhancements have taken place at the collection level to achieve remoting capabilities. The attributes 'Fetch', 'Compute' and 'Aggr Compute', provided a t the Collection level, and the attributes 'Fetch Object' and 'Fetch Collection' at the Report le vel, significantly help in the above functionality. The remoting capabilities are discussed in detail in the next s ection II “Writing Remote Compliant TDL for T ally. ERP 9”.
TDL_Reference_Manual.pdf
TDL_Reference_Manual.pdf
253 User Defined Functions Introduction TDL is a comprehensive 4G language which gives tremendous power in the hands of the programmer by providing data management, complex report generat ion and screen design capabilities using only a few lines of code, leading to rapid development. Before the introduction of User- defined functions, TDL had very few aspects of procedural progr amming. T o mention a few: V alue calculations were achieved using System Formula, or by wr iting external methods at object level. Repetitive execution of certain lines of code was possible usin g certain platform defined functions like $$Collection Field, $$Collection Amt T otal, etc. Th e functions used to take care of these implicitly. Sequential execution of certain segments of code was achieved b y using an Action list. Now, with the introduction of “User Defined Functions”, a path-brea king development in the history of TDL, procedural programming aspects have been introd uced into the language, along with preserving the basic nature of a definition language. 1. Functions-In General In procedural languages, Functions are called as Subroutines or Procedures. If it is required to execute a certain set of statements repeatedly to achieve a cer tain functionality, it is not a good programming practice to write the same set of statements in the program again and again. For example, n separate statements in a computer program require the sum of tw o numbers for some complex computation. Each statement will repeatedly compute a+b, with different set s of a and b. T o avoid this, a function is created, which will accept 'a' and 'b' and return the result, i. e., the sum, to the calling program. This reduces the no of lines in the cod e, along with improving the code readability. A function accepts certain values, processes the values in a ce rtain manner and finally returns a value to the calling program. The values which a function accep ts or the calling program passes to the function are called Parameters, and the result which is passed by the function to the calling program is called the Return value. A function is mainly used for some of the following purposes: 1. Repeating a block of code 2. Performing some calculations 3. Executing a set of statements
TDL_Reference_Manual.pdf
User Defined Functions 254 2. Functions-In TDL In TDL, prior to T ally. ERP 9, Functions were defined by the Pla tform and the TDL programmer could only call the function to achieve a certain functionality. From T ally. ERP 9 onwards, functions can be defined in the TDL layer. User Defined Function in TDL has been provided as a Definition which allows the user to specify a set of actions/statements to be executed, in the order as specified. Traditionally, TDL was always a non-procedural, action-driven language. The sequence of execution was not in the hands of the programmer. But, with this development in a 'Function' Definition, Conditional evaluation of statements and looping ha s been made possible. User defined Functions basically can be used f or performing complex calculat ions or executing a set of actions serially. Functions can accept parameter(s) as input, and return a 'V alu e' to the caller. Functions give the following benefits to the TDL programmer: Conditional execution/evaluation of statements Execution of a set of statements repeatedly, generally referred to as loops Defining variables and storing values from intermediate calcula tion/process Accepting parameters from the calling segment of code Working on data elements like getting an object from the callin g context, defining the function execution context, looping on the objects of a collect ion, etc. Returning a 'V alue' to the caller of the function Performing a set of actions sequentially/conditionally or repea tedly, without returning a value. With this development, the programmers can write business funct ions with complex computations by themselves, without platform dependency. 3. Function-Building Blocks In TDL, 'Function' is also a definition. It has two blocks: 1. Definition Block 2. Procedural Block A glimpse into the function: [Function : Function Name] ;; Definition Block ;; Parameter Specification Parameter : Parameter 1 : Datatype Parameter : Parameter 2 : Datatype ;; Variable Declarations Variable : Var 1 : Number Variable : Var 2 : String
TDL_Reference_Manual.pdf
User Defined Functions 25 5 ;; Explicit Object Association Object : Obj Name : Object Type ;;Return Value Returns : Datatype ;;Definition Block Ends here ;;Procedural Block Label 1 : Statement 1 Label 2 : Statement 2 | | Label n : Statement n ;; Procedural Block Ends here 3. 1 Definition Block The definition Block is utilized for the following purposes: Parameter specification This implies specifying the list of parameters which are passed by the calling code. The values thus obtained, are referred to in the function with these varia ble names. The syntax for specifying the same is given below: Syntax PARAMETER : <Variable Name> : <Data Type of the Variable> Where, <Variable Name> is the name of the V ariable which holds the parameter sent by t he caller of the Function. <Data T ype of the Variable> is the Data type of the V ariable sent by the caller of the Func tion. Example: [Function : Factorial Of] Parameter : Input Number : Number The Function '$$Factorial Of' receives number as the parameter f rom the Caller. Variable declaration If a Function requires some V ariable(s) for intermediate calcul ation, then those V ariable(s) need to be defined. The scope of these V ariable(s) will be within the F unction, and the V ariable(s) lose their value after exit from the Function. Syntax VARIABLE : <Variable Name> [:<Data Type of the Variable>]
TDL_Reference_Manual.pdf
User Defined Functions 256 Where, <Variable Name> is the name of the V ariable. <Data T ype of the Variable> is the Data type of the V ariable. Datatype is optional. If datatype is specified, a separate V ari able definition is not required (these are considered as in-line variables). If data type is not speci fied, the interpreter will look for a variable definition, with the name specified. Example: [Function : Factorial Of] Parameter : Input Number : Number Variable : Counter : Number Variable : Factorial : Number The Function '$$Factorial Of' requires intermediate V ariables 'C ounter' and 'Factorial' for calculation within the 'Function' Definition. Static Variable declartion Static V ariable is a V ariable, whose value persists between successive calls to a Function. The scope of the static variable is limited to the Function in which it is declared, and exists for the entire session. Syntax STATIC VARIABLE : <Variable Name> [:<Data Type of the Variable>] Where, <Variable Name> is the name of the Static V ariable <Data T ype of the Variable> is the Data type of the Static V ariable. Datatype is optional. If datatype is specified, a separate V ari able definition is not required (these are considered as in-line variables). If data type is not speci fied, the interpreter will look for a variable definition with the name specified. Example: [Function : Sample Function] Static Variable : Sample Static Var : Number The static variable 'Sample Static V ar' retains the value betwe en successive calls to the Function 'Sample Function' Return value specification If a Function returns a value to the caller, then its data type is specified by using 'RETURNS' statement. Syntax RETURNS : <Data Type of the Return Value>
TDL_Reference_Manual.pdf
User Defined Functions 25 7 Where, <Data T ype of the Return Value > is the Data type of the return value of the Function. Example: [Function : Factorial Of] Parameter : Input Number : Number Returns : Number Variable : Factorial : Number The Function '$$Factorial Of' returns the value of type 'Number' to the caller of the Function Object specification Function will inherit the Object context of the caller. This can be overridden by using the attribute 'Object' for 'Function' definition. This now becomes the curren t object for the function. Syntax Object : <Obj Type> : <Obj Id Value> Where, <Obj T ype> is the type of the object, and <Obj Id Value> is the unique identifier of the object. Example: [Function : Sample Function] Object : Ledger : “Party” The Function 'Sample Function' will be in the context of the Le dger 'Party' 3. 2 Procedural Block This block contains a set of statements. These statements can e ither be a programming construct or an Action specification. Every statement inside the procedur al block has to be uniquely identified by a label specification. Syntax LABEL SPECIFICATION : Programming Construct Or LABEL SPECIFICATION : Action: Action Parameter Example: [Function : Disp Stock Summary] 01 : Display : Stock Summary 02 : Display : Stock Category Summary The Function 'Disp Stock Summary' is having two Actions with Labe l.
TDL_Reference_Manual.pdf
User Defined Functions 258 4. Valid Statements inside a Function The statements used inside the procedural block of a function c an be: A Programming Construct, as disc ussed in the previous sections A TDL Action There have been major changes in some actions to work especiall y with functions. Some new actions have been introduced as well. Let us now discuss the va rious Actions used inside functions. 4. 1 Programming Constructs In Function Conditional Constructs IF-ENDIF The 'IF-ENDIF' statement is a powerful decision making statemen t and is used to control the flow of execution of statements. It is basically a two-way decision statement and is used in conjunction with an expression. Initially, the expression will be evaluated and based on the whether the expression is True or False, it transfers the execution flow to a particular statement. Figure 13. 1 Flow C hart for IF-ENDIF Syntax IF : <Condition Expression> STATEMENT 1 ... STATEMENT N ENDIF
TDL_Reference_Manual.pdf
User Defined Functions 25 9 Example: If the Function parameter sent to the Function 'Factorial Of' is less than zero, then it is multiplied by-1 to find the absolute value. [Function : Factorial Of] Parameter : Input Number : Number Returns : Number Variable : Counter : Number Variable : Factorial : Number1 : SET : Counter : 12 : SET : Factorial : 1 3 : IF ##Input Number < 0 4 : SET : Input Number : ##Input Number *-15 : END IF 6 : WHILE : ##Counter <= ##Input Number 7 : SET : Factorial : ##Factorial * ##Counter8 : SET : Counter : ##Counter + 1 9 : END WHILE 10 : RETURN ##Factorial DO-IF When an IF-ENDIF statement block contains only one statement, t hen the same can be written in a single line by using DO-IF statement. Syntax DO IF : <Condition Expression> : STATEMENT Example: Here, IF-END IF statement is rewritten using the DO-IF statement. [Function : Factorial Of] Parameter : Input Number : Number Returns : Number Variable : Counter: Number Variable : Factorial : Number 1 : SET : Counter : 1
TDL_Reference_Manual.pdf
User Defined Functions 260 2 : SET : Factorial : 1 3 : DO IF : ##Input Number < 0 : ##Input Number *-1 4 : WHILE : ##Counter <= ##Input Number 5 : SET : Factorial : ##Factorial * ##Counter6 : SET : Counter : ##Counter + 1 7 : END WHILE 8 : RETURN ##Factorial IF-ELSE-ENDIF The IF-ELSE-ENDIF statement is an extension of the simple IF-EN DIF statement. If the condition expression is True, then the 'True' block's statement (s) are executed; otherwise, the 'False' block's statement(s) are executed. In either case, either the True block or the False block will be executed, not both. Figure 13. 2 Flow Chart for IF-ELSE-ENDIF Syntax IF : <Condition Expression> STATEMENT 1 ... STATEMENT N ELSE STATEMENT 1
TDL_Reference_Manual.pdf
User Defined Functions 26 1 ... STATEMENT N ENDIF Example: Finding the greatest of three numbers [Function : Find Greatest Numbers] Parameter : A : Number Parameter : B : Number Parameter : C : Number RETURNS : Number 01 : IF : ##A > ##B 02 : IF : ##A > ## 03 : RETURN : ##A 04 : ELSE05 : RETURN : ##C 06 : END IF 07 : ELSE08 : IF : ##B > ##C09 : RETURN : ##B 10 : ELSE 11 : RETURN : ##C12 : END IF 13 : END IF Looping Constructs WHILE-ENDWHILE In looping, a sequence of statements is executed until some con dition(s) for termination of the loop is satisfied. A typical loop consists of two segments, one known as the body of the loop and the other known as the control statement. The control statement checks the condition and then directs the repeated execution of the statements contained in t he body of the loop. The WHILE-ENDWHILE is an entry-controlled loop statement. The condition expression is evaluated and if the condition is True, then the body of the lo op is executed. After the execution of the statements within the body, the condition expression is once again evaluated and if it is True,
TDL_Reference_Manual.pdf
User Defined Functions 262 the body is executed once again. This process of repeated execu tion of the body continues until the condition expression finally becomes False, and the control is transferred out of the loop. Figure 13. 3 Flow Chart for WHILE-ENDWHILE Syntax WHILE : <Condition Expression> STATEMENT 1 ... STATEMENT N ENDWHILE Example: [Function : Factorial Of] Parameter: Input Number : Number Returns : Number Variable : Counter : Number Variable : Factorial : Number1 : SET : Counter : 1 2 : SET : Factorial : 1 3 : WHILE : ##Counter <= ##Input Number4 : SET : Factorial : ##Factorial * ##Counter 5 : SET : Counter : ##Counter + 1
TDL_Reference_Manual.pdf
User Defined Functions 26 3 6 : END WHILE 7 : RETURN ##Factorial The Function 'Factorial Of' repeats statements 4 and 5, till the given condition is satisfied. WALK COLLECTION-END WALK If a Collection has 'n' Objects, then WALK COLLECTION-ENDWALK will be repeated for 'n' times. Body of the loop is executed for each object in the coll ection, making it the current context. Figure 13. 4 Flow Chart for W ALK COLLECTION-ENDW ALK Syntax WALK COLLECTION : <Collection Name> STATEMENT 1 ... STATEMENT N ENDWALK Example: Walking over all the Vouchers and counting the same. [Collection : Vouchers Coll] Type : Voucher [Function : Count Vouchers] Returns : Number Variable : Count : Number
TDL_Reference_Manual.pdf
User Defined Functions 264 001 : SET : Count : 0 002 : WALK COLLECTION : Vouchers Coll 003 :SET: Count : ##Count + 1 004 : END WALK 005 : RETURN : ##Count Control Constructs Loops perform a set of operations repeatedly until the conditio n expression satisfies the given condition or the Collection is exhausted. Sometimes, when execu ting the loop, it becomes desirable to skip the part of the loop or to exit the loop as a certain condition occurs, or to save the current state and return back to the current state later. BREAK When a BREAK statement is encoun tered inside the loop, the loop is immediately exited and the control is transferred to the statement immediately following t he loop. BREAK statement can be used inside WHILE-END WHILE and WALK COLLECION-END WALK. When loops are nested, the Break would only exit from the loop containing it. Syntax BREAK Example: [Function : Print Numbers] Variable : Counter: Number1 : SET : Counter: 1 2 : WHILE : ##Counter < = 10 3 : LOG : ##Counter4 : IF : ##Counter > 5 5 : BREAK 6 : END IF7 : SET : Counter : ##Counter + 18 : ENDWHILE 9 : RETURN In the Function 'Print Numbers', the loop is running from 1 to 1 0. But because of BREAK statement, the loop will be terminated as the counter reaches 6.
TDL_Reference_Manual.pdf
User Defined Functions 26 5 CONTINUE In some scenarios, instead of terminating the loop, the loop needs to be continued with next iteration, after skipping any statements in between. For this p urpose, CONTINUE statement can be used. CONTINUE statement can be used inside WHILE-END WHILE a nd WALK COLLECION- END WALK. Syntax CONTINUE Example: Function to Count the total number of Journal Vouchers [Collection : Vouchers Coll] Type : Voucher [Function : Count Journal] Returns : Number Variable : Count : Number 01 : SET : Count : 002 : WALK COLLECTION : Vouchers Coll 03 : IF : NOT $$Is Journal : $Voucher Type Name 04 : CONTINUE05 : ENDIF 06 : Count : ##Count + 1 07 : END WALK08 : RETURN : ##Count ST ART BLOCK-END BLOCK ST ART BLOCK--END BLOCK has been introduced to save the current state and ex ecute some actions within the block and return back to the original state. This is handy in cases where the Object context needs to be temporarily switched for the purpose of executing some actions. Current source and target object contexts are saved and the fur ther statements within the ST ART BLOCK and END BLOCK section get executed. Once the END BLOCK is encountered, the Object context is restored back to the original state. Syntax START BLOCK Block Statements END BLOCK
TDL_Reference_Manual.pdf
User Defined Functions 266 Example: 10 : WALK COLLECTION : EDColl Details Extract 11 : INSERT COLLECTION OBJECT : Inventory Entries 12 : SET : Qty Var : $$String:$Qty + " Nos" 13 : SET : Amt Var : $$String : $Amt14 : START BLOCK 15 : SET OBJECT 16 : SET VALUE : Actual Qty : $$As Qty : ##Qty Var17 : SET VALUE : Billed Qty : $$As Qty : ##Qty Var 18 : SET VALUE : Amount : $$As Amount : ##Amt Var 18A : END BLOCK 19 : SET TARGET :... 20 : SET VALUE : Stock Item Name : $Item 21 : END WALK ;; For Explanation on Object context, i. e., Source Object and T arget Object, ;; Set T arget, Set Object, etc., please refer to the T opic 'Function Execution-Object Context' In this code snippet, the collection 'EDColl Details Extract' is being walked over and the values for the Objects within Voucher Entry are being set. RETURN This statement is used to return the flow of control to the cal ling program, with or without returning a value. When RETURN is used, the e xecution of the function is te rminated and the calling program continues from where it had called the function. Syntax RETURN : <value expression> Where, <value expression> is optional, i. e., it can either return a value or return void. Example:The Function 'Factorial Of' returns factorial of number [Function : Factorial Of] Parameter : Input Number : Number Returns : Number Variable : Counter : Number Variable : Factorial : Number
TDL_Reference_Manual.pdf
User Defined Functions 26 7 1 : SET : Counter : 1 2 : SET : Factorial : 1 3 : WHILE : ##Counter <= ##Input Number 4 : SET : Factorial : ##Factorial * ##Counter5 : SET : Counter : ##Counter + 1 6 : ENDWHILE 7 : RETURN : ##Factorial 4. 2 Actions used in a TDL Function Actions for Variable Manipulation TDL provides various new actions that can be used inside User D efined Functions. SET This action is used to assign a value for a variable. Syntax SET : <Variable Name> : <Value Expression> Where, <Variable Name> is the variable for which the value needs to be assigned. <Value Expression> is the formula evaluating to a value. Example: [Function : Factorial Of] Parameter : Input Number : Number Returns : Number Variable : Counter : Number Variable : Factorial : Number1 : SET : Counter: 1 2 : SET : Factorial: 1 3 : WHILE : ##Counter <= ##Input Number4 : SET : Factorial : ##Factorial * ##Counter 5 : SET : Counter : ##Counter + 1 6 : ENDWHILE7 : RETURN : ##Factorial
TDL_Reference_Manual.pdf
User Defined Functions 268 EXCHANGE This action is used to exchange (swap) the values of two variab les. But, values of only the variables of the same Data type can be exchanged. Syntax EXCHANGE : <First Variable Name> : <Second Variable Name> Where, <First Variable Name> and <Second Variable Name> are the V ariables whose values need to be swapped. Example: 01 : EXCHANGE : Var1 : Var2 In this statement, both variables are of type 'Number' and thei r values are swapped. INCREMENT This action is used to increment the value of variables by any numerical value. INCREMENT is used inside the loop to increment value of control variables. You can specify multiple variables by separating them with a co mma. Syntax INCREMENT : <Variable Name> [,<Variable Name>,... ] [:<Number Expression>] Where, <Variable Name> is the name of the variable whose value needs to be incremented. <Number Expression> is the numerical value by which the variable needs to be increm ented. If no number is given, the variabl e will be incremented by 1. Example: [Function: VATVchr Col Walk_Inv_GUJ_Annx Error_Load VAR] If : ##GUJe VATAnex201BError Increment : v VATAnx Total Count, v VATAnx Error Count, v VATAnx201BTotal Count, v VATAnx201BError Count Else Increment : v VATAnx Total Count, v VATAnx201BTotal Count End If The keyword Last will only work from release 5. 4. 8.
TDL_Reference_Manual.pdf
User Defined Functions 26 9 DECREMENT This action is used to decrement the value of variables by any numerical value. DECREMENT is used inside the loop to decrement the value of the control variables. Syntax DECREMENT : <Variable Name> [,<Variable Name>,... ] [:<Number Expression>] Where, <Variable Name> is the name of the variable whose value needs to be decremented by the number specified. <Number Expression> is the numerical value by which the variable needs to be decrem ented. If no number is given, the variabl e will be decremented by 1. Example: [Function : Print Numbers] Variable : Counter : Number 1 : SET : Counter : 102 : WHILE : ##Counter > 0 3 : LOG : ##Counter 4 : DECREMENT : Counter5 : ENDWHILE 6 : RETURN In the function 'Print Numbers', the loop is running from 10 to 1. Action Enhancements and New Actions The global actions have been enhanced, so that they can be call ed from the User Defined Functions. Some new actions have also been introduced. Global Actions-Alter/Execute/Create These are global actions meant for the purpose of opening a rep ort in the mode specified. The return value of these actions is FALSE, if the user rejects the report, and TRUE, if the user accepts it. Syntax Display/Alter/Execute/Create : Report Name Example: [Function : Create Report] 01 : Create : Ledger The Function 'Create Report' opens the Ledger Creation screen.
TDL_Reference_Manual.pdf
User Defined Functions 270 Global Actions-MENU, DISPLA Y These global actions are used to invoke a menu or a report in D isplay mode. The return value of these actions is TRUE if Ctrl+Q is used to reject the report (i. e., via Form Reject T o Menu action). It returns FALSE when user uses 'Esc' to reject the report (i. e., v ia ' Fo rm Acc ep t ' a ct i on ). Fo r menu, this is only applicable if it is the first in the stack. Syntax Menu : <Menu name> Display : <Report Name> Example: [Function : Disp Pay Sheet] 01 : Menu : Statements of Payroll02 : Display : Pay Sheet The Function 'Disp Pay Sheet' opens the Pay Sheet and by pressing Escape, it will pop up the 'Statements of Payroll' Menu. MSG BOX This action is used to Display a message box to the user. It comes back to the original screen on the pressing of a key. This can be used by the programmers to display intermediate va lues of variables during calculations, th us helping in error diagnosis. Syntax MSG BOX : <Title Expression> : <Message Expression> : <Grey Back Flag> Where, <Title Expression> is the value that is displayed on the title bar of the message window. <Message Expression> is the actual message which is displayed in the box. This can b e an expression as well, i. e., the variable values can be concatenated and displayed along wi th the message in the display area of the box. <Grey Back Flag> indicates if the background window is to be greyed out during m essage display. It takes two values, i. e., YES/NO Example: 01 : MSGBOX : ”Return Value” : ##Factorial QUERY BOX This action is used to Display a confirmation box to the user a nd ask for a Y es/No response. Syntax QUERY BOX : <Message Expression> : <Grey Back Flag> : <Esc As Yes> Where, <Message Expression> is the message which is display ed inside the box. This can be a n expression.
TDL_Reference_Manual.pdf
User Defined Functions 27 1 <Grey Back Flag> indicates if the background window is to be greyed out during m essage display. It takes two values, i. e., YES/NO <Escape as Yes> is a flag which indicates the response when the user presses th e ESC key. This can be specified as YES/NO. A YES value for this flag indicates that the response should b e treated as YES on pressing of an ESC key. LOG During expression evaluation, intermediated values of the expre ssion can be passed to calculator window and a log file 'tdlfunc. log' inside the application dire ctory. This is very much helpful for debugging the expression. By default, logging is enabled inside the function. Syntax LOG : < Expression> Where, <Expression> is the expression whose value needs to be passed to the calcula tor window. Example: While finding the factorial of a number, intermediated values are outputted to the 'Calculator' window using LOG action [Function : Factorial Of] Parameter : Input Number : Number Returns : Number Variable : Counter : Number Variable : Factorial : Number 1 : SET : Counter : 1 2 : SET : Factorial : 1 3 : WHILE : ##Counter <= ##Input Number4 : SET : Factorial : ##Factorial * ##Counter5 : SET : Counter : ##Counter + 1 5a : LOG : ##Factorial 6 : ENDWHILE7 : RETURN : ##Factorial SET LOG ON While debugging a Function, sometimes it is required to conditi onally Log the values of an expression. If logging is stopped, then logging can be re-started based on the condition Action S ET LOG ON. This Action does no t require any parameter. Syntax SET LOG ON
TDL_Reference_Manual.pdf
User Defined Functions 272 SET LOG OFF This Action is used in conjuncti on with SET LOG ON. Log can be stopped by the Action SET LOG OFF. This Action does not require any parameter. Syntax SET LOG OFF SET FILE LOG ON This Action is similar to SET LOG ON. SET FILE LOG ON is used t o conditionally Log the values of an expression to log file ' tdlfunc. log '. This Action does not require any parameter. Syntax SET FILE LOG ON SET FILE LOG OFF This Action is used in conjunction with SET FILE LOG ON. Loggin g the file 'tdlfunc. log' can be stopped by the Action SET LOG OFF. This Action does not require any parameter. Syntax SET FILE LOG OFF Progress Bar Actions Sometimes, a Function may take some time to complete the task. It is always better to indicate the user whether the task is occurring, how long the task might take and how much work has already been done. One way of indicating the amount of progress is to use an anim ated image. This can be achieved by usi ng the following Actions: ST ART PROGRESS SHOW PROGRESS END PROGRESS Action-ST ART PROGRESS This Action sets up the Progress Bar by mentioning the total nu mber of steps involved in the task. In addition to this, the Title, Sub Title and Subject of the Pro gress Bar can also be given as parameters. Syntax START PROGRESS : <Number of steps> :< Title> [:< Sub Title> :< Subject>] Where, <Number of steps> denotes the whole task quantified as a number. <Title>, <Sub Title> and <Subject> Shows the Title, Sub Title and Subject of the Progress Bar, respectively. Example: START PROGRESS : ##Total Steps : ”TDS Migration”:+ @@Cmp Mail Name : ”Migrationg Vouchers..”
TDL_Reference_Manual.pdf
User Defined Functions 27 3 Action-SHOW PROGRESS This Action shows the current status of the task to the user. Syntax SHOW PROGRESS : <Number of Steps Completed> Where, <Number of Steps Completed> is a number which denotes the amount of work completed. Example: SHOW PROGRESS : ##Counter Action-END PROGRESS When a task is completed, the Progress Bar can be stopped by us ing the Action END PROGRESS. This Action does not take any parameter. Syntax END PROGRESS Actions-For Object and Context Manipulation As already seen in previous sections, functions can operate on 3 object contexts, i. e., Requestor, Current Object and T arget object context. When a function is in voked, the target object context will be the same as the current object context of the caller, i. e., the target object will be set to the current object. Here, we will discuss the various actions for manipulation of O bject and Context. Action-NEW OBJECT This action creates a new object from object specification and sets it as the target object. It takes only Primary Object as the Parameter. Syntax NEW OBJECT : <Obj Type>:<Obj Id Value> Where, <Obj T ype> is the type of the object to be created, and <Obj Id Value> is the unique identifier of the object. If this is an existing object in DB, then the further manipulations are performed on that object, else it cre ates a new object altogether. Example: 01 : NEW OBJECT : Stock Item : ”My Stock Item” This creates a new object in memory for Stock Item and sets it as the target object. Later, by using other methods of this, the target object can be set and saved t o the T ally DB. Action-INSERT COLLECTION OBJECT This action inserts the new object of the type specified in the collection and makes it as the current target object. This object is inserted into the collect ion at the end. This Action takes only Secondary Collection as the parameter.
TDL_Reference_Manual.pdf
User Defined Functions 274 Syntax INSERT COLLECTION OBJECT : <Collection Name> Where, <Collection Name> is the name of the Secondary Collection. Example: 01 : INSERT COLLECTION OBJECT : Ledger Entries This insets a new object 'Ledger Entries' in memory under Vouch er, and sets it as the target object. Later, by using other methods of this, the target object can be set a nd saved to T ally DB. Action-SET V ALUE This action sets the value of a method for the target object. T he value formula is evaluated with respect to the current object context. This can use the new met hod formula syntax. Using this, it is possible to access any value from the current object. Syntax SET VALUE : <Method Name>[: <Value Formula>] Where, <Method Name> is the name of the method, and <Value Formula> is the value which needs to be set to the method. It is optiona l. If the second parameter is not specified, it searches for the same method in the context object and the value is set based on it. If the source method name is same as in T arget Object, then the Source Object method name is optional. Example: 1 01 : SET VALUE : Ledger Name : $Ledger Name OR 01 : SET VALUE : Ledger Name These statements set the values of 'Ledger Entries' Object from the current Object context. Example: 2 02 : WALK COLLECTION : Vouchers of My Objects 03 : NEW OBJECT : Voucher ;; Since the methods Date, Voucher T ype Name are same in the source object and target object, they are not specified again as SET VALUE : DA TE : $Date. 04 : SET VALUE : Date 05 : SET VALUE : Voucher Type Name
TDL_Reference_Manual.pdf
User Defined Functions 27 5 Example: 3 [Function : Sample Function] Object : Ledger : "Party 1" 01 : NEW OBJECT : Ledger : "Party 2" ;; absence of Value expression will assume th at same method to be copied from source 02 : SET VALUE : Parent 03 : ACCEPT ALTER 'Party 1' is a ledger under the Group 'North Debtors' and Party 2 is a Ledger under the Group 'South Debtors'. After the execution of this function, Party 2 will also come under the Group 'South Debtors'. Action-RESET V ALUE This action sets the value of the method using the V alue Formul a. If V alue Formula is not specified, it sets the existing value to null. Syntax RESET VALUE : Method Name [: Value Formula] Where, <Method Name> is the name of the method, and <Value Formula> is an optional parameter and if it is used, it will reset the v alue of the method. Example: 01 : SET VALUE : Ledger Name : $Ledger Name 02 : RESET VALUE : Ledger Name : “New Value” In this code snippet, RESET V ALUE resets the value of the metho d 'Ledger Name' Action-CREA TE T ARGET/ACCEPT CREA TE It accepts the T arget Object to the Company Data base, i. e., it saves the target object to the database. This creates a new object in the database if it does not exist, else results in an error. Syntax CREATE TARGET/ACCEPT CREATE Action-SA VE T ARGET/ACCEPT It accepts the T arget Object to the Company T ally DB. If anothe r object exists in the T ally DB with the same identifier, then the object is altered, else a new object is created. Syntax SAVE TARGET/ACCEPT
TDL_Reference_Manual.pdf
User Defined Functions 276 Action-AL TER T ARGET/ACCEPT AL TER It allows altering an exiting object in the T ally Data Base. If the object does not exist, it results in an error. Syntax ALTER TARGET/ACCEPT ALTER Action-SET OBJECT It sets the current object with the Object Specification. If no object specification is given, the target object will be set as the current object. Only Secondary Object can be used along with this Action. Syntax SET OBJECT [:<Object Spec>] Where, <Object Spec> is the name of the Secondary Object. Example: [Function : Sample Function] Object : Ledger : "My Test Ledger" 01 : LOG : $Name 02 : SET OBJECT : Bill Allocations[1]03 : LOG : $Name 04 : SET OBJECT :.. 05 : LOG : $Name Initially, the context object is 'Ledger', so $Name gives the name of the Ledger. By Using 'SET OBJECT', the current Object is changed to first Bill allocation. So, the second $Name is giving the Bill name. The Fourth line changes the current Object back to ' Ledger' using dotted notation. Action-SET T ARGET This action sets the target object with the Object Specificatio n. If no object specification is given, then the current object will be set as the target object. Syntax SET TARGET : <Object Spec> Where, <Object Spec> is the name of the Object. Example: 01 : SET TARGET : Group This sets the 'Group' Object as the T arget Object. Later, by using other methods of this, the target object can be set and saved to the T ally DB.
TDL_Reference_Manual.pdf
User Defined Functions 27 7 Usage of Object manipulation Actions: Duplicating all payment Vouchers [Function : Duplicate Payment Vouchers] ;;Process for each Payment Voucher 01 : WALK COLLECTION : My Vouchers ;; Create new Voucher Object as T arget Object 02 : NEW OBJECT : Voucher ;;For New Object, set methods from the First Object of the Walk Collection, i. e., from the Current Object 03 : SET VALUE : Date : $Date 04 : SET VALUE : Voucher Type Name : $Voucher Type Name05 : SET VALUE : Narration : $Narration + " Duplicated" ;; Walk over Ledger Entries of the current Object 05a : WALK COLLECTION : Ledger Entries ;;Insert Collection Object to the T arget Ob ject and make it the present T arget Object 06 : INSERT COLLECTION OBJECT : Ledger Entries ;;Set the Values of the T arget Object's Method from Current Objects Methods 07 : SET VALUE : Ledger Name : $Ledger Name 08 : SET VALUE : Is Deemed Positive : $Is Deemed Positive 09 : SET VALUE : Amount : $Amount ;;Set the Voucher Object as T arget, (which is 1 level up in the hierarchy) as Voucher is already having ;;Object specification 10 : SET TARGET :.. 11 : END WALK ;;Save the Duplicated Voucher to the DB. 12 : CREATE TARGET 13 : ENDWALK14 : RETURN
TDL_Reference_Manual.pdf
User Defined Functions 278 5. Calling a Function A Function can be invoked in two ways: 1. By using a “CALL” action-This is mainly used when the function does not return a value. It only performs a certain functionality. 2. By Using the prefix $$ with the function name within a value expression-This is used when a return value is expected from the function execution. This value is used in the value expression of the calling program. 5. 1 Using the Action 'CALL' Action 'CALL' can be used to call a function. It can be invoked from a Key, Menu Item or a Button. Syntax CALL: <Function Name> [: <Parameter List>] Where, <Function Name> is the name of a user defined function. <Parameter List> is the list of parameters accepted by the function. Example:Calling the Function as a procedure with CALL action [#Menu : Gateway of Tally] Button : Call Function [Button : Call Function] Key : Alt + F9 Title : “Call Function” Call : Disp Staturory Rpts 5. 2 Using the S ymbol Prefix '$$' A Function can be called and executed by prefixing it with the symbol '$$'. This can be used inside a value expression or as a value for the 'Set As' attrib ute of the field. The value returned from the function is used. Syntax $$Function Name : <Parameter List> Where, <Function Name> is the name of a user defined function.
TDL_Reference_Manual.pdf
User Defined Functions 27 9 <Parameter List> is the list of parameters accepted by the function. Example: Calling the User Defined Function at Field using $$ [Field : Call Function] Use : Number Field Set as : $$Factorial Of:#Input Fld 6. Function Execution-Object Context We all are aware that in TDL, any function, method or formula g ets evaluated in the current object context. All the platform defined functions will be executed wi th the current object and requestor context. With the introduction of User Defined Functions, another type o f context is introduced. This is known as the target context. 6. 1 T arget Object Context T arget Context mainly refers to the object context which can be set inside the function, which allows the function to perform manipulation operations for that object, i. e., alteration and creation. The object context of the caller and target object context can be different. It will now be possible to obtain the values from the caller object context and alter the values of the target object with those values. The User has the option to override the context within the func tion later or use the same context being passed. He can change the current and target object at any point and a lso switch target and current object to each other. $$Tgt Object is used to evaluate the value of an expression in t he context of the target object. 6. 2 Parameter Evaluation Context It is important to note that the parameter values which are pas sed to the functions are always evaluated in the context of the caller. Parameter specification within the functions is just to determine the data type, order and number of parameters. These are basically the place-holders for values passed from caller object context. The target object context or context switch within the function does not affect the initial values of the parameters. Later, within the function, these values can be altered just like ordinary variables. 6. 3 Return Value Evaluation We have already discussed above that function can return a valu e. This can be specified by the function by indicating the data type of the value it returns, n o specification as sumed as a void function (a function which does not return a value). Each state ment (Actions discussed in the nextDuring T ally Startup, T ally executes a function with the name “T ally MAIN” Internal functions always override if both exist in the same name.
TDL_Reference_Manual.pdf
User Defined Functions 280 section) used can return a value. This depends on the individua l action. Some actions may not return a value. The data type of the return value is also prede fined by the action. Return value of the last action executed can be extracted using an internal fun ction '$$Last Result'. Any error messages generated from the system can be obtained with $$Last E rror. This can only be used to determine the result of the intermediate statements used within the function. The final value which is to be returned from the function has to be explicitly given using the RETURN construct discussed in the previous section.
TDL_Reference_Manual.pdf
Section III What's New in TDL
TDL_Reference_Manual.pdf
TDL_Reference_Manual.pdf
283 What's New in Release 5. 5. 2 1. Language Enhancements in Procedures (TDL) 1. 1 Action-Browse URL The action Browse URL is enhanced to accept a logical value as an optional fourth pa rameter to open the URL in Admin mode. Syntax Action: Browse URL: <URL Formula>: [<Command Line Parameters>: + <Logical Expression1>: <Logical Expression2>] Where, <URL Formula > is an expression which evaluates to a link to a website or a folder path. <Command Line Parameters > is the list of command line parameters separated by space. It is an optional parameter. <Logical Expression1 > can be any expression which evaluates to a logical value. Whe n this parameter is set to yes, it executes the given action in hidden mode. It is an optional parameter. <Logical Expression2 > can be any expression which evaluates to a logical value. Whe n this parameter is set to yes, it executes the action in admin mode. It is an optional parameter. 1. 2 Function-Sys Info The function Sys Info is enhanced to get the file name of the current application wi th the folder path. Example $$Sys Info: Module Name If the application path is C:\Tally. ERP 9, it returns C:\Tally. ERP 9\tally. exe. 1. 3 Attribute-Data Source The collection attribute Data Source is used to populate data to a collection dynamically from a variety of data sources. T his attribute accepts the Type and Identity of the data source from where the data is to be retrieved. Directory, File XML, Name Set, and so on, are some of the data sources supported in TDL. The collection attribute Data Source is enhanced to support Rule Set, Num Set, and Flag Set as new data source types. This attribute helps the developer to ga ther the data pertaining to Rule Set, Num Set, or Flag Set like other data source types. The information of Num Set and Flag Set give same results except for the value. The value of Num Set is a number and value of Flag Set is logical. These data sources can be used for generating repor ts using Value and User Description methods. Otherwise these can act as a debugging aid for the dev eloper.
TDL_Reference_Manual.pdf
What's New in Release 5. 5. 2 284 Syntax [Collection: <Collection Name>] Data Source: <Type>: <Identity> Where, <Collection Name> is the name of the collection where the data is populated. <Type> specifies the type of data source. This enhancement includes Rule Set, Num Set and Flag Set as data source types. <Identity> is the name of the Rule Set/Num Set/Flag Set. It can be an exp ression which results to the name of Num Set/Flag Set as specified in the corresponding data type. Example [Collection: Data Source FSRepo] Data Source: Flag Set: #FSDSVariable The above code snippet helps to populate the collection Data Source FSRepo with the data from the variable FSDSVariable, which returns a Flag Set name. You can refer the below table to know more about this enhanceme nt: Data Source Type Keyword Parameters Example Rule Set Rule Set Name of the Rule Set definition[Collection: DSRepo] Data Source: Rule Set: DSRule Set Flag Set Flag Set Expression evaluating to the value of Flag Set data type[Collection: DSRepo] Data Source: Flag Set: $Flag Set Value OR Data Source:Flag Set: ##Flag Set Value Num Set Num Set Expression evaluating to the value of Num Set data type[Collection: DSRepo] D a t a S o u r c e : N u m S e t : $ N u m S e t V a l u e OR Data Source:Num Set:##Num Set Value
TDL_Reference_Manual.pdf
What's New in Release 5. 5. 2 28 5 The list of methods used in Rule Set /Flag Set /Num Set as data source is listed below: Method Name Description Method Value-Sample Name Rule Name which includes the complete doted notation Is Op Bal GT1000. Is PANEmpty. Is Cont act Empty Additional Name/Formal Name Leaf Rule Name Is Contact Empty Parent Current Rule Set Name Dimension2 Value Value for individual flag or number i. e., Logical for Flag Set and Number for Num Set. It is not applicable for Rule Set. Logical-Yes Number-1 Sort Position Index of the flag or number within the Flag Set and Num Set5 Is Aggregate Is Aggregate flag for Rule Set, Num Set and Flag Set No Depth Level or Depth of Rule Set, Num Set and Flag Set3 User Description Rule Set, Num Set and Flag Set description from corresponding Name Set Is Party Contact Empty
TDL_Reference_Manual.pdf
TDL_Reference_Manual.pdf
287 What's New in Release 5. 4. 9 In TDL, to make the programming simpler and to optimise the rep orting and query area, we have introduced two definitions-Rule Set and Name Set, and two data types-Flag Set and Num Set. 1. Definition-Rule Set Rule Set is a definition in TDL and can be used to define a set of rule s. You can use this definition to evaluate the rules efficiently. Rule Set can be defined with single dimension or multiple dimensions along with flow control. The attribute Rule Set and related functions help to evaluate the defined Rule Sets. The result of a Rule Set is always an Ob ject method of Flag Set data type. The functions related to Flag Set data type allow you to access the Flag Set. Storing the Flag Set result in data base is currently not supported. For example, du ring voucher acceptance, the Rule Set can be used to check the correctness of data. The definition Rule Set makes TDL programming simpler because of its ability to allow a developer to scope only one validation at a time and not all of them together. It reduces the code size. It also provides the named identity to access flag set va lues. Rule Set increases the efficiency of the programme, whi ch is measured on performance a nd the memory usage. Syntax [Rule Set: <Rule Set Name>] Where, <Rule Set Name > is the name of the Rule Set. Various attributes and functions, which are related to Rule Set are explained below: 1. 1 Attribute-Break On Break On is a single type attribute with constant value. You can use th e attribute Break On in Rule Set definition to determine the continuation of evaluation in the current rule set. It provides vertical flow control to evaluate the rules. Break on can also be mentioned with Rule attribute. Syntax Break On: <Logical Constant> Where, < Logical Constant > is Yes/No. While evaluating each rule, If the value of Break On matches with the result of the rule, then the evaluation flow will break and further rules are not evaluated in the current Rule S et. The remaining rule values are defaulted to No. If the attribute Break On is not specified, the evaluation flow continues, irrespective of the result of rule. 1. 2 Attribute-Walk On Walk On is a single type attribute with constant value. The attribute Walk On helps to determine whether the next dimension will be evaluated or not, for the cu rrent rule. It has diagonal flow control to evaluate the steps.
TDL_Reference_Manual.pdf
What's New in Release 5. 4. 9 288 Syntax Walk On: <Logical Constant> Where, < Logical Constant > is Yes/No. While evaluating each rule, If the value of Walk On value matches with the result of the rule, then the evaluation flow continues to evaluate the next dimension in the current rule co ntext. If the next dimensions are not evaluated, the rule values are defaulted to No. If the attribute Walk On is not specified, the evaluation flow continues to evaluate th e next dimension, irrespective of the result of rule. 1. 3 Attribute-Rule Rule is a Triple list attribute. You can use the attribute Rule to define a rule. It accepts three parameters. Syntax [Rule Set: <Rule Set Name>] Rule : <Rule Identifier>: <Logical Expression>[: <Keyword>] Where, <Rule Identifier> is the name of the rule to identify or access the rule later. “*” and “?” are not supported as rule names. <Logical Expression> evaluates in the context of requester/source/target object bei ng passed from evaluation context. <Keyword> specifies the value of Break On sub-attribute for current rule. If no specification is provided, it inherits the Break On attribute value at current rule set level. Possible options are True/Yes: When the result of the rule is True/Yes, it stops the evaluati on further in the current rule set. The next dimension gets evaluated for the current rule. False/No: When the result of the rule is False/No, it stops evaluating f urther. Never: It continues the evaluation, irrespective of rule result. Example [Rule Set: My Rule Set] ;; Yes/No or Not Specified Break On : Yes Rule : A1 : @@TNAnnexure1Included Rule : A2 : @@TNAnnexure2Included: No
TDL_Reference_Manual.pdf
What's New in Release 5. 4. 9 28 9 In the above example, A1, A2 are rule identifiers. @@TNAnnexure1Included and @@TNAnnexure2Included are rule expressions. 1. 4 Attribute-Aggr Rule Aggr Rule is a Triple list type attribute and it accepts consta nt values as parameters. You can use Aggr Rule to specify various pre-defined aggregation for Rule Set. Syntax Aggr Rule: <Identifier>: <Type of aggregation>[: <Level Indicator>] Where, <Identifier> is to specify the identifier for the aggregate rule. It can be accessed from Flag Set like any other flags. <Type of aggregation> is to specify the type of aggregation. (Any True / OR, All Tru e / AND) <Level Indicator> is to indicate the level for aggregation. It is always relativ e to current rule set. The default value of this parameter is One. This parameter to b e specified by using a level number from current rule set to identify the level. The aggregate flags are accessed using the same dotted notation like any other flags. Value of these rule flags are aggregation results, which are computed at the time of rule evaluation. When multiple flag sets are aggregated, similar to Aggr Compute: SUM in collection, these aggregate flags are also further aggregated (counts) into Num S ets. The first Aggr Rule result of the root/top level Rule Set is stored into the Zeroth flag. If no aggregate rule is specified in t he hierarchy, the first rule re sult is stored at Zeroth flag. Zeroth flag value is also referred as the master aggregate rule value. 1. 5 Attribute-Rule Set Rule Set is a Triple list attribute. You can use the attribute Rule Set to specify the rule set for next dimension of each rules in the current rule set. Rule Set attri bute accepts three parameters. Syntax Rule Set: <Rule Set Name>: [<Current Definition Rules> + : <Next Dimension Rules>] Where, <Rule Set Name> is the name of the next dimension Rule Set. It is the Rule Set description reference to another Rule Set definition. <Current Definition Rules> are the rules in the current rule set and it has the given Rul e Set as next dimension. If it is not specif ied, it assumes all rules in the current rule set have the given rule set as next dimension. <Next Dimension Rules> are the rules in next dimension Rule Set that have to be evalu ated. If not specified, it assumes all rules in next dimension rule set are to be evaluated. The results are available as part of the Flag Se t generated by Rule Set evaluat ion.
TDL_Reference_Manual.pdf
What's New in Release 5. 4. 9 290 The attribute Rule Set accepts multiple values. Each rule can have a different Rule S et for its next dimension. A Rule Set already present in the hierarchy at any level is not allowed to be spec ified as the next dimension again. 1. 6 Attribute-Name Set Name Set is a Single type attribute. You can use the attribute Name Set to specify the default name set definition for the current rule set. In general, Name Set contains rule descriptions. Syntax Name Set: <Name Set Definition Name> Where, <Name Set Definition Name> is the name of Name Set definition to map the current rule set. Name Set can be used in two ways: 1. To specify the default name of the name set definition name, when it is used with the attribute Name Map, without using the third parameter of Name Map. 2. Use the attribute Name Set without using Name Map-automatic ally it will get mapped based on the rules in the current rule set, if the identifiers in Nam e Set match the rule identifier. 1. 7 Attribute-Name Map Name Map is a triple list type attribute. You can use the attri bute Name Map to specify explicit name mapping for Rule descriptions. It accepts three parameters. Syntax Name Map: <Rule Name>:<Name Identifier>[:<Name Set Definition Name>] Where, <Rule Name> is an identifier to Rule in current rule set. This name is def ined in Rule attribute. <Name Identifier> is specified in the Name Set definition. <Name Set Definition Name> is an optional parameter and it is the name of Name Set defini tion. If this sub-attribute is specified, then the string value is ac cessed from Name Set which is mentioned here. If it is not mentioned it assumes the Name Set Definition Name mentioned in Name Set attribute in the current Rule Set. Either the third parameter of Name Map or a Name Set attribute should be specified. Otherwise the specific name map will be ignored. Name Map is useful to map the error strings inline with each Rule Set. 1. 8 Function-E valuate Rule Set The function Evaluate Rule Set evaluates the Rule Set and returns a Flag Set data type. It returns a Flag Set type, which is constructed with fl ags and dimensions as per the Rule Set definition provided, and evaluated on the current contexts.
TDL_Reference_Manual.pdf
What's New in Release 5. 4. 9 29 1 Syntax $$Evaluate Rule Set:<Rule Set Name> Where, <Rule Set Name> is the name of the Rule Set definition. It returns Flag Set data type. Static modifiers like Add, Change, and Delete are supported in rule set definition. Local formula is supported with the definition rule set. The lo cal formula can be accessed only from the Rule Set in which the local formula is defined. Example-Rule Set [Rule Set: My Rule Set] ;; Yes/No or Not Specified Break On : Yes ;;Rule Name ;; Rule Logica l Expression ;; break on (override) Rule : A1 : @@TNAnnexure1Included Rule : A2 : @@TNAnnexure2Included : No Rule : A3 : @@TNAnnexure3Included ... ;; Second Dimension Ru le Set ;; My Rules ;; Dimension Rules (Filter) Rule Set : Anx_Errors A : A1 : EA1, EA2 Rule Set : Anx_Errors B : A2, A3 : EB2, EB3 ;; Aggregate Rules Aggr Rule : Is Included In Any Annexure: Is Any True : 1 Aggr Rule : Has Any Error : Is Any True : 2 ;; option1 Name Set mapping [Rule Set: Anx_Errors A] Break On : Yes ;; ;;Rule Name ;; Rule Logi cal Expression ;;break/continue condition Rule : EA1 : @@TN_Error1 Rule : EA2 : @@TN_Error2 : No Rule : EA3 : @@TN_Error3
TDL_Reference_Manual.pdf