Sort a field in 2 dataitems

I have 2 dataitems at the same level of indentation. Let us name them DataItem A and DataItem B. Both of them has a field F. I wish to have a list of data from DataItem A and then DataItem B. Each dataitem will show field F in body section. Question is how can I sort field F ? Does anyone know ? Thx in advance.

Hey S.K. i had a similar problem in the past. The only way navision is sorting is to have the sorting field in a key and to select this key. Navision automatically uses the records as they are sorted by the selected key. In your case you need to sort both dataitems the same way to have the same sequence. Stefan Weinreich Billing Analyst

Yes,Stefan. You’re right. However, I have DataItem A with Field F numbered 1,2,9 and DataItem B with Field F numbered 5,6,7,10. As you can see, they shall be displayed in order 1,2,9,5,6,7,10 as a report. I would love to have Field F in ascending order but that remains in puzzle. Here, DataItem A is a different table from DataItem B. Edited by - skchong on 2002 Mar 18 09:04:18

I understood your topic as DataItem A and B were the same table. Sorry. But what about the possibility to use temporary tables ? Although i’m not very familar with them wouldn’t it be possible to read out DataItem A and B and to write the contents of Field F into a field of the temporary table and then print it out ? So you would have the chance to sort field F as you like. But i’m not sure whether it is possible to use temporary tables in sections. Another possibility was to write the data into an ascii-file and to use excel as printer. If you import the data into excel via a excel-macro you can sort the data as youwant to. But this would be only a workaround and not very elegant for mass data. Stefan Weinreich Billing Analyst

Temporary Tables are the way to go here. The only other trick might be if the Key field in both tables is an integer, then you can use the Integer table as a dataitem then A and B under that joined to the Number field. For a temporary table, it’s a little more work as you have to load the table, read through the table, then find the corresponding records from A and/or B. Chris.

Chris is right, even if the F field isn’t an integer, that can be a good way, but in any case forget about typical navision indentation. It’s a code stuff. While cycling on integer table (see some examples in reports about the invoice or sales order print) you must indent Dataitem A (with no DAtaitemlink) sorting by F field and in the aftergetrecord event you must verifify that a the value in Table B (NOT dataitem and sorted by F field) is in the range between the current and the next record in table A. All the field values (F field included) you need must be saved in global variables and assigned to text box controls in the printing section of the report. This could work…i believe. Let me know… :slight_smile:

Thanks for all the inputs. But couldn’t manage to solve it yet. Give me a little more time and I hope to be back with a solution soon. Thx.