Options

PO Export issue using xml port

kamranshehzadkamranshehzad Member Posts: 165
Hi
I am facing a strange thing.
I have created a XML port to export the data into a file.

I am filtering out PurchaseHeader.Document Type = order using set range
and same with Purchase Lines but when it exports the data, it includes all lines of Purchase Lines table (39) and Range works fine for PurchaseHeader (38) table.

Any idea. Code follows.
IF EXISTS('C:\XML_PO_OUT.XML') THEN
    ERASE('C:\XML_PO_OUT.XML');

    PurchaseHeader.SETRANGE(PurchaseHeader."Document Type",PurchaseHeader."Document Type"::Order);
    PurchaseLine.SETRANGE(PurchaseLine."Document Type",PurchaseLine."Document Type"::Order);
    PurchaseHeader.SETFILTER(PurchaseHeader."No.",'104001');
    PurchaseLine.SetFilter(PurchaseLine."Document No.", '104001');

    TESTFILE.CREATE('C:\XML_PO_OUT.XML');
    TESTFILE.CREATEOUTSTREAM(TestStream);

    XP_PO.SETTABLEVIEW(PurchaseHeader);
    XP_PO.SETDESTINATION(TestStream);
     XP_PO.Export;

   // XMLPORT.EXPORT(123456753,TestStream);
    TESTFILE.CLOSE;
MESSAGE('PO Exported Successfully.');

Please suggest anything.

regards,
KS

Answers

  • DenSterDenSter Member Posts: 8,307
    You need to set the link between the header and line tables in your XMLPort. Somewhere in there you have a table element for the header table, and somewhere else a table element for the line table. On the line table element go to the properties of the dataitem, and set the LinkFields property correctly.
  • kamranshehzadkamranshehzad Member Posts: 165
    Great. I had a thought about it but then thought setting filter / range should sort it out.

    Thanks its working.
    KS
  • DenSterDenSter Member Posts: 8,307
    You're welcome, always glad to help :mrgreen:
Sign In or Register to comment.