Tally ERP 9 | Tally 9 | Tally 8.1 | Tally 7.2 | Tally 6.3 | Learn Tally TDL

Monday, September 3, 2007

Example 45: Using the $$Table function to lookup values in a Table

This program illustrates how to use the $$TABLE function to lookup records in a Table.

Herein, we shall create a Collection of STOCK ITEM's having two fields viz. Item-Name and Part-number. When the user selects an ITEM from the list, it's Part-Number must be automatically displayed.

Download TDL45

;;Program  :- TDL45.TXT
;;Author :- Shweta Computers
;;Objective:- Using $$Table to lookup/fetch field values

[#Menu: Gateway of Tally]
Item: TDL45 : Alter: My ItemReport

[Report: My ItemReport]
Form: My ItemForm

[Form: My ItemForm]
Part: My ItemPart

[Part: My ItemPart]
Line: My Line1, Myline2

[Line: My Line1]
Fields: Short Prompt, My ItemName
Local: Field: Short prompt: Set as: "Item Name:- "

[Line: My Line2]
Fields: Short Prompt, My ItemPartNo
Local: Field: Short prompt: Set as: "Part Number:- "

[Field: My ItemName]
Use: Name Field

;;Variable to hold the user-input
Modifies: varItemName

;;Specify the Collection Name
Table: My ItemList

Show Table: Always

[Field: My ItemPartNo]
Use: Name Field

;;Variable to hold the user-input
Modifies: varItemPartNo

Set as: $$Table:MyItemName:$PartNo

;;Required to assign value automatically on selection of ItemName
Set Always: Yes

[System: Variables]
varItemName: ""
varItemPartNo: ""

[Variable: varItemName]
Type: String

[Variable: varItemPartNo]
Type: String

[Collection: My ItemList]
Title: "Item List"
ListName : $$SysName:EndOfList
Objects: Item1,Item2,Item3,Item4,Item5

[Object: Item1]
Name: "Bush"
PartNo: "1001"

[Object: Item2]
Name: "Piston"
PartNo: "1002"

[Object: Item3]
Name: "Gear Box"
PartNo: "1003"

[Object: Item4]
Name: "O-Ring"
PartNo: "1004"

[Object: Item5]
Name: "Camshaft"
PartNo: "1005"
1) $$Table function accepts two arguments. 
$$Table : <LookupExpr> : <LookupField>

Herein, the $$Table function searches for <LookupExpr> and returns the value for field <LookupField>.

Tally; Tally Developer and Tally Definition Language are trademarks or registered trademarks of "Tally Solutions FZ LLC", Bangalore.