How to Run XMLPort

Hi,

I am new user in the Dynamics Navision , I face the problem that how to Run the XMLPort

---------------BajiRao

Hi BaijiRao.

The example from the Developer and IT Pro help(NAV 2009). Hope it will be usefull. I advise you study the document from the microsoft first. You will be familiar with the basic concepts after studying it. Good luck.

Gary.

This topic contains an example showing how you can use an XMLport to import data from an XML document into the Microsoft Dynamics NAV database.

Example

In this example, you design an XMLport to import data from an XML sales order document, XML Sales Order.xml, to the Microsoft Dynamics NAV database. The following code example shows the sales order.

<?xml version="1.0" ?>
<HeaderLines>
  <SalesOrder>
    <Header Date="17-02-04" Type="Quote">
      <SellTo CountryRegion="GB">
       <Name>The Cannon Group PLC</Name>
       <Address>192 Market Square</Address>
       <City>Birmingham</City>
       <Zip>B27 4KT</Zip>
     </SellTo>
     <BillTo CountryRegion="GB">
       <Name>The Cannon Group PLC</Name>
       <Address>192 Market Square</Address>
       <City>Birmingham</City>
       <Zip>B27 4KT</Zip>
     </BillTo>
     <Lines>
       <Item PartNum="LS-150">
         <ProductName>Loudspeaker, Cherry, 150W</ProductName>
         <Quantity>8</Quantity>
         <UnitPrice>129,00</UnitPrice>
         <ShipmentDate />
         <Comment>Confirm the voltage is 75W</Comment>
       </Item>
          <Item PartNum="LS-MAN-10">
          <ProductName>Manual for Loudspeakers</ProductName>
          <Quantity>20</Quantity>
          <UnitPrice />
          <ShipmentDate />
          <Comment />
       </Item>
          <Item PartNum="LS-2">
            <ProductName>Cables for Loudspeakers</ProductName>
            <Quantity>10</Quantity>
            <UnitPrice>21,00</UnitPrice>
            <ShipmentDate />
            <Comment />
            </Item>
     </Lines>
     <Contact>Mr. Andy Toal</Contact>
     <Terms>14 days</Terms>
    </Header>
  </SalesOrder>
</HeaderLines>

After analyzing the XML document, you can see that the data belongs in two database tables: XML Header - Import and XML Items - Import. You need to design an XMLport that can insert the data into these tables.

The design of the XMLport shows that the data in the XML document has been mapped to database tables which have a header-line relation. The XMLport must insert the header information before inserting the line information. You need to set the LinkedTableForcedInsert property to Yes for the <Item> node to ensure that this happens. The LinkTable and LinkFields properties for this node also need to be set to indicate the relationship between the XML Header - Import and XML Items - Import tables. It is important to specify this binding information to ensure that the XMLport enters the data into the correct tables. Note that you have given the XML Items - Import table the variable name L and that the XML Header - Import table has the variable name H. The following table shows the properties for the <Item> node.

Property Value


Indentation



4



NodeName



Item



NodeType



Element



SourceType



Table



SourceTable



XML Items - Import



VariableName



L



SourceTableView







CalcFields







LinkTable



H



LinkTableForceInsert







LinkFields



Doc No=FIELD(Order No)



Temporary







Width



<0>



MinOccurs







MaxOccurs





After all the records have been inserted into the XML Items - Import table, the Contact Person and Payment Terms fields in the XML Header - Import table have to be updated. You can do this by adding the following C/AL code line on the Contact - Import::OnAfterAssignField() trigger and on the Terms - Import::OnAfterAssignField() trigger:

H.MODIFY;

You are not saying if you want to import or export → but If you are doing an export simply create a codeunit to call your xmlport → use something along these lines:

_File.CREATE(‘c:\new.xml’);
_File.CREATEOUTSTREAM(_DatafileOutstream);
XMLPORT.EXPORT(50010, _DatafileOutstream);
_File.CLOSE;

Hi Tvis ,

Thanks for replay to my Question…

Hi Gary,

Thanks for replay to my Question…

I got the proper solution that how to Run the XMLPort

Yes , I got the proper solution that how to run the XML Port