Type search words and press enter
Seamless e-invoicing is now at your fingertips. Check out our self-help videos.

Tally.ERP 9 as a Client – Tally as a Frontend for Web Services

With the new enhancements now Tally can send a request to the HTTP Server and display the response. Tally sends the request as an XML and receives the response in XML format. Tally can collect data directly from an XML file or from a web service running on the server. Even data can be sent along with the request to the web service which can process the data and return the result as an XML. The web service in turn might be operating on an external data base.

Following Figure shows the functionality when Tally acting as a client interacts with a web service operating on the external data.

Collection capability has been enhanced to gather live data from HTTP/web-service delivering XML. The entire XML is now automatically converted to TDL objects and is available natively in TDL reports as $ based methods. Reports can be shown in Tally with live data from an HTTP server. Coupled with the new [OBJECT:] extensions and Using POST action data can be submitted data back to the server almost operating Tally as a client to HTTP-XML web-services.

This capability allows us to retrieve and store data as objects in Collection. The attributes in col-lection for gathering XML based data from a remote server over HTTP are RemoteURL, Remot-eRequest, XMLObjectPath, and XMLObject. Whenever the collection is referred the data is fetched from the remote server and is populated in the collection.

Events On Focus, On Form Accept and Action - HTTP - POST are used providing the flexibility to send a request automatically to server when a particular event occurs.

Consider that the file TestXML.xml contains data and Tally sends a request to fetch the data. Once the data is available any data manipulation operation can be performed on it.

The TestXML.xml file contains the following:


<NAME>Sapna Awasthi</NAME> <EMPID>1000</EMPID>







<ADDRLINE>C/o. Info Solutions</ADDRLINE>

<ADDRLINE>Technology Street</ADDRLINE>




Note: Prerequisites for Data Transfer over HTTP

In order to retrieve the data available in TestXML.xml File from a remote server (Pre-defined IP Address) ensure that web service is running on the machine. Check for IIS Server Installation. The file TestXML.xml can be copied to the directory C:\Inetpub\wwwroot to be accessible at the root and then the URL can be specified as follows http://localhost/TestXML.xml.

If the XML request needs to be processed at the remote server by a file (.asp,.php, etc.), at least one web server (e.g., IIS, Apache etc) and PHP/ASP must be installed on the system.

Collection attributes introduced to facilitate these capabilities are:

[Collection: <Collection Name>]

RemoteURL : <http-url formula>

RemoteRequest : <Request-report-name>,<pre-request-display-report>: <Encoding type>

XMLObjectPath : <Start-node> : <Path-to-start-node>

XMLObject : <TDL-Object-Name>

Once the collection is populated with the objects it can be used in TDL reports to display the retrieved data. The XML TAG names can be used as methods in the TDL programs. The methods names must be in the same case as the XML Tag name.


If the XML tag name is written as <NAME> then $NAME must be used as method name while referring it in TDL.

If the XML tag name is written as <Name> then $Name must be used as method name while referring it in TDL.

Collection attribute – Remote URL

Remote URL attribute is used to specify the Universal Resource Locator (URL) of the HTTP server delivering the XML data. The URL can be directly specified as string or through a String formula. This attribute is mandatory to access the data in XML format from remote server in a collection.

The collection is created as follows to populate XML Data available at the URL http://localhost/TestXML.xml:


RemoteURL: <http-url formula>


< http-url formula > This can be any string formula which resolves as an URL.


[Collection: XML Get Collection]

Remote URL : "http://localhost/TestXML.xml"

This collection can be used in a TDL Report to display the data retrieved. In order to display the retrieved data the line is repeated over this collection.

Repeat: XMLDetLn : XMLGetCollection

In the field the XML TAG names are used as method names.

[Field: CustNm]

Set As : $NAME

To display the PHONE and ADDRESS details, the line can be exploded.

[Line : XMLDetLn]

Explode : PhPart

Explode : AddPart

In the Exploded parts the line is repeated over the PHONE and ADDRESS collection respectively.

[Part : PhPart]

Repeat : PhLine : PHONE

[Part: AddPart]

Repeat: AddLine : ADDRESS

Collection attribute – XML Object Path

By default, all the data from XML file is made available in the collection. If only a specific data fragment is required it can be obtained using the collection attribute XML Object Path. This attributes converts the extracted fragment as TDL Objects in Collection. By default, it takes the root node.


XMLObjectPath : <Start-node> : <Path-to-start-node>


< Start- Node > allows you to specify the name and position of the XML node from which the data should be extracted. The parameter is specified as follows:

<Node Name> : <Position>

< Path-to-Start-Node > is used to specify the path to reach the <start node> from the root node. The path specification is:

<Root-node>: <Child Node> : <Start Pos> : <Child Node> : <Start Pos> …


From the XML file, if only address is required then the collection is defined as follows:

[Collection: XML Get CollObjPath]

Remote URL : "http://localhost/TestXML.xml"


Collection attribute – XML Object

XMLObject attribute is used to specify the TDL Object specification.


XMLObject : <TDL-Object-Name>


< TDL -Object Name > is user defined name. The data is required to be mapped as TDL Objects. The following syntax is used for object specification:

[Object: <Object Name>]

Storage : <Name> : Type

Collection : <Name> : Type

The second Parameter in the Collection Type can be an Object type in case of a complex collection or a simple data type in case of simple collection.


The data available in XML format is at the URL "http://Remoteserver/TestXML.xml". The collection attribute XML Object is used to specify the object name to which the obtained data is mapped.

[Collection: XML Get Collection]

Remote URL : "http://Remoteserver/TestXML.xml"

XML Object : Customer Data

The Object specification for "Customer Data" is as follows:

[Object: Customer Data]

Storage : Name : String

Storage : EmpId : String

;;Complex collections

Collection : Phone : XML Phone Coll

Collection : ADDRESS : XML AddressColl

[Object: XML Phone Coll]

Storage : OfficeNo : String

Storage : HomeNo : String

Storage : Mobile : String

[Object: XML AddressColl]

Collection : AddrLine : String ;; Simple collection

Collection attribute – Remote Request

A TDL report can be sent to the HTTP server as an XML request and the XML response is to be obtained in the collection. RemoteRequest attribute is used to specify the Report name which is to be sent to the HTTP server as an XML Request. If the report requires user inputs then it has to be accepted before the request is sent. Pre-request is used to specify the name of the report which accepts the user-input.


RemoteRequest: <request-report-name>,<pre-request-report>: + <encoding type>


< Encoding Type > specifies the encoding to be used while transmitting information to the receiving end. The valid encoding formats are ASCII and UNICODE. UNICODE is set by default.

< Request Report Name > is the name of the TDL Report which will be used for generating XML Request to be sent.

< Pre-Request Report Name > is the name of the TDL Report which accepts the user-input.


The Test.php page on the remote server accepts the data in the following XML format.







Following collection sends request in the above XML format with the help of a TDL report XML-PostReqRep. The encoding scheme selected is ASCII.

[Collection: XML Post Collection]

Remote URL : "http://Remoteserver/test.php"

RemoteRequest : XMLPostReqRep : ASCII

The report XMLPostReqRep is automatically executed when the collection is referred.

Request Report

In the request report XMLPostReqRep , the XMLTAG attribute is used at Part and Field Definitions. The XML Tag <ENVELOPE> is added by Tally while sending the XML request.

In the part definition the XMl TAG is specified as "REQUEST".

[Part: XMLPostReqRep]


Scroll : Vertical

In the field definitions the tag names "NAME" and "EMPID" are specified.

[Field: XMLPostReqRepName]

XML Tag : "NAME"

Set As : " Tally "

[Field: XMLPostReqRepId]

XML Tag : " EMPID "

Set As : " 00000 "

The response received from "http://Remoteserver/test.php" page is the same XML given previ-ously. The data now available in the collection can be displayed in a TDL report.

Pre- request Report

A Pre-request report is required when some inputs are to be accepted from the user and the XML Request is to be generated out of those inputs. In that case, a TDL report is used which has to be accepted first. If the data captured through pre request report has to be sent to remote server for processing then it has to be made available in the Request Report. The input report name is specified as Pre Request Report.

[Collection: XML Post Collection]

Remote URL : "http://localhost/test.php"

RemoteRequest : XMLPostReqRep, XML PreReqRep : ASCII

The Report XMLPostReqRep sends the XML request to the page Test.php in the format described earlier. Before sending the XML request to the page, the data entered in the report XML PreReqRep must be accepted. The data entered in the Pre-Request report can also be sent to the remote server in the XML request. Both the reports are triggered when the collection is referred. PreRequest Report is only used to accept value from the user. These values are sent to the HTTP Server through the Request Report Only.

Action – HTTP POST

A new Key/Button Action HTTP Post has been introduced which will help in exchanging data with external applications using web services. In other words, HTTP Post action can be used to submit data to a server over HTTP and gather the response. This will enable a TDL Report to perform a HTTP Post to a remote location.


[Key: <Key Name>]

Key : <Key Combination>

Action : HTTP Post : <URL Formula> : <Encoding> : <Request Report>: <Error Report> : <Success Report >


< URL Formula > can be any string formula which resolves as an URL and is defined under System Definition.

< Encoding > is the encoding scheme ASCII or UNICODE .

< Request Report > is the name of the TDL Report which will be used for generating XML Request to be sent.

< Error Report > is displayed in case of failure.

< Success Report > is displayed when the post is successful.

The details pertaining to URL (at the receiving end), Encoding Format, RequestReport , Error Report and Success Report should be specified along with HTTP Post Action. The Request, Error and Success reports are optional.

Success and failure is determined by <STATUS> tag in the standard message format. If it is 1 then success else it is failure. Based on the value of the <STATUS> tag 0/1, the error report and success report are executed respectively. It will not close or accept the form if status is not equal to 1.


[Key: XMLReqResp]

Key : Ctrl + R

Action : HTTP Post : @@MyUrl : ASCII : ReqRep: ERRRespRep: SuccRep

Scope : Selected Lines

;;URL Specification must be done as a system formula

[System: Formula]

MyUrl :

The defined Key XMLReqResp in the snippet above must be attached to an initial Report. When the report is activated and this Key is pressed, the Action HTTP Post activates a defined report ReqRep which generates the request XML. The response data is made available in collection called Parameter Collection. The reports ERRRespRep and SuccRep can use the Parameter Collection to display the error message/data in the Report.

Two events are introduced in Tally.ERP 9, they are: OnFormAccept and OnFocus

Event – On Form Accept

A new event is introduced in Form definition, On: Form Accept . A list of actions can be executed when the form is accepted. The execution can be based on a condition.


On: Form Accept: <Condition>: Action: Action parameters


< Condition > should return a logical value. <Action> any one of the actions

< Action Parameters > parameters of the actions specified.


[Form: TestForm]

On:FormAccept:Yes:HttpPost:@@SCURL:ASCII:SCPostNewIssue:SC NewIssueResp

Event – On Focus

In the definitions Part, Line and Field a new event On : Focus is introduced. When the Part, Line or Field receives a focus list of action can be executed. A condition can also be specified. When the condition returns true then only the actions will be executed.


On : Focus : condition : Action : Action parameters

< Condition > should return a logical value <Action> any one of the actions

< Action Parameters > parameters of the actions specified Its a list type attribute so as many actions can be specified.

[Part : TestPart1]

On : FOCUS : Yes : HTTP Post : @@MyUrl : ASCII : ReqRep, RespRep

[Part : TestPart2]

On : FOCUS : Yes : Call : SCSetVariables : $$Line

Collection Capability to Accept File as a Data Source

Collection is enhanced to support a generalized data source structure. All types of data sources are currently made available through different attributes of collection. For example: To retrieve data from ODBC collection attributes, ODBC, SQL, and SQL Object are used.

The new attribute Data Source can be used for any type of Data source.

The Collection attribute – Data Source

As of now the attribute data source allows to specify XML file as data source. The collection can be created directly from the specified XML file and the data in the XML file can be displayed in a report.


DataSource : <Type> : <Encoding> : <Identity>

< Type > specifies the type of data source. For example, File Xml, HTTP XML, ODBC etc <Encoding> ASCII or UNICODE. This is Optional .The default value is UNICODE. < Identity > Data source file path


[Collection: My XML Coll]

DataSource : File Xml : "C:\MyFile.xml"

In the above code snippet the type of file is 'File XML ' as the data source is XML file. The encoding is Unicode by default as it is not specified.

Support for other data sources like ODBC, HTTP will also be available in future builds.