A blog on Tally Integration, to import and export data from Tally.ERP programmatically using VB6, VB.NET,C#,ASP.NET etc

Wednesday, June 13, 2007

How to Count Number of Ledgers in Tally Company ?

At times we need to Count the number of records in a given Collection (i.e. Table). This can be done by using SQLRequest() function of RTSLink DLL.

The underneath statement shows how to fetch number of Ledgers :-

SQLRequest("Select $$NumItems:LEDGER from Ledger where $$ItemSerial=1")

Now let us try to understand the above SELECT statement.

1) $$NumItems is an Internal Tally function. It returns the Number of items in the specified Collection.

$$NumItems: <CollectionName>

The $$NumItems function is passed a Collection-Name, and it returns the number of Objects (records) in the LEDGER collection.

2) Why do we use the $$ItemSerial function ?

First of all, let us understand the functionality of $$ItemSerial function. It does not require any parameter and returns the number of records (lines) processed starting from 0. In simple words, if there are 5 Ledgers master records in the LEDGER collection, the $$ItemSerial will return 4.

Now, using $$ItemSerial=0 in the WHERE clause of the SELECT statement, will return a single row of information (i.e. the Ledger-Count). Try removing the WHERE clause and notice the difference.

It works the same way for other masters too. Example:-

Select $$NumItems:STOCKITEM from StockItem where $$ItemSerial=0

No comments: