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 <invoice header data source>
- Using HFilter, filter the invoice lines data source for that invoice (ordered by invoice and linenumber)
- FOR EACH <invoice lines data source>
- - Print the invoice report or create the output file
I tried 3 different ways to filter the invoice lines data:
1. FOR...EACH <invoice lines data source> - 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(<invoice lines data source>) - correct invoice set but the lines were in random order
3. FOR EACH <invoice lines data source> where "saleid = '" + <invoice number data source>.saleid + "'" ON LineNumber
#3 worked correctly. The "where clause" created the correct subset of data, and "ON linenumber" retained the correct line sequence.
See [
doc.windev.com].
This may be well known but not to me. Shared for anyone who can benefit!