XMLPort (Export, FixedVariable format) - nested loops?
            
                
                    alex9                
                
                    Member Posts: 97                
            
                        
            
                    Is it possible to create nested loops in XMLPort, which is used for exporting txt file?
My XMLPort successfully creates txt file - one row per each record in my table. But I need some extra rows in the exported txt file - headers and trailers. it's like GroupHeader and GroupFooter in classic report. Something like that:
Header1
Line1
Line2
Trailer1
Header2
Line3
Line4
Trailer2
I need to retrieve Header, Line and Trailer values from the same table, but Header row in txt file has different structure (obviuosly) than Line row. I know, how to create Header once, using Integer. But I do not know how to creater Header2 and get back to line structure again. I was goint to use nested loops, but XMLPort does not allow to set different indentation for the element = table.
Any tricks?
                My XMLPort successfully creates txt file - one row per each record in my table. But I need some extra rows in the exported txt file - headers and trailers. it's like GroupHeader and GroupFooter in classic report. Something like that:
Header1
Line1
Line2
Trailer1
Header2
Line3
Line4
Trailer2
I need to retrieve Header, Line and Trailer values from the same table, but Header row in txt file has different structure (obviuosly) than Line row. I know, how to create Header once, using Integer. But I do not know how to creater Header2 and get back to line structure again. I was goint to use nested loops, but XMLPort does not allow to set different indentation for the element = table.
Any tricks?
0                
            Comments
- 
            
 - 
            Thanks, Daniel, but your video is about import, and I am using XML for export data from NAV to text file.
How would you use XMLPort to export several purchase invoices, so in text file you would have data from the purchase header in the first row, then several rows from purchase line, then another row from the next purchase invoice header, then its lines, etc. ? Is it possible with XMLPort?0 - 
            Import, Export, it all works the same. You flatten the file to get it all out to a flat text file. Because you can't have nested dataitems when working with flat text files, you will have to program the XMLPort to take care of the data. In your case I would probably create an XMLPort based on the line table, exporting everything to variables, and programming the dataitem to fetch the header information that belongs to the current line. Be creative, try out different things, see what happens when you change it around.
Instead of thinking 1 header, multiple lines, you need to think about repeating the header values for each line, like I did in the example. The text file that I show at the start of the demo (the one with multiple lines for the second invoice) is your target file format. You could theoretically think about not repeating the header fields but only showing those once, but I actually like the repeating nature because it clearly shows all relevant attributes, which is especially useful if you have large numbers of lines per document.
If you want the nested tables idea, you'll have to use XML, text files can't be formatted that way. Unfortunately those are the limitations of XMLPorts.0 - 
            Unfortunately, I cannot change a structure of the exported file, as it has fixed format and supposed to be submitted to the 3-rd party system.
In fact, I already have all necessary data in one single table, the only problem is grouping. I have several groups and I have to create header and trail for each group and all of this should be in the one text file. I don't think there is a way to create more than one row in text file per record in the table with the XMLPort, right?
I think I need to forget about XML Port and use REPEAT ..UNTIL to loop through the table and write data to the File variable. With that, I can create as many extra rows (headers/trails) as I need based on my data.
Thanks anyways!0 - 
            It does sound like using an XMLPort is not the way for this particular one, and you'll have to program writing to the file yourself.0
 
Categories
- All Categories
 - 73 General
 - 73 Announcements
 - 66.7K Microsoft Dynamics NAV
 - 18.7K NAV Three Tier
 - 38.4K NAV/Navision Classic Client
 - 3.6K Navision Attain
 - 2.4K Navision Financials
 - 116 Navision DOS
 - 851 Navision e-Commerce
 - 1K NAV Tips & Tricks
 - 772 NAV Dutch speaking only
 - 617 NAV Courses, Exams & Certification
 - 2K Microsoft Dynamics-Other
 - 1.5K Dynamics AX
 - 323 Dynamics CRM
 - 111 Dynamics GP
 - 10 Dynamics SL
 - 1.5K Other
 - 990 SQL General
 - 383 SQL Performance
 - 34 SQL Tips & Tricks
 - 35 Design Patterns (General & Best Practices)
 - 1 Architectural Patterns
 - 10 Design Patterns
 - 5 Implementation Patterns
 - 53 3rd Party Products, Services & Events
 - 1.6K General
 - 1.1K General Chat
 - 1.6K Website
 - 83 Testing
 - 1.2K Download section
 - 23 How Tos section
 - 252 Feedback
 - 12 NAV TechDays 2013 Sessions
 - 13 NAV TechDays 2012 Sessions
 
