https://help.tallysolutions.com/docs/td9rel54/integration_capabilities/te9_as_server.htm

Tally.ERP 9 as a Server – Using External Application as Front-end

Data can be accessed from Tally.ERP 9 once the connection is established between Tally.ERP 9 and other external applications. Here we are usingData can be posted from Visual Basic to Tally.ERP 9 through XML Interface. The existing Tally.ERP 9 data can be altered and deleted from Visual Basic. Let us discuss some scenarios for using external application as front end.

Case Study I – Importing Masters from Excel to Tally.ERP 9

A Company "Global Enterprises" was using external software as on 31st March 2008. As on 1st April 2008, they have procured Tally.ERP 9. There is a requirement for all their ledgers and inventory masters to be transferred to Tally without entering them. The external software has an option to export its master data to Excel. Using the same, all ledger and inventory masters have been exported in Excel Sheets. The data files thus exported are displayed below.

A Company Global Enterprises has been created in Tally.ERP 9 and only default masters exist as shown in the screen below:

The data in Excel needs to be converted to Tally understandable XML format and sent to the port in which Tally.ERP 9 is running.

To achieve this, an interface is built in VB to import all the masters from Excel and generate a Tally compatible XML which is subsequently posted in Tally.ERP 9. The interface application created for the same has been displayed below.

On selecting Type "Stock Items" or "Ledgers" and clicking on Export to Tally button, it transfers all the relevant masters to Tally.ERP 9. On the Export to Tally Button, required XML as discussed earlier is constructed and posted to Tally.ERP 9 which is up at a predefined port.

The XML is generated through the following VB Code Snippet.

Private Function LedgerMasterText(ByVal intI As Integer) As String Dim strTemp As String

Dim strTxt As String

sbExport.SimpleText = intI & ": " & Trim$(xlWS.Cells(intI, 2)) strTxt = vbNullString

strTxt = _

"<ENVELOPE>" & vbCrLf & _ "<HEADER>" & vbCrLf & _

"<VERSION>1</VERSION>" & vbCrLf & _ "<TALLYREQUEST>Import </TALLYREQUEST>" & vbCrLf & _ "<TYPE>Data</TYPE>" & vbCrLf & _

"<ID>All Masters</ID>" & vbCrLf & _ "</HEADER>" & vbCrLf & _

"<BODY>" & vbCrLf & _ "<DESC>" & _

"<STATICVARIABLES>" & _ "<SVCURRENTCOMPANY>" & _

"##SVCurrentCompany" & _

"</SVCURRENTCOMPANY>" & _

"</STATICVARIABLES>" & _

"</DESC>" & _

"<DATA>" & vbCrLf & _

"<TALLYMESSAGE>" & vbCrLf & _ "<LEDGER>" & vbCrLf & _ "<NAME.LIST>" & vbCrLf & _

"<NAME>" & ReplaceXmlText(Trim$(xlWS.Cells(intI, 2))) & "</NAME>" & vbCrLf

If Trim$(xlWS.Cells(intI, 1)) <> vbNullString Then

strTxt = strTxt & "<NAME>" & ReplaceXmlText(Trim$(xlWS.Cells(intI, 1))) & "</NAME>" & vbCrLf

End If

strTxt = strTxt & _

"</NAME.LIST>" & vbCrLf & _

"<PARENT>" & ReplaceXmlText(Trim$(xlWS.Cells(intI, 3))) & "</PARENT>" & vbCrLf

'-----Optional----------

If Trim$(xlWS.Cells(intI, 4)) <> vbNullString Then

strTxt = strTxt & "<ADDRESS.LIST>" & vbCrLf

strTxt = strTxt &

"<ADDRESS>" & ReplaceXml Text(Trim$(xlWS.Cells(intI, 4))) & "</ADDRESS>" _ & vbCrLf 'Address 1

If Trim$(xlWS.Cells(intI, 5)) <> vbNullString Then

strTxt = strTxt & _

"<ADDRESS>" & ReplaceXmlText(Trim$(xlWS.Cells(intI, 5))) &

"</ADDRESS>" & vbCrLf 'Address 2

If Trim$(xlWS.Cells(intI, 6)) <> vbNullString Then

strTxt = strTxt & _

"<ADDRESS>" & ReplaceXmlText(Trim$(xlWS.Cells(intI, 6))) & "</ADDRESS>" & vbCrLf 'Address 3

strTxt = strTxt & "</ADDRESS.LIST>" & vbCrLf

End If

If Trim$(xlWS.Cells(intI, 7)) <> vbNullString Then strTxt = strTxt & _

"<STATENAME>" & ReplaceXmlText(Trim$(xlWS.Cells(intI, 7))) &

"</STATENAME>"

End If

If Trim$(xlWS.Cells(intI, 8)) <> vbNullString Then strTxt = strTxt &

"<LEDGERPHONE>" & ReplaceXmlText(Trim$(xlWS.Cells(intI, 8))) & _ "</LEDGERPHONE>"

End If

If Trim$(xlWS.Cells(intI, 9)) <> vbNullString Then strTxt = strTxt &

"<LEDGERFAX>" & ReplaceXmlText(Trim$(xlWS.Cells(intI, 9))) & _ "</LEDGERFAX>"

End If

If Trim$(xlWS.Cells(intI, 10)) <> vbNullString Then strTxt = strTxt &

"<EMAIL>" & ReplaceXmlText(Trim$(xlWS.Cells(intI, 10))) & _ "</EMAIL>"

End If

strTemp = ReplaceXmlText(Trim$(xlWS.Cells(intI, 2))) strTxt = strTxt &

"<ADDITIONALNAME>" & Trim$(strTemp) & _ "</ADDITIONALNAME>" & _ vbCrLf

strTxt = strTxt & _ "</LEDGER>" & vbCrLf & _

"</TALLYMESSAGE>" & vbCrLf & _ "</DATA>" & vbCrLf & _

"</BODY>" & vbCrLf & _ "</ENVELOPE>" & vbCrLf

LedgerMasterText = strTxt End Function

The following VB Code Snippet sends the above generated XML Data to Tally.ERP 9 which is running at a predefined port.

objXml.open "POST", "http://localhost:9000", False

objXml.send XMLToPost

On importing both Ledgers and Inventory Masters, statistics is as shown below:

In the above figure, we can observe that 5 Ledgers and 6 Stock Items have been imported from Excel. If there are some errors while Importing, Tally.imp can be referred for Import Log.