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

Friday, August 24, 2007

Example 44: Adding FILTER button to MyDaybook

This program TDL44.TXT is an extension to my earlier program TDL43.TXT. It adds the FILTER button to My Daybook Report.

There are few minor modifications done to acheive the task:-
a) Add FILTER button to the FORM
b) Add few variables at the REPORT definition level

Download TDL44

The new code has been shown as highlighted.

;; AUTHOR : Shweta Computers
;; Objective:- Adding Filter button to MyDaybook

;;Global Formula. Used to assign a simple text string to a Global constant.
[System: Formula]
MYDBKTDL: $LocaleString:"Daybook"

;;Add a new menu-item to the Gateway of Tally
[#Menu: Gateway of Tally]
Item: @@MYDBKTDL : Display: My DBKTDL

;;Control whether the menu-option is displayed or not?
Control: @@MYDBKTDL: $Allow:Display:Daybook

;; Syntax for $Allow
;; $Allow : <mode> : <family report name>
;; Return Value : Logical

[Report: MYDBKTDL]

Family: $Translate:"Daybook"
;; The attribute FAMILY specifies that this Report (i.e. MYDBKTDL)
;; belongs to a Family (report) named Daybook.
;; DAYBOOK is a pre-defined report and here we are specifying that
;; MYDBKTDL report belongs to the same DAYBOOK family.
;; This will affect ACCESS to MYDBKTDL report.
;; Now, when we change the ACCESS to DAYBOOK report using option
;; "Gateway of Tally -> Alt+F3 -> Security Features".
;; it will automatically affect the report MYDBKTDL

Title: $LocaleString:"Daybook"
Form : My Form

;;Variables used in the Report
Variables: SVFromDate,SVToDate,SVSortMethod
Variables: ExplodeFlag, ExplodeNarrFlag
Variables: OnlyAccVouchers,OnlyInvVouchers

Set: SV SortMethod : @@Default
Set: SVFromDate: $$MonthStart:##SVCurrentDate
Set: SVToDate: $$MonthEnd:##SVCurrentDate

;;Required for F12 Configuration
Repeat: SVColumntype, SVColumnName

;;PRINTSET affects the variables related to Printing, whereas
;;SET is used to assign values to variables used otherwise.
PrintSet: ReportTitle: $LocaleString:"Daybook"
PrintSet: PrintFileName: "Daybook"

[Form: My Form]

;;Pre-defined button. Adds the Print button
Button: PrintButton

;;EXPLODEFLAG is a pre-defined button in Default Tally.
;;Try using KEY instead of BUTTON, Alt+F1 still works,
;;but the "Alt+F1" button is not displayed
Button: ExplodeFlag

;;Pre-defined button. Required for F12 configuration
Button: DYBKConfigure

;;Pre-defined button. Filter records using Alt+F12 key
Button: FilterButton

Space Top : if $$InPrintMode then ##SVSpaceTop else 0.05 inches
Space Bottom: if $$InPrintMode then 0.5 else 0.05 inches
Space Left : if $$InPrintMode then 0.5 else 0.05 inches
Space Right : if $$InPrintMode then 0.25 else 0.05 inches

Part: My DB Title,My DB Body

[Part: My DB Title]

;;Optional Parts
Option: My DB PrntTitle : $$InPrintMode
Option: My DB ScrTitle : NOT $$InPrintMode

[!Part: My DB PrntTitle]

;;This is a pre-defined part in default TDL
Use: DSP AccTitles

[!Part: My DB ScrTitle]
Line: My DB Title

[Line: My DB Title]
Field : Name Field
Local : Field : Name Field : Set as : $$LocaleString:"Daybook"

[Part: My DB Body]
Line: My Line
Scroll: Vertical
Common Border: Yes
Repeat : My Line: My Collection

[Line: My Line]
Left Fields: Myfld1,MyFld2
Right Fields: MyFld3,MyFld4

;;This Shows the Ledger details when Alt+F1 key is pressed
Explode: MyExplodePart : ##ExplodeFlag

[Field: Myfld1]
;;TYPE attribute specifies the data-type of the field
Type : Date
Set as : $Date

[Field: Myfld2]
Use : Name Field
Set as : $$CollectionField:$LedgerName:1:AllLedgerEntries

[Field: Myfld3]
Use : Short Name Field
Set as : $VoucherTypeName

[Field: Myfld4]
Use : Amount Field
Set as : $Amount

;;This PART is displayed when EXPLODEFLAG variable is set to Yes
;;i.e. When user presses Alt+F1 key
[Part: MyExplodePart]
Line : MyExplodline
Line : MyExplodeNarrLine

;;Repeats the line MyExplodeLine to display the AllLedgerEntries
;;Collection fields
Repeat : MyExplodline : AllLedgerEntries

;; Specify the fields that you wish to display when the PART is Exploded
[Line: MyExplodline]

;;Show this field on the left side of the line
Add: Left Fields: fldExplodeLedger,fldExplodeAmount

;;This skips the first object of Collection AllLedgerEntries
Empty: $$IsFirstObj

;;Ledger Name field
[Field: fldExplodeLedger]
Indent : 10
Use : Name Field
Set as : $LedgerName
Style : Small Italic
Width : @@NameWidth

;;Amount field
[Field: fldExplodeAmount]
Use : Amount Field
Set as : $Amount
Style : Small Italic
Width : @@ShortWidth

;; Line to Display Narration
[Line: MyExplodeNarrline]
Add: Left Fields: fldExplodeNarration

;;Display Narration field
[Field: fldExplodeNarration]
Indent : 12
Use : Name Field
Set as : $Narration
Style : Small Italic
Width : @@NameWidth

;;Collection definition
[Collection: My Collection]
Type: Voucher

1) This program is an extension of program TDL43.TXT
2) Herein, we have added Filter button to the MyDaybook Report.
To Filter records, press Alt+F12

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