Options

XMLPort with Child tables

RoelofRoelof Member Posts: 377
I want to export Sales Order data with 2 levels as of the Sales Header and Sales Lines. Is there a way to do that? The xml port is defined as format = Fixed Data (no XML format).

I was trying to define the fields as:

Root Element Text <Root>
SalesHeader Element Table <SalesHeader>(Sales Header)
HeaderField1 Element Text <HeaderField1>
HeaderField2 Element Text <HeaderField2>
HeaderField3 Element Text <HeaderField3>
..etc..
SalesLine Element Table <SalesLine>(Sales Line)
LineField1 Element Text <LineField1>
LineField2 Element Text <LineField2>
LineField3 Element Text <LineField3>

But this format doesn't seem to work since I'm getting this error:
'An element with source type Table cannot have Table element children.'





Roelof de Jonghttp://www.wye.com

Comments

  • Options
    andrewtandrewt Member Posts: 73
    Hi Roelof,
    your assumption is correct. NAV does not allow parent/child indentation of table elements for Fixed Text or CSV format. You would have to use the Xml format instead or use a plain data structure with independent table elements for SalesHeader and SalesLine.

    Hope this helps
    Andrew T.
  • Options
    RoelofRoelof Member Posts: 377
    Thanks Andrew. Not the answer what I would like to hear but this is what I thought. I know there is a way to do it in a classic Dataport by using CurrFile but these options no longer exist in the latest NAV versions. That sucks. I guess an alternative would be to buffer data in the right order before it exports.
    Roelof de Jonghttp://www.wye.com
  • Options
    DenSterDenSter Member Posts: 8,304
    edited 2016-01-07
    That used to be possible
    https://youtu.be/qNYrmZXUOxE

    That was in 2009 though I think, not sure if it wouldn't work anymore. See if you can make this work.
  • Options
    DenSterDenSter Member Posts: 8,304
    Today I would probably think about creating a Query based on two tables, load it into a temp table during OnPre, something like that.
  • Options
    RoelofRoelof Member Posts: 377
    Hi Daniel,
    I actually figured out a way doing that. I created an integer and running through all the data (parent and child), buffer it and then using an Integer that has one datasource field. I added some code in the DataItem to control the export. I string the Parent data when Parent Data needs to be exported and string the Child data when Child Data needs to be exported. The record length is for both Parent and Child the same but the layout is defined in code. It works pretty well although a bit slower than a straight export would be.
    Roelof de Jonghttp://www.wye.com
Sign In or Register to comment.