Import File
An Import File in TDL defines the structure of each record in the ASCII file being imported into TallyPrime. It describes how the data in each record is organized so that TallyPrime can interpret and process the imported data correctly.
An Import File can contain multiple records, with each record representing data to be mapped and processed during the import operation.
By defining the Import File, developers can specify how the data in the source file should be structured and interpreted during the import process.
Syntax
[Import File: <Import File Name>]
Example
[Import File :TSPL Import File]
Combine : @@IsImpCombineOpBal
Empty : @@IsImpIgnoreDup AND $$InAlterMode
BackUp : ##svImpBackupEnabled : ##svImpBackupPath
Click here to download Response Report Attribute Sample
Click here to download On Attribute Sample
Attributes
Think of an import operation as bringing a new set of records into TallyPrime. Before bringing in the new data, the Backup attribute acts as a safety step by determining whether the existing data should be backed up. The attribute controls whether a backup is taken before the import operation begins.
This way, developers can include a backup step in the import process, helping preserve the existing data before any new information is imported into TallyPrime. It provides an additional layer of protection by keeping the existing data safe before the import operation is performed.
Syntax
[Import File : <Import File Name>]
BackUp : <Logical Expression> : <Backup Path>
Example
[Import File: JSON Import]
Use : JSONFormat
BackUp : Yes : “C:\Users\Desktop\Masters.json”
In this example, the JSON Import definition is configured to use the JSONFormat format for processing the import file. The BackUp attribute is set to Yes, which instructs TallyPrime to take a backup before the import operation begins. The second parameter specifies the location where the backup should be stored, ensuring that a copy of the existing data is preserved before the new information is imported.
The Combine attribute comes into play when an import contains duplicate records. It allows TallyPrime to determine whether the values from such records should be combined or totalled based on a specified condition.
The attribute accepts a logical value—Yes or No. When the value is Yes, the values of duplicate records that meet the specified condition are combined or totalled during the import process. When the value is No, the values are not combined and the records are handled separately.
This is useful when the same record occurs multiple times in the import data and the values need to be consolidated based on a specific condition. By controlling the Combine attribute, developers can determine whether values for duplicate records should be combined during the import process.
In simple terms, Combine decides whether the values of duplicate records should be totalled or kept separate based on a condition.
Syntax
[Import File : <Import File Name>]
Combine: <Logical Expression>
Example
[Import File: JSON Import]
Combine : @@IsImpCombineOpBal
The Empty attribute comes into play when an import process needs to discard a particular record based on a condition. It allows developers to specify a condition that determines whether the record should be discarded during the import process.
The attribute accepts a logical expression as its parameter. When the expression evaluates to Yes, the corresponding record is discarded. When it evaluates to No, the record continues through the import process normally.
This is useful when certain records need to be excluded from the import based on specific conditions. By using the Empty attribute, developers can control which records are discarded during the import process.
In simple terms, Empty checks a condition and discards the record when the condition is satisfied.
Syntax
[Import File : <Import File Name>]
Empty: <Logical Expression>
Example
[Import File: JSONImport]
Empty : @@IsImpIgnoreDup AND $$InAlterMode
In this example, the Empty attribute uses the predefined TDL formula @@IsImpIgnoreDup along with $$InAlterMode to decide whether an imported record should be discarded. The formula @@IsImpIgnoreDup checks whether the ImportDups variable is set to the system name IgnoreDup. The record is discarded only when this condition is true and TallyPrime is in Alter Mode.
The Excel Sheet Name attribute is used when importing data from an Excel workbook. It allows developers to specify the name of the Excel sheet from which the data is to be captured.
The attribute accepts an expression that provides the name of the Excel sheet. This allows the required sheet name to be specified as part of the import process.
This is useful when an Excel workbook contains multiple sheets and the name of the sheet needs to be captured for the import operation. By using the Excel Sheet Name attribute, developers can specify the sheet name that is required during the import process.
In simple terms, Excel Sheet Name captures the name of the Excel sheet.
Syntax
[Import File : <Import File Name>]
Excel Sheet Name : <Excel Sheet Name>
Example
[Import File : Excel Import]
Excel Sheet Name : “Item Batch”
In this example, the Excel Sheet Name attribute specifies the worksheet from which TallyPrime should read the data during the import. The value “Item Batch” identifies the exact sheet in the Excel workbook that contains the records to be imported.
The Format attribute comes into play when TallyPrime needs to identify the format of the file being imported. It allows developers to specify the format of the source file as part of the import process, such as JSON or XML.
The attribute accepts a value that specifies the format of the file to be imported. This helps TallyPrime identify the format of the incoming file during the import operation.
This is useful when an import process works with a specific file format and the format needs to be explicitly specified. By using the Format attribute, developers can define the format of the file that is being imported.
In simple terms, Format specifies the format of the file to be imported.
Syntax
[Import File: <Import File Name>]
Format : <File Format>
Example
[Import File: JSONImport]
Format : “JSON”
In this example, the Format attribute specifies that the file being imported is in JSON format. The BackUp attribute is set to Yes, so TallyPrime takes a backup before starting the import and stores it at the specified path. The Combine attribute uses the predefined formula @@IsImpCombineOpBal to determine whether the applicable duplicate records should be combined during the import.
The Modifies attribute comes into play when the value of a storage needs to be changed during the import process. It allows developers to specify the storage whose value needs to be modified and the value that should be assigned to it.
The first sub-attribute specifies the name of the storage whose value needs to be modified, while the second sub-attribute specifies the value to be assigned to that storage. This allows developers to control the value that is stored during the import process.
This is particularly useful when a storage value needs to be changed or assigned a specific value while importing data. By using Modifies, developers can control the value assigned to a storage during the import process without changing the source file.
In simple terms, Modifies specifies which storage value to change and what value to assign to it during import.
Syntax
[Import File: <Import File Name>]
Modifies : <Storage Name> : <Storage Value>
Example
[Import File: JSONImport]
Format : “JSON”
Modifies : GUID : RemoteAltGUID
Modifies : AlterId : RemoteAlterId
The Object attribute comes into play when defining an import structure in TallyPrime. It allows developers to specify the name of the Import Object, which is associated with the corresponding Internal Object in TallyPrime.
The attribute accepts an expression that specifies the name of the Import Object. The specified Import Object is associated with an Internal Object, establishing the relationship between the import definition and the corresponding object in TallyPrime.
This is useful when defining how imported data is represented within TallyPrime. By specifying the appropriate Import Object, developers can associate the import definition with the corresponding Internal Object.
In simple terms, Object specifies the Import Object name, which in turn is associated with an Internal Object in TallyPrime.
Syntax
[Import File: <Import File Name>]
Object : <Import Object Name>
Example
[Import File: TSPL Ledger_Import]
Object: TSPL Ledger
[Import Object : TSPL Ledger]
Object : Ledger : $Name
The On keyword comes into play when a specific event occurs during the execution of a TDL definition and one or more actions need to be performed in response. It allows developers to associate a list of actions with an event.
The keyword is used to specify the actions that should be executed when the associated event occurs. This allows developers to define actions that are triggered automatically when a particular event takes place.
This is particularly useful when developers need TallyPrime to perform specific actions in response to an event during the execution of a TDL definition.
In simple terms, On specifies the list of actions to be executed when an event occurs.
Syntax
[Import File: <Import File Name>]
On : <Import Event Keyword> : <Logical Condition Expression> : <Action Keyword> : <Action Parameter>
Example
[#Import File: XMLImport]
On : Import Object : @@IsLedgerStateNameExist : Execute ObjectMap : ImpLedgerStateName
The Option attribute comes into play when a definition needs to provide different results based on a particular condition. It allows developers to specify an optional definition that is considered only when the required condition is satisfied.
The first sub-attribute specifies the name of the optional definition, while the second sub-attribute specifies a logical condition or expression. When the condition evaluates to Yes, the specified option is considered; when it evaluates to No, the option is not considered.
This is particularly useful when a program needs to provide different results based on different conditions. By using Option, developers can conditionally control which definition is considered during program execution.
In simple terms, Option allows a definition to provide a conditional result based on a specified condition.
Syntax
[Import File: <Import File Name>]
Option : <Optional definition> : <Logical Condition>
Example
[#Import File: Vouchers]
Option : TSPL Empty Payments : @@IsJSONImpFormat
[!Import File: TSPL Empty Payments]
Empty : $$IsPayment:$VoucherTypeName
In this example, the Option attribute is used to conditionally apply the TSPL Empty Payments Import File to the existing Vouchers import definition. The option is enabled when the formula @@IsJSONImpFormat evaluates to Yes, meaning the additional import behaviour is applied when the vouchers are being imported in JSON format.
The TSPL Empty Payments Import File then uses the Empty attribute with the condition $$IsPayment:$VoucherTypeName. When the imported voucher is identified as a Payment voucher, this condition evaluates to Yes and the record is discarded.
This allows the import behaviour to be applied selectively without changing the base Vouchers Import File for every import scenario.
The Response Report attribute comes into play when TallyPrime needs to create a structured response for a SOAP request. It allows developers to specify the name of the report that should be used to create the response.
The attribute accepts the name of a report that is used for creating the Response XML or Response JSON. The specified report is used to create the response string for the SOAP request.
This is particularly useful when developers need to define the report that should be used to generate the response for a SOAP request. By using the Response Report attribute, developers can specify the report from which the response XML or JSON is created.
In simple terms, Response Report specifies the name of the report used to create the Response XML or Response JSON for SOAP requests.
Syntax
[Import File: <Import File Definition Name>]
Response Report : <Response Report Name>
Example
[Import File : Vouchers]
Response Report : TallyCustomResponse
In this example, the Response Report attribute specifies TallyCustomResponse as the report to be used for preparing the response to the Vouchers import. The TallyCustomResponse report needs to be defined with the appropriate XML Tags and can be designed to include information such as the number of vouchers created or altered, along with any additional details required by the requesting system.
Once TallyCustomResponse is specified, TallyPrime uses the output generated by this report as the response. Therefore, the report must be designed to generate all the required response information, including details about how individual voucher objects were processed.
The Set attribute comes into play when a storage value needs to be modified or assigned during an import operation. It allows developers to specify the value that should be assigned to a storage while importing data.
The first sub-attribute specifies the name of the storage, while the second sub-attribute specifies the value to be assigned to that storage. The value can be specified using an expression, allowing developers to define the value that should be stored during the import process.
This is particularly useful when a storage value needs to be modified or set while importing data. By using Set, developers can control the value assigned to a storage as part of the import process.
In simple terms, Set is used to modify or set a storage value while importing.
Syntax
[Import File : <Import File Name>]
Set : <Storage Name> : <Value / Expression>
Example
[Import File: XMLExciseFormat]
Set : DATE : @@SVExciseCurrentDate
The Show Preview attribute comes into play when an import process needs to determine whether a preview should be displayed. It allows developers to specify whether TallyPrime should show a preview during the import process.
The attribute accepts a logical expression that determines whether the preview should be shown. When the expression evaluates to Yes, the preview is shown; when it evaluates to No, the preview is not shown.
This is particularly useful when developers need to control whether a preview is displayed during an import operation. By using the Show Preview attribute, developers can conditionally specify whether the preview should be shown.
In simple terms, Show Preview determines whether to show a preview or not.
Syntax
[Import File : <Import File Name>]
Show Preview: <Logical Expression>
Example
[Import File: JSONImport]
Show Preview: Yes
In this example, the Show Preview attribute is set to Yes, which means TallyPrime will display a preview of the data before proceeding with the import. This gives the user an opportunity to review the imported information before it is processed.
The Switch attribute comes into play when different conditional choices need to be handled during an import process. It is similar to the Option attribute, but provides a more structured way to handle multiple conditions, reducing code complexity and improving performance.
The Switch attribute groups related conditions using a common label. Each Switch statement within a group specifies an optional definition and the condition under which that definition should be used. When a condition in a group evaluates to Yes, the corresponding optional definition is selected, and TallyPrime does not evaluate any further conditions from the same group. However, conditions belonging to other Switch groups, if specified, continue to be evaluated.
The first sub-attribute specifies the label used to group related Switch conditions. The second specifies the name of the optional definition, while the third specifies the logical condition that determines whether the optional definition should be used.
This is particularly useful when multiple conditional choices need to be handled without writing repetitive Option conditions. By grouping related conditions, developers can simplify the code and avoid unnecessary evaluation of further conditions within the same group.
In simple terms, Switch is similar to Option, but groups conditions using a label and stops evaluating further conditions from a group once a condition is satisfied.
Syntax
[Import File : <Import File Name>]
Switch : <Label> : <Optional Definition Name> : <Logical Condition>
Example
[#Import File: Vouchers]
Switch : ImpFormat : JSONImport : @@IsJSONExImpFormat
Switch : ImpFormat : XMLImport : Yes
Consider a scenario where an application needs to work with a user-defined map maintained separately from the standard TDL definitions. Instead of keeping the mapping information directly within the application logic, the User Defined Map attribute allows developers to point TallyPrime to the map that should be used.
The User Defined Map attribute specifies the location and name of the user-defined map file, or identifies a company-level map, depending on how the map is configured. This provides flexibility in managing mapping information outside the main definition.
The first sub-attribute specifies a keyword or SysName that determines whether the map is being specified at the application level or Company level. The second sub-attribute then specifies the corresponding file path or Company Map Key, based on the value provided in the first sub-attribute.
This is particularly useful when mapping information needs to be maintained separately and reused by an application or associated with a particular company. Developers can therefore control where TallyPrime should look for the required map without embedding the mapping details directly into the definition.
Syntax
[Import File : <Import File Name>]
User Defined Map : <Keyword/SysName> : <File Path/Company Map Key>
Example
[Import File : JSONImport]
User Defined Map : Company: ##svImportMapFileName
In simple terms, User Defined Map tells TallyPrime which user-defined map to use and where to find or identify it, based on whether the map belongs to the application or company level.
