RSS

XMLPort: Export from temporary tables

08 Aug

You can export data from tables to XML by using XMLPorts. But you can also use XMLPorts to export data from temporary tables.
The principle is to set the Temporary property on the table line and then create a function in XMLPort that inserts all the data into the temporary record.

I will start with creating a XMLPort to the Item table. I have only chosen two fields, “No.” and Description.

XMLPort

In order for the XMLPort to be temporary we have to set the following setting

Temporary Property on XMLPort

Lets create the function that inserts the data into the temporary table. Note that the record that I inserts to is the same record name on the XMLPort line.
Function that inserts the data into the temporary record

Once this is done I’ll create a test function that builds our temporary data, sends the data to the temporary XMLPort and then the export function on it.


    PROCEDURE ExportTempRecordsToXMLFile@1000000002();
    VAR
      TemporaryItemXMLPort@1000000003 : XMLport 69790;
      TempItem@1000000004 : TEMPORARY Record 27;
      TestFile@1000000002 : File;
      Outstream@1000000001 : OutStream;
      FileName@1000000000 : Text[100];
    BEGIN
      //Builds data in temporary records and uses a XMLport with the
      //temporary property to export the temporary records as XML

      //Build the temporary records
      //TempItem is declared as temporary
      TempItem.INIT;
      TempItem."No." := '1';
      TempItem.Description := 'Test1';
      TempItem.INSERT;

      TempItem.INIT;
      TempItem."No." := '2';
      TempItem.Description := 'Test2';
      TempItem.INSERT;

      //Create a stream to the destination file
      FileName := 'C:\temp\TESTXML.txt';
      TestFile.CREATE(FileName);
      TestFile.CREATEOUTSTREAM(Outstream);
      //XMLPort part
      TemporaryItemXMLPort.InsertTemporaryRecords(TempItem);
      TemporaryItemXMLPort.SETDESTINATION(Outstream);
      TemporaryItemXMLPort.EXPORT;

      TestFile.CLOSE;
      HYPERLINK(FileName); //To open the file when it is done
    END;

Once done the result is this

XMLPort export esult

Advertisements
 
1 Comment

Posted by on 2015-08-08 in Okategoriserade

 

Tags: , ,

One response to “XMLPort: Export from temporary tables

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Mark Brummel Blog | Microsoft Dynamics NAV

Master Classes Design Patterns and more...

Vjeko.com

ideas in the cloud

Goprowe AB

Reflections from the ERP field

ArcherPoint Developer Blog

Reflections from the ERP field

The NAV Viking´s Blog

- Sharing my experience in the Dynamics NAV world

Comments for waldo's blog

Reflections from the ERP field

Nav Can Be Fun

Its Really Fun to Work with Microsoft Dynamics Nav

Navision-Girl.Com

Reflections from the ERP field

LET'S TALK NAV

Tips, Tricks, How-To's & News about Microsoft Dynamics NAV & Dynamics 365 for Financials

Kine's Info

Reflections from the ERP field

blog.wibeck.org/

Just another WordPress.com site

NAV/SQL Performance - My Two Cents

Reflections from the ERP field

Hougaard.com – Applied Hacking

Reflections from the ERP field

Kauffmann @ Dynamics NAV

Reflections from the ERP field

Kriki’s Dynamics NAV blog

Reflections from the ERP field

Rashed Amini

Reflections from the ERP field

Olof Simren - Microsoft Dynamics NAV Blog

My blog about Microsoft Dynamic NAV tips and tricks. Remember to Subscribe!

Van Vugt's dynamiXs

Reflections from the ERP field

Navisionary – Dynamics NAV

Reflections from the ERP field

%d bloggers like this: