Thursday, November 15, 2012

TDL Specifications in XML Request

Report specification in TDL. 

<HEADER>
        <VERSION>1</VERSION>
        <TALLYREQUEST>Export</TALLYREQUEST>
        <TYPE>Data</TYPE>
        <ID>Report Name </ID>
</HEADER>

In the above header format the value of Tally Request is Export and the Type is data. Specifying the value of ID is Report Name. This report name should come inside the tag <REPORT> within the <TDL> tag.

Example : 

<TDL>
          <TDLMESSAGE>
                    <REPORT NAME="TDL Report" ISMODIFY="No" ISFIXED="No"
                                                 ISINITIALIZE="No" ISOPTION="No" ISINTERNAL="No">
                              <FORMS>First TDL Form</FORMS>
                    </REPORT>
                             .
                             .
          </TDLMESSAGE>
</TDL>

Collection specification in TDL.

<HEADER>
        <VERSION>1</VERSION>
        <TALLYREQUEST>Export</TALLYREQUEST>
        <TYPE>Collection</TYPE>
        <ID>Collection Name</ID>
</HEADER>

In the above template the value of Tally Request is Export and the Type is Collection. Specifying the value of ID is Collection Name. This collection name should come inside the tag <COLLECTION > within the <TDL> tag.

Example :

<TDL>
         <TDLMESSAGE>
                   <COLLECTION NAME="Collection of Ledgers"
                                                ISMODIFY="No" ISFIXED="No" ISINITIALIZE="No"
                                                ISOPTION="No" ISINTERNAL="No">
                             <TYPE>Ledger</TYPE>
                   </COLLECTION>
                               .
                               .
                               .
         </TDLMESSAGE>
</TDL>

Object specification in TDL.

<HEADER>
        <VERSION>1</VERSION>
        <TALLYREQUEST>Export</TALLYREQUEST>
        <TYPE>Object</TYPE>
        <ID>Object Name</ID>
</HEADER>

In the above template the value of Tally Request is Export and the Type is Object. Specifying the value of ID is Object Name. This object name should come inside the tag <OBJECT> within the <TDL> tag.

Example :

<TDL>
        <TDLMESSAGE>
                  <OBJECT NAME="Ledger" ISINITIALIZE="Yes">
                             <LOCALFORMULA> TNetBalance: $$AsPositive: $$AmountSubtract:
                                                                                         $ClosingBalance: $OpeningBalance
                             </LOCALFORMULA>
                  </OBJECT>
        </TDLMESSAGE>
</TDL>

Function specification in TDL.

<HEADER>
        <VERSION>1</VERSION>
        <TALLYREQUEST>Export</TALLYREQUEST>
        <TYPE>Function</TYPE>
        <ID>Function Name</ID>
</HEADER>

In the above template the value of Tally Request is Export and the Type is Function. Specifying the value of ID is Function Name.

Example :
 
<DESC>
        <FUNCPARAMLIST>
                   <PARAM>@@FirstParameter</PARAM>
                   <PARAM TYPE="Number">0.10</PARAM>
        </FUNCPARAMLIST>
        <TDL>
                  <TDLMESSAGE>
                            <SYSTEM TYPE="Formulae" NAME="FirstParameter" >
                                          1242849 / 1000
                            </SYSTEM>
                  </TDLMESSAGE>
        </TDL>
</DESC>

In the above example, the function parameter list enclosed with the tag <FUNCPARAMLIST>. The formula which is used inside the Function parameter list is specified inside TDL Tag.

Saturday, November 10, 2012

Significance of Tally XML Tags

Significance of Tally XML Tags. 

Following are some significant tags that are required for requesting any info from Tally.ERP 9.
The tags are divided into two categories:
  • Header Tags
  • Body
Header Tags.

Header tags are enclosed with the tag <HEADER> and </HEADER>. These tag gives all the header information.

Example : Tags coming under the header tags.

        <HEADER>
                  <VERSION>1</VERSION>
                  <TALLYREQUEST>EXPORT</TALLYREQUEST>
                  <TYPE>OBJECT</TYPE>
                  <SUBTYPE>Ledger</SUBTYPE>
                  <ID TYPE="Name">ABC India Pvt. Ltd. </ID>
        </HEADER>
 
<VERSION>  .....  </VERSION>

It gives the version of the messaging format. The tag <VERSION> is a mandatory tag which is used in Header tags.

<TALLYREQUEST>  .....  </TALLYREQUEST>

TALLYREQUEST tag specifies the type of request. This tag is vital as it determines the response required. The permissible values for this tag are Import, Export and Execute. This value further determines the range of values required for this tag.  
  • Import
Import is specified when we want Tally to import data from the XML fragment to Tally. i.e Tally validates and saves the data. A request is made to Import Data or File which can be specified within the subsequent tags. 
  • Export
Export is specified when we want to retrieve data from Tally. A request is made to Export Data, Collection, Object, Function, etc. which is specified within the tag <TYPE>.  
  • Execute
Execute is specified when we want to execute some TDL Action in Tally.ERP 9. Here the request is made to Execute TDL Action which can be specified within the <TYPE> tag.

<TYPE>  .....  </TYPE>

The <TYPE> tag provides the type of information being requested / responded. The tag TALLYREQUEST determines the value for this tag.

The possible values of <TYPE> tag are as follows: 
  • Data - Request for the data or Response of data.
  • Collection - Collection Request or Response.
  • Object - Object Request or Response.
  • Action - Action to be performed by the message recipient.
  • Function - Execute the Function Request.

<SUBTYPE>  .....  </SUBTYPE>

<SUBTYPE> is an optional tag. In cases the <TYPE> tag alone is not sufficient to identify the entity then SUBTYPE tag will be used. For example OBJECT refers to various types of objects such as GROUP, LEDGER, and CURRENCY etc.

<ID>  .....  </ID>

<ID> tag provides the identification of Request. The TYPE attribute of this tag can be used to identify specific instance of an entity.

<STATUS> .....  </STATUS>

The <STATUS> tag is applicable only for Response. Value within this tag indicates success or failure of the request made. Possible values are SUCCESS (1), FAILURE (0).

Body Tags.

As discussed, there are two sections under the tag <BODY>: 
  • <DESC>: Description for Request / Respons
  • <DATA>: Data required for Request / Response 
<DESC> ..... </DESC>  : Description for Request / Response

The description block is used for providing description of Request / Response. Following are the different types of descriptions available inside the description tag: 
  • StaticVariable
  • RepeatVariables
  • ComputeList
  • FetchList
  • Function ParamList
  • TDL

<STATICVARIABLES>  .....  </STATICVARIABLES>

The STATICVARIABLES provides all configuration details and all global variable details. All tags inside Staticvariable would be any of the system variables. In the following example SVCurrentCompany, SVFromDate and SVToDate are the system variables. All elements inside the tag <STATICVARIABLES> would be starting with SV.

        <DESC>
                <STATICVARIABLES>
                         <SVCURRENTCOMPANY> ABC Company Ltd  </SVCURRENTCOMPANY>
                         <SVFROMDATE TYPE="Date">1-Apr-2008</SVFROMDATE>
                         <SVTODATE TYPE="Date">31-Mar-2009</SVTODATE>
                 </STATICVARIABLES>
        </DESC>

<REPEATVARIABLES>  .....  </REPEATVARIABLES>

REPEATVARIABLES is used to specify the details for all the repeated variable information such as Date Range, Block Range etc. All the information related to repeated variables will be enclosed within the tag <REPEATSET>. Here also the value will be enclosed with the system variables. In the following example shows the repeated usage of variables.

        <REPEATVARIABLES>
                    <REPEATSET>
                                <SVFROMDATE>1-Apr-2007</SVFROMDATE>
                                <SVFROMDATE>1-Oct-2007</SVFROMDATE>
                    </REPEATSET>
                    <REPEATSET>
                                <SVTODATE>30-Sep-2007</SVTODATE>
                                <SVTODATE>31-Mar-2008</SVTODATE>
                      </REPEATSET>
        </REPEATVARIABLES>

<FETCHLIST>  .....  </FETCHLIST>

FETCHLIST is used to specify the list of storages to be fetched. In case of type object the methods that need to be retrieved within the <FETCHLIST> Tag using <FETCH> Tags.

        <FETCHLIST>
                    <FETCH>TBalClosing</FETCH>
                    <FETCH>TBalOpening</FETCH>
                    <FETCH>StkClBalance</FETCH>
                    <FETCH>StkOpBalance</FETCH>
        </FETCHLIST>

<FUNCPARAMLIST>  .....  </FUNCPARAMLIST>

It is used to specify the parameters used for function execution. In the time of using Function as a type with parameters then the parameter list will come under the tag <PARAMLIST>. The structure of PARAMLIST as follows:

        <FUNCPARAMLIST>
                    <PARAM>@@FirstParameter</PARAM>
                    <PARAM TYPE="Number">0.10</PARAM>
        </FUNCPARAMLIST>

<TDL>  .....  </TDL>

It is used to specify the TDL related information. The complete TDL to be executed in order to handle the Request; will be sent within the TDL block. TDL tag is specified, when Report, Collection, Object or Function is to be sent as a request to Tally. Tally application will respond depends on the TDL request. A TDL specification is required only when the TDL required for serving the request does not exist at the Tally end.

The TDL program is sent using TDL tag as per the following structure:

        <TDL>
                 <TDLMESSAGE>
                          <REPORT NAME="TDL Report" ISMODIFY="No" ISFIXED="No"
                                                         ISINITIALIZE="No" ISOPTION="No" ISINTERNAL="No">
                                        <FORMS>First TDL Form</FORMS>
                          </REPORT>
                          <FORM NAME="First TDL Form" ISMODIFY="No" ISFIXED="No"
                                                          ISINITIALIZE="No" ISOPTION="No" ISINTERNAL="No">
                                        <TOPPARTS>First TDL Part</TOPPARTS>
                          </FORM>
                                  .
                                  .
                                  .
                           <FIELD NAME="First TDL Field" ISMODIFY="No"
                                                           ISFIXED="No" ISINITIALIZE="No" ISOPTION="No"
                                                           ISINTERNAL="No">
                                         <SET>"Welcome to the world of TDL"</SET>
                            </FIELD>
                  </TDLMESSAGE>
        </TDL>

TDL request should be enclosed within <TDL> tags. The <TDLMESSAGE> tag is mandatory inside the <TDL> tag. Inside that we can write all the definitions and its attributes with their values. All definitions and attributes are represented as tags.

<DATA>  .....  </DATA> : Data required for the Request / Response

Data contains the actual data being transferred from one system to another. If the information is retrieved then the data will be obtained inside the <DATA> tag.

        <DATA>
                  <COLLECTION>
                             <OBJECT NAME="CDROM Disks 10s - Defective">
                                        <NAME TYPE="String">CDROM Disks 10s - Defective</NAME>
                             </OBJECT>
                             <OBJECT NAME="TVS MSP 245 132 Col Printer">
                                        <NAME TYPE="String">TVS MSP 245 132 Col Printer</NAME>
                             </OBJECT>
                                        <OBJECT NAME="Assembled PIV">
                                        <NAME TYPE="String">Assembled PIV</NAME>
                             </OBJECT>
                 </COLLECTION>
        </DATA>

In the case of importing data to be sent to Tally, to be specified within the <DATA> tag.

        <DATA>
                 <TALLYMESSAGE>
                            <LEDGER Action = "Create" >
                                     <NAME>ICICI Test</NAME>
                                     <PARENT>Bank Accounts</PARENT>
                                     <OPENINGBALANCE>13500</OPENINGBALANCE>
                            </LEDGER>
                 </TALLYMESSAGE>
        </DATA>