How to get list of ledgers from tally using XML request filtered by name that contains a specified sub-text?

huangapple go评论105阅读模式
英文:

How to get list of ledgers from tally using XML request filtered by name that contains a specified sub-text?

问题

我有以下的XML请求,它返回Tally中所有账户的列表。

<ENVELOPE>
    <HEADER>
        <VERSION>1</VERSION>
        <TALLYREQUEST>Export</TALLYREQUEST>
        <TYPE>Collection</TYPE>
        <ID>Ledgers</ID>
    </HEADER>
    <BODY>
        <DESC>
            <STATICVARIABLES>
                <SVEXPORTFORMAT>SysName:XML</SVEXPORTFORMAT>
            </STATICVARIABLES>
            <TDL>
                <TDLMESSAGE>
                    <COLLECTION ISMODIFY="No" ISFIXED="No" ISINITIALIZE="No" ISOPTION="No" ISINTERNAL="No" NAME="Ledgers">
                        <TYPE>Ledger</TYPE>                             
                        <BELONGSTO>Yes</BELONGSTO>
                        <NATIVEMETHOD>Name</NATIVEMETHOD>
                    </COLLECTION>
                </TDLMESSAGE>
            </TDL>
        </DESC>
    </BODY>             
</ENVELOPE>

现在在上面的代码中,我添加了以下筛选条件:

<TDLMESSAGE>
     <COLLECTION ISMODIFY="No" ISFIXED="No" ISINITIALIZE="No" ISOPTION="No" ISINTERNAL="No" NAME="Ledgers">
            <TYPE>Ledger</TYPE>                             
            <BELONGSTO>Yes</BELONGSTO>
            <NATIVEMETHOD>Name</NATIVEMETHOD>
			<FILTERS>Site</FILTERS>
      </COLLECTION>
	<SYSTEM TYPE="Formulae" NAME="Site">$Name = 'Site'</SYSTEM>
</TDLMESSAGE>

所以,它的作用是检查是否有一个名为'Site'的账户。这个筛选条件完美地工作,只会给我返回一个名为'Site'的账户。但是,我需要的是一个包含词语'Site'的所有账户的列表,不论它们的名称中的位置如何。因此,我尝试使用LIKE操作符代替**=**。

<SYSTEM TYPE="Formulae" NAME="Site">$Name LIKE 'Site'</SYSTEM>
英文:

I have the following XML request that returns the list of all ledgers from Tally.

<ENVELOPE>
            <HEADER>
                <VERSION>1</VERSION>
                <TALLYREQUEST>Export</TALLYREQUEST>
                <TYPE>Collection</TYPE>
                <ID>Ledgers</ID>
            </HEADER>
            <BODY>
                <DESC>
                    <STATICVARIABLES>
                        <SVEXPORTFORMAT>SysName:XML</SVEXPORTFORMAT>
                    </STATICVARIABLES>
                    <TDL>
                        <TDLMESSAGE>
                            <COLLECTION ISMODIFY="No" ISFIXED="No" ISINITIALIZE="No" ISOPTION="No" ISINTERNAL="No" NAME="Ledgers">
                                <TYPE>Ledger</TYPE>                             
                                <BELONGSTO>Yes</BELONGSTO>
                                <NATIVEMETHOD>Name</NATIVEMETHOD>
                            </COLLECTION>
                        </TDLMESSAGE>
                    </TDL>
                </DESC>
            </BODY>             
        </ENVELOPE>

Now in the above code, I added a filter as follows:

<TDLMESSAGE>
     <COLLECTION ISMODIFY="No" ISFIXED="No" ISINITIALIZE="No" ISOPTION="No" ISINTERNAL="No" NAME="Ledgers">
            <TYPE>Ledger</TYPE>                             
            <BELONGSTO>Yes</BELONGSTO>
            <NATIVEMETHOD>Name</NATIVEMETHOD>
			<FILTERS>Site</FILTERS>
      </COLLECTION>
	<SYSTEM TYPE="Formulae" NAME="Site">$Name = 'Site'</SYSTEM>
</TDLMESSAGE>

So, what it does is it checks if there is a ledger called 'Site'
This filter works perfectly. It only gives me one ledger whose name is 'Site'. But, what I need is a list of all the ledgers that contain the word 'Site' anywhere in their name.
Thus, I tried to use LIKE operator instead of =.

<SYSTEM TYPE="Formulae" NAME="Site">$Name LIKE 'Site'</SYSTEM>

答案1

得分: 1

"Like" 用于模式匹配,需要使用 "expression"。

如果您想使用字符串搜索,请使用 "Contains"。

<SYSTEM TYPE="Formulae" NAME="Site">$Name Contains 'Site'</SYSTEM>

How to get list of ledgers from tally using XML request filtered by name that contains a specified sub-text?

英文:

Like is for pattern matching and it requires expression.

if you want to search with string use Contains

&lt;SYSTEM TYPE=&quot;Formulae&quot; NAME=&quot;Site&quot;&gt;$Name Contains &#39;Site&#39;&lt;/SYSTEM&gt;

How to get list of ledgers from tally using XML request filtered by name that contains a specified sub-text?

答案2

得分: 0



1
Export
Collection
Ledgers




SysName:XML




Ledger
Yes
Name
Site

$Name LIKE '%Site%'




英文:
&lt;ENVELOPE&gt;
	&lt;HEADER&gt;
		&lt;VERSION&gt;1&lt;/VERSION&gt;
		&lt;TALLYREQUEST&gt;Export&lt;/TALLYREQUEST&gt;
		&lt;TYPE&gt;Collection&lt;/TYPE&gt;
		&lt;ID&gt;Ledgers&lt;/ID&gt;
	&lt;/HEADER&gt;
	&lt;BODY&gt;
		&lt;DESC&gt;
			&lt;STATICVARIABLES&gt;
				&lt;SVEXPORTFORMAT&gt;SysName:XML&lt;/SVEXPORTFORMAT&gt;
			&lt;/STATICVARIABLES&gt;
			&lt;TDL&gt;
				&lt;TDLMESSAGE&gt;
					&lt;COLLECTION ISMODIFY=&quot;No&quot; ISFIXED=&quot;No&quot; ISINITIALIZE=&quot;No&quot; ISOPTION=&quot;No&quot; ISINTERNAL=&quot;No&quot; NAME=&quot;Ledgers&quot;&gt;
						&lt;TYPE&gt;Ledger&lt;/TYPE&gt;    						
						&lt;BELONGSTO&gt;Yes&lt;/BELONGSTO&gt;
						&lt;NATIVEMETHOD&gt;Name&lt;/NATIVEMETHOD&gt;
						&lt;FILTERS&gt;Site&lt;/FILTERS&gt;
					&lt;/COLLECTION&gt;
					&lt;SYSTEM TYPE=&quot;Formulae&quot; NAME=&quot;Site&quot;&gt;$Name LIKE &#39;%Site%&#39;&lt;/SYSTEM&gt;
				&lt;/TDLMESSAGE&gt;
			&lt;/TDL&gt;
		&lt;/DESC&gt;
	&lt;/BODY&gt;             
&lt;/ENVELOPE&gt;

This did the trick.

huangapple
  • 本文由 发表于 2023年7月14日 01:08:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76681803.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定