xmlrequesttallytdl

Is there a way to extract all the stock items from Tally Group/Category including the items inside sub-group with Tally XML request?


Tally XML request to get all stock items with their quantity, rate, and alias name/part number from the mentioned group/category and the stock items under that group/category.

I have tried to modify the following code by setting <EXPLODE> to YES in <STATICVARIABLES>.

<ENVELOPE>
    <HEADER>
        <VERSION>1</VERSION>
        <TALLYREQUEST>Export</TALLYREQUEST>
        <TYPE>Collection</TYPE>
        <ID>maincol</ID>
    </HEADER>
    <BODY>
        <DESC>
            <STATICVARIABLES/>
            <TDL>
                <TDLMESSAGE>
                    <COLLECTION ISINTERNAL="No" ISOPTION="No" ISINITIALIZE="No" ISFIXED="No" ISMODIFY="No" NAME="maincol">
                        <Type>stock item</Type>
                        <Method>Name:$name</Method>
                        <Method>parent:$parent</Method>
                        <Filters>test</Filters>
                    </COLLECTION>
                    <SYSTEM ISINTERNAL="No" ISFIXED="No" ISMODIFY="No" NAME="test" TYPE="Formulae">$parent="Tes" </SYSTEM>
                </TDLMESSAGE>
            </TDL>
        </DESC>
    </BODY>
</ENVELOPE>
//But this fails to fetch stock items inside sub-group

I have also tried using the following code which gets the sub-items

<ENVELOPE>
              <HEADER>
                  <TALLYREQUEST>Export Data</TALLYREQUEST>
              </HEADER>
              <BODY>
                  <EXPORTDATA>
                      <REQUESTDESC>
                          <REPORTNAME>STOCKGROUPSUMMARY</REPORTNAME>
                          <STATICVARIABLES>
                              <SVEXPORTFORMAT>$$SysName:XML_WithAlias</SVEXPORTFORMAT>
                              <SVFROMDATE>${formattedDate}</SVFROMDATE>
                              <SVTODATE>${formattedDate}</SVTODATE>
                              <SVCompany>${companyName}</SVCompany>
                              <STOCKGROUPNAME>${stockGroupName}</STOCKGROUPNAME>
                              <STOCKCATEGORY>${stockGroupName}</STOCKCATEGORY>

                              <ISITEMWISE>YES</ISITEMWISE>
                              <EXPLODEFLAG>YES</EXPLODEFLAG>
                              <DSPALIASNAME>Yes</DSPALIASNAME>
                              <DSPALIAS>Part Number</DSPALIAS>
                              
                              <DSPZEROQTY>Yes</DSPZEROQTY>
                              <INCLUDEZEROSTOCK>Yes</INCLUDEZEROSTOCK>

                              <NativeMethod>*</NativeMethod>

                          </STATICVARIABLES>                          
                      </REQUESTDESC>
                  </EXPORTDATA>
              </BODY>
          </ENVELOPE>
//but does not get the items with zero-quantity and fails to get alias names/part number

Solution

  • First xml works best for your case as you can simply add fields list inside collection

    <ENVELOPE>
    <HEADER>
        <VERSION>1</VERSION>
        <TALLYREQUEST>Export</TALLYREQUEST>
        <TYPE>Collection</TYPE>
        <ID>maincol</ID>
    </HEADER>
    <BODY>
        <DESC>
            <STATICVARIABLES>
                <SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
                <SVFROMDATE TYPE="Date">01-04-2010</SVFROMDATE>
                <SVTODATE TYPE="Date">31-03-2011</SVTODATE>
            </STATICVARIABLES>
            <TDL>
                <TDLMESSAGE>
                    <COLLECTION ISINTERNAL="No" ISOPTION="No" ISINITIALIZE="No" ISFIXED="No" ISMODIFY="No" NAME="maincol">
                        <Type>StocKItem</Type>
                        <CHILDOF>Tes</CHILDOF>
                        <BELONGSTO>Yes</BELONGSTO>
                        <FETCH>Name,parent,OpeningRate</FETCH>
                    </COLLECTION>
                </TDLMESSAGE>
            </TDL>
        </DESC>
    </BODY>
    

    Tes - is group name(can be changed to name you want should exist in Tally)

    BelongsTo is set to yes, if you want nested items (stock items inside sub-group) else you can remove that or set to No

    *Add required methods inside fetch list not in method