xmltallytdl

Not able to fetch LedgerList data in an XML request from Tally


While exporting data from Tally, I'm not able to fetch the ledger details of the invoice.

I am only able to fetch the outer-level details.

I tried with Walk by: Ledger Entries, but it does not come under the Voucher tag. How can I make it possible?

Also, I am having a big doubt about the form, part, and line work flow.

<ENVELOPE>
<HEADER>
    <VERSION>1</VERSION>
    <TALLYREQUEST>Export</TALLYREQUEST>
    <TYPE>Data</TYPE>
    <ID>DaybookGR</ID>
</HEADER>
    <BODY>
        <DESC>
            <STATICVARIABLES>
                <EXPLODEFLAG>Yes</EXPLODEFLAG>
                <CURRENTCOMPANY>${company}</CURRENTCOMPANY>
                <SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
                <SVFROMDATE>${fromDate}</SVFROMDATE>
                <SVTODATE>${toDate}</SVTODATE>
            </STATICVARIABLES>
            <TDL>
                <TDLMESSAGE>
                    <REPORT NAME="DaybookGR">
                        <FORMS>DaybookGR</FORMS>
                        <TITLE>DaybookGR </TITLE>
                    </REPORT>
                    <FORM NAME="DaybookGR">
                        <TOPPARTS>DaybookGR</TOPPARTS>
                        <XMLTAG>"TallyGraphs"</XMLTAG>
                    </FORM>
                    <PART NAME="DaybookGR">
                        <TOPLINES>Daybook Line Title, Daybook Details</TOPLINES>
                        <REPEAT>Daybook Details : GetLedgerCollAmt</REPEAT>
                        <SCROLLED>Vertical</SCROLLED>
                        <COMMONBORDERS>Yes</COMMONBORDERS>
                    </PART>
                    <PART NAME="Ledgerlist Line Title">
                     <TOPLINES>Ledgerlist Line Title,Ledger Details</TOPLINES>
                        <REPEAT>Ledger Details : GetLedger</REPEAT>
                        <SCROLLED>Vertical</SCROLLED>
                        <COMMONBORDERS>Yes</COMMONBORDERS>
                    </PART>
                    <LINE NAME="Daybook Line Title">
                        <USE>Daybook Details</USE>
                        <LOCAL>Field : Default : Type : String </LOCAL>
                        <LOCAL>Field : Field Amount : Set as: "Amount"</LOCAL>
                    </LINE>
                    <LINE NAME="Ledgerlist Line Title">
                        <USE>Ledger Details</USE>
                        <LOCAL>Field : Default : Type : String </LOCAL>
                        <LOCAL>Field : Field Amount : Set as: "Amount"</LOCAL>
                    </LINE>
                    <LINE NAME="Daybook Details">
                        <LEFTFIELDS>PartyLedgerName</LEFTFIELDS>
                        <RIGHTFIELDS>vchType,VoucherNumber,Amount,Date</RIGHTFIELDS>
                        <XMLTAG>Voucher</XMLTAG>
                        <EXPLODE>Ledgerlist Line Title</EXPLODE>
                        <BELONGSTO>YES</BELONGSTO>
                    </LINE>
                    <LINE NAME="Ledger Details">
                        <LEFTFIELDS>PartyLedgerName</LEFTFIELDS>
                        <XMLTAG>LedgerList</XMLTAG>
                    </LINE>
                    <FIELD NAME="PartyLedgerName">
                        <USE>Name Field</USE>
                        <SET>$LedgerName</SET>
                    </FIELD>
                   <FIELD NAME="Date">
                        <USE>Long Date Field</USE>
                        <SET>$$DDMMYYYYDateFormat:$Date:"-"</SET>
                    </FIELD>
                    <FIELD NAME="VoucherNumber">
                        <USE>Name Field</USE>
                        <SET>$VoucherNumber</SET>
                    </FIELD>
                    <FIELD NAME="Amount">
                        <USE>Amount Field</USE>
                        <SET>$Amount</SET>
                    </FIELD>

                    <COLLECTION NAME="AllVouchers" ISMODIFY="No">
                        <TYPE>Voucher</TYPE>
                        <BELONGSTO>YES</BELONGSTO>
                    </COLLECTION>
                    <COLLECTION NAME="GetLedger" ISMODIFY="No">
                    <walk>Ledger</walk>
                        <BELONGSTO>YES</BELONGSTO>
                            <FILTER>IsOptionalFilter</FILTER>
                              <FETCH>PartyLedgerName</FETCH>
                        </COLLECTION>
                    <COLLECTION NAME="GetLedgerCollAmt" ISMODIFY="No">
                            <SourceCOLLECTION>AllVouchers</SourceCOLLECTION>
                            <FILTER>IsOptionalFilter</FILTER>
                              <FETCH>VoucherNumber,LedgerName,Amount,VoucherTypeName,Date</FETCH>
                        </COLLECTION>
                        <SYSTEM TYPE="Formulae" NAME="IsOptionalFilter">NOT $IsOptional</SYSTEM>
                </TDLMESSAGE>
            </TDL>
        </DESC>
    </BODY>
</ENVELOPE>

My expected output structure is:

`<TALLYGRAPHS>
        <VOUCHER>
              <PARTYLEDGERNAME></PARTYLEDGERNAME>
              <VOUCHERTYPENAME></VOUCHERTYPENAME>
              <VOUCHERNUMBER></VOUCHERNUMBER>
              <AMOUNT></AMOUNT>
              <DATE></DATE>
            <Ledgerlist>........</Ledgerlist>
            <Ledgerlist>........</Ledgerlist>
         </VOUCHER>
         <VOUCHER>
                 <PARTYLEDGERNAME></PARTYLEDGERNAME>
                  <VOUCHERTYPENAME></VOUCHERTYPENAME>
                  <VOUCHERNUMBER></VOUCHERNUMBER>
                   <AMOUNT></AMOUNT>
                    <DATE></DATE>
            <Ledgerlist>........</Ledgerlist>
            <Ledgerlist>........</Ledgerlist>
         </VOUCHER>
    </TALLYGRAPHS>`

Solution

  • If you want control of fields you want in Ledger Entries, then you have to take everything into control.

    <ENVELOPE>
        <HEADER>
            <VERSION>1</VERSION>
            <TALLYREQUEST>Export</TALLYREQUEST>
            <TYPE>Data</TYPE>
            <ID>DaybookGR</ID>
        </HEADER>
        <BODY>
            <DESC>
                <STATICVARIABLES>
                    <EXPLODEFLAG>Yes</EXPLODEFLAG>
                    <CURRENTCOMPANY>${company}</CURRENTCOMPANY>
                    <SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
                    <SVFROMDATE>${fromDate}</SVFROMDATE>
                    <SVTODATE>${toDate}</SVTODATE>
                </STATICVARIABLES>
                <TDL>
                    <TDLMESSAGE>
                        <REPORT NAME="DaybookGR">
                            <FORMS>DaybookGR</FORMS>
                            <TITLE>DaybookGR </TITLE>
                        </REPORT>
                        <FORM NAME="DaybookGR">
                            <TOPPARTS>DaybookGR</TOPPARTS>
                            <XMLTAG>"TallyGraphs"</XMLTAG>
                        </FORM>
                        <PART NAME="DaybookGR">
                            <TOPLINES>Daybook Line Title, Daybook Details</TOPLINES>
                            <REPEAT>Daybook Details : GetLedgerCollAmt</REPEAT>
                            <SCROLLED>Vertical</SCROLLED>
                            <COMMONBORDERS>Yes</COMMONBORDERS>
                        </PART>
                        <PART NAME="Ledgerlist Line Title">
                            <TOPLINES>Ledger Details</TOPLINES>
                            <REPEAT>Ledger Details:LedgerEntries</REPEAT>
                            <SCROLLED>Vertical</SCROLLED>
                            <COMMONBORDERS>Yes</COMMONBORDERS>
                        </PART>
                        <LINE NAME="Daybook Line Title">
                            <USE>Daybook Details</USE>
                            <LOCAL>Field : Default : Type : String </LOCAL>
                            <LOCAL>Field : Field Amount : Set as: "Amount"</LOCAL>
                        </LINE>
                        <LINE NAME="Ledgerlist Line Title">
                            <USE>Ledger Details</USE>
                            <LOCAL>Field : Default : Type : String </LOCAL>
                            <LOCAL>Field : Field Amount : Set as: "Amount"</LOCAL>
                        </LINE>
                        <LINE NAME="Daybook Details">
                            <LEFTFIELDS>PartyLedgerName</LEFTFIELDS>
                            <RIGHTFIELDS>vchType,VoucherNumber,Amount,Date</RIGHTFIELDS>
                            <XMLTAG>Voucher</XMLTAG>
                            <EXPLODE>Ledgerlist Line Title</EXPLODE>
                        </LINE>
                        <LINE NAME="Ledger Details">
                            <LEFTFIELDS>PartyLedgerName</LEFTFIELDS>
                            <XMLTAG>LedgerList</XMLTAG>
                        </LINE>
                        <FIELD NAME="PartyLedgerName">
                            <USE>Name Field</USE>
                            <SET>$LedgerName</SET>
                        </FIELD>
                        <FIELD NAME="Date">
                            <USE>Long Date Field</USE>
                            <SET>$$DDMMYYYYDateFormat:$Date:"-"</SET>
                        </FIELD>
                        <FIELD NAME="VoucherNumber">
                            <USE>Name Field</USE>
                            <SET>$VoucherNumber</SET>
                        </FIELD>
                        <FIELD NAME="Amount">
                            <USE>Amount Field</USE>
                            <SET>$Amount</SET>
                        </FIELD>
                        <COLLECTION NAME="AllVouchers" ISMODIFY="No">
                            <TYPE>Voucher</TYPE>
                            <BELONGSTO>YES</BELONGSTO>
                        </COLLECTION>
                        
                        <COLLECTION NAME="GetLedgerCollAmt" ISMODIFY="No">
                            <SourceCOLLECTION>AllVouchers</SourceCOLLECTION>
                            <FILTER>IsOptionalFilter</FILTER>
                            <FETCH>VoucherNumber,LedgerName,Amount,VoucherTypeName,Date,Ledgerentries.*</FETCH>
                        </COLLECTION>
                        <SYSTEM TYPE="Formulae" NAME="IsOptionalFilter">NOT $IsOptional</SYSTEM>
                    </TDLMESSAGE>
                </TDL>
            </DESC>
        </BODY>
    </ENVELOPE>
    

    If you don't want control of fields in Ledger Entries then use below XML

    <ENVELOPE>
        <HEADER>
            <VERSION> 1</VERSION>
            <TALLYREQUEST>Export</TALLYREQUEST>
            <TYPE>COLLECTION</TYPE>
            <ID>AllVouchers</ID>
        </HEADER>
        <BODY>
            <DESC>
                <STATICVARIABLES>
                    <EXPLODEFLAG>Yes</EXPLODEFLAG>
                    <CURRENTCOMPANY>${company}</CURRENTCOMPANY>
                    <SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
                    <SVFROMDATE>${fromDate}</SVFROMDATE>
                    <SVTODATE>${toDate}</SVTODATE>
                </STATICVARIABLES>
                <TDL>
                    <TDLMESSAGE>
                       
                        <COLLECTION NAME="AllVouchers" ISMODIFY="No">
                            <TYPE>Voucher</TYPE>
                            <FETCH>LedgerEntries.*</FETCH>
                            <BELONGSTO>YES</BELONGSTO>
                        </COLLECTION>
                        
                    </TDLMESSAGE>
                </TDL>
            </DESC>
        </BODY>
    </ENVELOPE>