Explore Categories

 

 PDF

TallyPrime as a Server – Using External Application as Front-end

Data can be accessed from TallyPrime once the connection is established between TallyPrime and other external applications. Here we are using Data can be posted from Visual Basic to TallyPrime through XML Interface. The existing TallyPrime 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 TallyPrime

A Company “Global Enterprises” was using external software as on 31st March 2008. As on 1st April 2008, they have procured TallyPrime. 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 TallyPrime 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 TallyPrime 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 TallyPrime. 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 TallyPrime. On the Export to Tally Button, required XML as discussed earlier is constructed and posted to TallyPrime 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 TallyPrime 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.

Post a Comment

Is this information useful?
YesNo
Helpful?