RTSlink                                                                     RTSlink [Home]     tdlplayground

Copyright 2007, Shweta Computers

All rights reserved.

 

Creating Masters in Tally using TDL: Part 1

by Soni R Singh

 

This article teaches how you can create masters in Tally using TDL (Tally definition Language).  In the next Part [i.e Part 2] of this article, we shall focus on the ‘Alternate methods for Creating Masters’ and ‘Pros &  Cons of creating masters using TDL’.

 

We all know what “masters” are. And if you are a programmer, you would certainly know what all it is required for creating masters viz Forms, Tables, Coding and all that stuff. Isn’t it? Before we start  with TDL programming, let us see how do we create a Master in a Visual programming language like Visual basic or Delphi.

 

When you think of “Creating Masters”, certain things immediately come to mind:-

·         Designing the Table structure

·         Creating a form with the Visual interface

·         Accepting and validating User-input

·         Functionality to retrieve and store records in the database

 

And of-course, you need to follow the principles of Good programming. Before proceeding with the real task, let us understand the basic TDL fundamentals which are the building blocks for TDL programming.

 

Objects

 

The default TDL comprises of several pre-defined objects viz. Group, Ledger, Godown, Unit, Stock Group, Stock Item, Voucher, Voucher Types, Cost Centre, Cost Category, Budget etc.

 

You can think of Objects as a ‘Collection of fields that hold data’ which is like Tables or DBFs. In simple words,  Objects hold data in form of records and a record is a collection of fields. TDL allows you to add new fields to the pre-defined Objects using UDFs.

 

User-defined Fields (UDFs)

 

TDL allows you to define UDFs which can hold persistent data. UDFs can be of various types viz String, Amount, Number, Date etc. UDFs may further be classified as follows:-

 

a)      Single UDF

Allows you to input a single value. For example, you can add a new field (say Excise Registration Number) to the Ledger master entry screen.

 

b)      Repeat UDF

Allows you to input multiple values.  For example, you can add a new field (say Discount Amount) in the ITEMs section of the Sales or Purchase Voucher entry. In this case, the user is prompted to enter Discount Amount for each item/row.

 

c)       Aggregate UDF

It is a collection of fields which repeats itself. In simple words, Aggregate UDF is a  set of fields of different types and sizes that allows you to hold records of data.

 

Syntax for declaring UDFs

 

 

Single UDF

Multiple UDF

Aggregate UDF

Syntax

[System: UDF]

   <FieldName>:<Type>: <Index>

[System: UDF]

   <FieldName>:<Type>: <Index>:<Repeat>

[System: UDF]

   <FieldName>:Aggregate: <Index>:<Repeat>

Example

[System: UDF]

    ChequeNo: String: 1000

 

[System: UDF]

ChequeNo: String: 1000: Yes

 

[System: UDF]

MyDB: Aggregate: 1000

ChequeNo: String: 1000

ChequeDate: Date: 1001

BankName: String: 1002

 
 

On examining the UDF definitions given above, one question that immediately comes to mind is “How do we attach an UDF to a specific object ?”.  Indeed, no Object has been specified in the above definitions. 

 

Then, how do we do it? As mentioned earlier, UDFs are fields which can be added to any existing Object.

 

In our blogspot tdlplayground, we have already created some UDFs viz.

a)       UDF for “Cheque no” in the Ledger Master entry screen

b)       UDF for “Salesman” in the Voucher entry screen.

(Please visit tdlplayground for more information).

 

But, did we specify the Object to which the UDF is to be linked ? No, we did not specify any such object. Ooops…, then how does the UDF get attached to an Object and to which Object does it get attached? Here’s the Answer: In fact, it is not required to specify the Object as the UDF get automatically attached to the current Object.  In simple words, a UDF used in the Ledger Master entry screen automatically gets attached to the Ledger Object. A UDF used in the Voucher entry screen automatically gets attached to the Voucher Object.That’s all.

 

 

More on Aggregate UDFs

 

An UDF is a single field, but for creating masters we require a table-like structure that can hold records. For this, Aggregate UDFs  are to be used.

 

The Aggregate UDF can be created only under the Company Object. In simple words, the Company object is the only object that allows you to store tables (or Aggregate UDFs).

 

Some Important facts

·         For each Company in Tally, there is a single instance of the Company Object.

·         To add a Aggregate UDF (which can reside only in the Company Object) , we have to ALTER the Company Object.

·         You should not  use CREATE action on the company object to add new Aggregate UDFs.

 

 

Adding an Aggregate UDF to the Company Object

 

STEP-BY-STEP INSTRUCTIONS

 

Step 1: Aggregate UDF definition

[System: UDF]

      MyDBSalesman: Aggregate: 2

      SalesmanName: String:       1000

      Commission: Number: 1001

Remarks:- The first line ‘MyDBSalesman: Aggregate: 1000’ specifies that it is an Aggregate UDF followed by the the fields comprising of the Aggregate UDF.

   

Step 2: Modify the Company [F11] Features screen to add a new line

[#Part: CMP AdvancedFeatures]

    Add: Line: CMP EnableSalesmanTable

Remarks:-

a)   You might have used F11 key [Company Features] in the GatewayofTally menu. It allows you to configure Tally features. We are adding a new line in the ‘F11 Company Features’ screen which shall automatically attach the Aggregate UDF to the Company Object.

b) ‘CMP Advanced Features’ is a Part definition which is defined in the default TDL.

 

Step 3: Define the newly added line

[Line: CMP EnableSalesmanTable]

    Field: Medium Prompt, CMP EnableSalesmanTable

    Local: Field: Medium Prompt: Info: "Enable Salesman ? "

    Invisible: NOT $$MODAdvInventory or NOT $IsInvoicingOn

    Space Top: 1

Remarks:-The above defines a LINE with two fields

a)       Field ‘Medium Prompt’ to display a  prompt message. This field is already defined in default TDL

b)       Field ‘CMP EnableSalesmanTable’ to accept user-input

 

Step 4: Field to accept user-input “Yes/No”

[Field: CMP EnableSalesmanTable]
    Use: Logical Field
    Storage: EnableSalesman
    Set as: If $$IsEmpty:$$Value then "No" else $$Value
    Sub Form: CMP SalesmanReport: $$Value = "Yes"

Remarks:- The above defines a field ‘CMP EnableSalesmanTable’

a)       Field ‘CMP EnableSalesmanTable’ is inherited from ‘Logical field’ which is a part of default TDL

b)       The ‘Storage’ attribute specifies the UDF which holds the field contents

c)       The ‘Sub Form’ attribute displays a Form if the user selects ‘Yes’

 
Step 5: UDF definition
[System: UDF]
    EnableSalesman: Logical: 1000

Remarks:- This defines a  UDF ‘EnableSalesman’ which is used in Field ‘CMP EnableSalesmanTable’ as shown above.

 
Step 6:  Screen to accept user input
[Report: CMP SalesmanReport]
    Form: CMP SalesmanForm
 
[Form: CMP SalesmanForm]
    Part: CMP Salesman PartTitle, CMP Salesman PartDetails
    Background: White, Petal Pink
 
Step 7:  Part/Line/Field  for displaying Prompt message
[Part: CMP Salesman PartTitle]
    Line: CMP Salesman LineTitle
 
[Line: CMP Salesman LineTitle]
    Field: Long Prompt
    Local: Field: Long Prompt: Style: Small Bold
    Local: Field: Long Prompt: Info: "Salesman / Commission"
 
Step 8:  Part/Line/Field  to accept user input
[Part: CMP Salesman PartDetails]
    Line: CMP Salesman LineDetails
    Repeat: CMP Salesman LineDetails: MyDBSalesman
    BreakOn: $$IsEmpty:$SalesmanName
    Height: 6
    Scroll: Vertical
 
[Line: CMP Salesman LineDetails]
    Field: CMP Salesman NameField,CMP Salesman CommissionField
 
[Field: CMP Salesman NameField]
    Use: Short Name Field
    Storage: SalesmanName
    Border: Thin Left
 
[Field: CMP Salesman CommissionField]
    Use: Number Field
    Storage: Commission
    Border: Thin Left
 

Remarks:-

a)       The ‘Repeat’ attribute takes two arguments. 1st: The line to be repeated and 2nd: the Data-source (Aggregate UDF)

b)      The ‘BreakOn’ attribute exits the Repeat loop when the SalesmanName field is empty

c)       The ‘Height’ attribute specifies the number of lines to be displayed in the Part.

d)       This defines a  UDF ‘EnableSalesman’ which is used in Field ‘CMP EnableSalesmanTable’ as shown above.

 
Step 9:  Modify the Voucher Entry screen and add a new line to accept Salesman Name
[#Part: EI BaseInfo]
    Option: EI Salesman: $$IsSales:##SVVoucherType
[!Part: EI Salesman]
      Add: Line: EI lnSalesman
[Line: EI lnSalesman]
      Fields: Short Prompt, fldSalesman
      Local: Field: Short Prompt: Info: ‘Salesman Name: ‘
 [Field: fldSalesman]
      Use: Short Name Field
      Storage: EI SalesmanName
      Width: 20
      Table: MySalesmanCollection
      ShowTable: Always
 
[System: UDF]
    EI SalesmanName: String: 1002
 

Remarks:-

a)       ‘EI BaseInfo’ is a Part definition which is defined in the default TDL.

b)      The ‘Option’ attribute modifies the original part definition ‘EI BaseInfo’ with the ‘EI Salesman’  part definition if the current VoucherType is Sales.

c)       The field definiton ‘fldSalesman’ uses UDF ‘EI SalesmanName’. This UDF automatically gets attached to the Voucher object as the field ‘fldSalesman’ is used in Part definition ‘EI BaseInfo’. In simple words, the field (EI SalesmanName) is added automatically to the Voucher object.

 
Step 10:  Defining the Collection Object
 [Collection: MySalesmanCollection]
      Type: MyDBSalesman: Company
       Childof: ##SVCurrentCompany
       Format: $SalesmanName,10
      Title: Salesman
 

Remarks:-

a)       This defines a collection object named ‘MySalesmanCollection’

b)      A Collection Object is like a query which works on a specific data-source. It retrieves records (objects) from the given data-source.

c)       The data-source here is ‘MyDBSalesman’ Aggregate UDF which is a part of the Company Object.

d)       The ‘Childof’ Attribute is used for filtering records.

e)       The ‘Format’ attribute formats and displays the field-contents in the help-list popup.

 
 

Downloads

 
Download Salesman Master (Aggregate UDF) with source-code
 

Using Salesman Master Aggregate UDF

 
Step 1: Download the Salesman Master (Aggregate UDF) compiled file with source-code
 
Step 2: Tally.ini modifications
User TDL=Yes
;; For Tally 7.2
TDL= C:\tally\tdl24.tcp
 
;;For Tally 9
TDL=c:\tally\tdl9v24.tcp
 
Step 3: Salesman Master entry
a)       GatewayofTally -> F11
b)       Next, move down to option  ‘Set/modify other company features’  and enable it “YES”
c)       Next, move down to option ‘Enable Salesman’  and make it ‘YES’
d)       Next, enter the Salesman Names and their commission figures 
e)       After you finish entering the Salesman details, press ENTEr key twice to save it.
 
 
Remarks:-
You can modify the Salesman details same way as mentioned above.
 
Step 4: Voucher Entry
a)       GatewayofTally -> Accounting Vouchers
b)       Next, in the Voucher entry screen, press F8 key for Sales Voucher
c)       Next, enter the details. It should show a new field ‘Salesman Name’.
 
 

Creating Masters in Tally using TDL: Part 1

Copyright 2007, Shweta Computers

All rights reserved.

Subject to Rights given for publication to interested parties.

 

 

Tally, Tally Developer, Tally definition language are trademarks or registered trademarks of Tally Solutions FZ LLC