How to create and import xml file in navision

abhishekpareekabhishekpareek Member Posts: 150
Hi All,

My problem is follows:

1: I need to create the XML file for Purchase Order in Navision and than to import from Navision to some location say C drive.
2: Purchase order should include Purchase Header and Purchase Line.

Queries:
a) Can I use XML port to achive this?If yes then is there any reference about how to use XML port?
b) If point a is acievable then how to run the XML port in Navision.

Is there any other solution inspite of XML port?

Thanks in advance!

Regards,
Abhishek

Comments

  • DenSterDenSter Member Posts: 8,304
    Yes you can use XMLPort to create an XML document out of a PO. Take a look at the standard XMLPorts, there's one for PO's for Commerce Gateway, number 8000 in a standard US database.

    XMLPorts are used inside C/CAL code, you can't run them directly from the object designer. For some examples take a look at the commerce gateway XML codeunits.

    You can also write code to open and process XML documents, using the XMLDOM automation server. For samples take a look at the same codeunits in older versions that didn't yet have XMLPorts.
  • abhishekpareekabhishekpareek Member Posts: 150
    It would be great if you could explain with example.Like if are using the existing XMPORT say 8000 then how we can export the data throw this XML port?
    Thanks for help in advance!

    Regards,
    Abhishek
  • DenSterDenSter Member Posts: 8,304
    I gave you directions to hundreds of code samples. Here, let me repeat myself:
    DenSter wrote:
    Take a look at the standard XMLPorts, there's one for PO's for Commerce Gateway, number 8000 in a standard US database.

    For some examples take a look at the commerce gateway XML codeunits.

    For samples take a look at the same codeunits in older versions that didn't yet have XMLPorts.
    Do a little research, take the initiative to actually go into your database and see what I mean. Open the object designer, take a look at the commerce gateway objects. The codeunits that use XMLPorts that I'm talking about have "XML" in their title, down near the end of the list.
  • dagodago Member Posts: 22
    I have finished export sales invoice into xml file and now I need to import it as a purchase order. Any idea how to do it :?:

    Thanks
  • abhishekpareekabhishekpareek Member Posts: 150
    Create a XMLPORT for Purchase Header and Purchase Line.Then call this XMLPORT for the sales invoice xml file.

    Regards,
    Abhishek
  • dagodago Member Posts: 22
    thanks Abhishek

    well I have already created XMLport for purchase header and line but dont know how to call this xml port for the sales invoice xml file
  • SavatageSavatage Member Posts: 7,142
    I would start here....

    Application Designers Guide
    PART 8 XMLPorts
    Chapter 21 XMLPorts
      XMLport Fundamentals Designing XMLports XMLport Examples Validating Data XMLports and Business Notification

    Also, available in the download section
    Xml Export 1.3i
    viewtopic.php?f=7&t=1775

    XML Import Sample v1.0i
    viewtopic.php?f=7&t=2266
  • dagodago Member Posts: 22
    how to create temporary tables to receive header and lines of sales invoice?
  • abhishekpareekabhishekpareek Member Posts: 150
    A) Please create an new xmlport for sales invoice header and sales invoice line.
    B) Call xml file which you had created.

    Steps to create the xml port:

    1:First create the file object
    2:Create the instream object
    3:Call the open function with the path and file name of the xml file which you had created.
    4:Call the Import function for xmlport object with the parameter as follows
    a)XMLPORT ID
    b)Instream variable

    Example:

    Filexml.OPEN(filepath\filename);
    Filexml.CREATEINSTREAM(instreamobject);
    XMLPORT.IMPORT(50001,instream); //for running th xml port without setting the filter for the record

    Regards,
    Abhishek Pareek
  • abhishekpareekabhishekpareek Member Posts: 150
    temporary table are created in the following way:

    1) Declare the record variable in Globals
    2) Go to property for that variable and make temporary =yes

    Regards,
    Abhishek Pareek
  • dagodago Member Posts: 22
    Thanks a lot and let me try it..
  • dagodago Member Posts: 22
    Whats wrong with this code ?

    ImportFile.OPEN('C:\Temp\Import.xml');
    ImportFile.CREATEINSTREAM(INSTREAM);
    XMLPORT.IMPORT;
    ImportFile.CLOSE;

    can i add these two lines


    rec_PurchHeader.SETRANGE("No.", "No.");
    XMLPORT.SETTABLEVIEW(rec_PurchHeader);

    what about the INSERT or TRANSERFIELDS functions ? how and where i can use them ? :-k
    I am desperate student ](*,) does anybody have an idea how to continue with this code to finish import from xml file?

    I can attach my xml port for import if it helps

    Thanks to anybody who can help
  • abhishekpareekabhishekpareek Member Posts: 150
    The error is in the following code:
    XMLPORT.IMPORT;

    Correted one:

    XMLPORT.IMPORT(XMLPORTNUMBER,INSTREAM);

    XMLPOARTNAUMBER ->The object ID of the XMLPORT which needs to be run for importing the XML records.

    Regards,
    Abhishek Pareek
  • dagodago Member Posts: 22
    the ID of my xml port is 1

    but i need to add some more lines i think since tha data must be imported somewhere.. e.g. temporary tables or some variables of a type RECORD..

    i am really desperate



    ImportFile.OPEN('C:\Temp\Import.xml');
    ImportFile.CREATEINSTREAM(INSTREAM);
    XMLPORT.IMPORT(1,INSTREAM);
    ImportFile.CLOSE;

    do you think this will work ??
Sign In or Register to comment.