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

 
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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

 
JoeBrown

DevOps starts with culture!

Comments for DevOps ABCs Blog

Reflections from the ERP field

DevOps ABCs Blog

Reflections from the ERP field

Dynamics 365 Business Central for Partners

Reflections from the ERP field

Freddys blog

Learn something new... - then Teach someone!

Stefano Demiliani Technical Blog

Reflections from the ERP field

David Worthington's NAV Performance Blog

Micosoft Dynamics NAV Performance Testing & Optimization

Freddys Blog

Reflections from the ERP field

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

Reflections from the ERP field

Nav Can Be Fun

Its Really Fun to Work with Microsoft Dynamics Nav / D365 Business Central

Navision-Girl.Com

Reflections from the ERP field

Kine's Info

Reflections from the ERP field

blog.wibeck.org/

Just another WordPress.com site

%d bloggers like this: