XMLPort: Import Into Temporary Table

08 Aug

Earlier today I wrote a blog post XMLPort: Export from temporary tables. The principle is the same when you want to import to a temporary table. Instead of calling a function in XMLPort before you call the export that inserts values into the temporary table you do the opposite, call a function after the import has completed that copies all the temporary data to your temporary record parameter.  Create the XMLPort in the same way and don’t forget to mark the table as temporary.

Temporary Property on XMLPort

Create a function in the XMLPort that fetches the imported data and copies it to the parameter.

    PROCEDURE GetTemporaryRecord@1000000002(VAR TemporaryItem@1000000000 : Record 27);
      //Copy all the temporary records to the new temporary variable
        TemporaryItem := Item;
      UNTIL Item.NEXT = 0;

Here is the test function that I use to call the XMLPort.

PROCEDURE ImportXMLToTempRecords@1000000013();
      TemporaryItemXMLPort@1000000003 : XMLport 69782;
      TempItem@1000000004 : TEMPORARY Record 27;
      TestFile@1000000002 : File;
      Instream@1000000001 : InStream;
      FileName@1000000000 : Text[100];
      //Builds data in temporary records and uses a XMLport with the temporary property to export the
      //temporary records as XML

      FileName := 'C:\temp\TESTXML.txt';

      IF TempItem.FINDSET THEN
        MESSAGE('Found the imported records, count=%1',TempItem.count)
        ERROR('Couldn't find the imported records');

Here is the XML that I’m importing (export from my previous blog post)

<?xml version="1.0" encoding="UTF-16" standalone="no"?>
1 Comment

Posted by on 2015-08-08 in Okategoriserade


Tags: , , ,

One response to “XMLPort: Import Into Temporary Table

  1. Brian Blackstone

    2015-09-08 at 06:26

    YES! This is exactly what I’ve been looking for! I missed it because of the simplicity! I couldn’t figure out how to get the temporary table data back from the XMLPort import, without writing it to a real table first. Creating a GetTemporaryData function fixes that. Thank you so much!



Leave a Reply

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

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

Facebook photo

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

Connecting to %s

The BC Docs Librarian

Tips and news for AL programmers

Stefan Maroń

Dynamics 365 Business Central

James Pearson

Thoughts about Dynamics 365 Business Central, Git, Azure DevOps, PowerShell, Automated Testing, Visual Studio Code...and maybe some other stuff

Roberto Stefanetti BLOG

MVP & MCT Microsoft Dynamics 365 Business Central, Powershell, Azure, SQL Server


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

Marije Brummel Blog | Business Central, Azure and more...

Design Patterns, Performance, Clean Code

Ideas in the cloud

Goprowe AB

Reflections from the ERP field


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

%d bloggers like this: