How to use dataport to export multiple header and detail records?


I am pretty new with NAV (less than a month self-learning) and I would appreciate it if somebody can explain to me how to export Purchase Header and Purchase Line in the following format:

Purchase Header Record 1

Purchase Line Record 1

Purchase Line Record 2

Purchase Header Record 2

Purchase Line Record 1

Purchase Line Record 2

Thank you very much in advance! [:)]

Not easily. You have to either fill a buffer table or manually export it using streams. Does it absolutely have to be in that format?

Hi Matt,

Thanks for responding. Unfortunately yes, I have to format it this way for an external system that would read the text file. I forgot to mention that either dataport or xmlport can be used for this but the output has to be in variable text. Which one is easier? Can you please explain how it can be done? Thank you very much.

Try getting the file format to be flattened out:

Header1 fields - Line1 fields
Header1 fields - Line2 fields
Header2 fields - Line1 fields
Header2 fields - Line2 fields

Read the fields into variables and take care of records in C/AL code.

Much easier to develop in code.

XML surely is the way to go.