<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>Printing/sending invoices with correct line sequence</title>
        <description> I generate invoice as PDFs or files of various types, eg XML, CSV. I had trouble retaining the original line sequence as per the source transaction.

Typically I scan a data source of invoice headers, and within the scan I filter another data source for all the invoice lines for that invoice, then scan those lines to generate the output:

FOR EACH &amp;lt;invoice header data source&amp;gt;
 - Using HFilter, filter the invoice lines data source for that invoice (ordered by invoice and linenumber)
 -  FOR EACH &amp;lt;invoice lines data source&amp;gt;
 -   -  Print the invoice report or create the output file

I tried 3 different ways to filter the invoice lines data:

1. FOR...EACH &amp;lt;invoice lines data source&amp;gt; - did not return the correct set of data, even though a display of the data source in the debugger showed the correct set of lines.

2. WHILE HOut(&amp;lt;invoice lines data source&amp;gt;) - correct invoice set but the lines were in random order

3. FOR EACH &amp;lt;invoice lines data source&amp;gt; where &amp;quot;saleid = &amp;#039;&amp;quot; + &amp;lt;invoice number data source&amp;gt;.saleid + &amp;quot;&amp;#039;&amp;quot; ON LineNumber

#3 worked correctly. The &amp;quot;where clause&amp;quot; created the correct subset of data, and &amp;quot;ON linenumber&amp;quot; retained the correct line sequence.

See [doc.windev.com].

This may be well known but not to me. Shared for anyone who can benefit!</description>
        <link>https://www.wxforum.info/read.php?27161,799185,799185#msg-799185</link>
        <lastBuildDate>Tue, 19 May 2026 02:31:52 +0200</lastBuildDate>
        <generator>Phorum 5.2.23</generator>
        <item>
            <guid>https://www.wxforum.info/read.php?27161,799185,799250#msg-799250</guid>
            <title>Re: Printing/sending invoices with correct line sequence</title>
            <link>https://www.wxforum.info/read.php?27161,799185,799250#msg-799250</link>
            <description><![CDATA[ Thanks for your comments Al, much appreciated. Totally agree with all of it, especially your first sentence!]]></description>
            <dc:creator>Mike James</dc:creator>
            <category>WinDev Solutions</category>
            <pubDate>Sat, 02 May 2026 00:23:41 +0200</pubDate>
        </item>
        <item>
            <guid>https://www.wxforum.info/read.php?27161,799185,799244#msg-799244</guid>
            <title>Re: Printing/sending invoices with correct line sequence</title>
            <link>https://www.wxforum.info/read.php?27161,799185,799244#msg-799244</link>
            <description><![CDATA[ Hello Mike,<br />
<br />
Over the years I have found Windev functions that work perfectly and those that don&#039;t as I am sure you have.<br />
One function that randomly causes issues for me is the For Each construct, especially if you do some process inside the loop so now I never use it.<br />
<br />
For an invoice, I load all the line records into a memory table with an incrementing numeric counter field, then sort the table on the counter field and use it to supply the body section of the invoice report.<br />
<br />
Regards<br />
Al]]></description>
            <dc:creator>Al</dc:creator>
            <category>WinDev Solutions</category>
            <pubDate>Thu, 30 Apr 2026 02:32:27 +0200</pubDate>
        </item>
        <item>
            <guid>https://www.wxforum.info/read.php?27161,799185,799243#msg-799243</guid>
            <title>Re: Printing/sending invoices with correct line sequence</title>
            <link>https://www.wxforum.info/read.php?27161,799185,799243#msg-799243</link>
            <description><![CDATA[ Option 3 worked in development but not in production. Error: &lt;fieldname&gt; unknown. A small change fixed it:<br />
<br />
&quot;ON LineNumber&quot; (a field name from the table/data source) replaced by &quot;ON sFieldName&quot; (a string containing the fieldname).<br />
<br />
It&#039;s not the first time we&#039;ve had to make a similar change.]]></description>
            <dc:creator>Mike James</dc:creator>
            <category>WinDev Solutions</category>
            <pubDate>Thu, 30 Apr 2026 02:19:29 +0200</pubDate>
        </item>
        <item>
            <guid>https://www.wxforum.info/read.php?27161,799185,799185#msg-799185</guid>
            <title>Printing/sending invoices with correct line sequence</title>
            <link>https://www.wxforum.info/read.php?27161,799185,799185#msg-799185</link>
            <description><![CDATA[ I generate invoice as PDFs or files of various types, eg XML, CSV. I had trouble retaining the original line sequence as per the source transaction.<br />
<br />
Typically I scan a data source of invoice headers, and within the scan I filter another data source for all the invoice lines for that invoice, then scan those lines to generate the output:<br />
<br />
FOR EACH &lt;invoice header data source&gt;<br />
 - Using HFilter, filter the invoice lines data source for that invoice (ordered by invoice and linenumber)<br />
 -  FOR EACH &lt;invoice lines data source&gt;<br />
 -   -  Print the invoice report or create the output file<br />
<br />
I tried 3 different ways to filter the invoice lines data:<br />
<br />
1. FOR...EACH &lt;invoice lines data source&gt; - did not return the correct set of data, even though a display of the data source in the debugger showed the correct set of lines.<br />
<br />
2. WHILE HOut(&lt;invoice lines data source&gt;) - correct invoice set but the lines were in random order<br />
<br />
3. FOR EACH &lt;invoice lines data source&gt; where &quot;saleid = &#039;&quot; + &lt;invoice number data source&gt;.saleid + &quot;&#039;&quot; ON LineNumber<br />
<br />
#3 worked correctly. The &quot;where clause&quot; created the correct subset of data, and &quot;ON linenumber&quot; retained the correct line sequence.<br />
<br />
See [<a href="https://doc.windev.com/en-US/?1510013"  rel="nofollow">doc.windev.com</a>].<br />
<br />
This may be well known but not to me. Shared for anyone who can benefit!]]></description>
            <dc:creator>Mike James</dc:creator>
            <category>WinDev Solutions</category>
            <pubDate>Thu, 19 Mar 2026 23:52:08 +0100</pubDate>
        </item>
    </channel>
</rss>
