Automation Variable Issue

chrisdavis_23chrisdavis_23 Posts: 2Member
edited 2004-07-08 in Navision Attain
We are working on a project that is taking data out of Navision and dumping it into a xml format. The issue that we have is that we have an "Autmation variable has not been instantiated" and no matter what I change in the CAL Locals to point it to the MSXML it will not get past.

Any suggestions?

Comments

  • fbfb Posts: 246Member
    Why not follow the pattern in the XML Codeunits -- they work roughly as follows:

    Declare XMLDOMDocument as 'Microsoft XML, v3.0'.DOMDocument
    Declare CurrNode as 'Microsoft XML, v3.0'.IXMLDOMElement
    Declare NewChild as 'Microsoft XML, v3.0'.IXMLDOMElement
    PROCEDURE ExportPO(PurchHdr,PurchLin)
    BEGIN
      CREATE(XMLDOMDocument);
      XMLDOMDocument.loadXML := '<PurchaseOrder/>';
      CurrNode := XMLDOMDocument.documentElement;
    
      // begin a 'Header' element...
      NewChild := CurrNode.ownerDocument.createNode('element', 'Header', '');
      CurrNode.appendChild(NewChild);
    
      // add child elements to the 'Header' element...
      CurrNode := NewChild;
    
      NewChild := CurrNode.ownerDocument.createNode('element', 'Document_Number', '');
      NewChild.text := PurchHdr."No.";
      CurrNode.appendChild(NewChild);
    
      NewChild := CurrNode.ownerDocument.createNode('element', 'Buy_from_Vendor', '');
      CurrNode.appendChild(NewChild);
    
      // add child elements to the 'Buy_from_Vendor' element...
      CurrNode := NewChild;
    
      NewChild := CurrNode.ownerDocument.createNode('element', 'Number', '');
      NewChild.text := PurchHdr."Buy-from Vendor No.";
      CurrNode.appendChild(NewChild);
    
      NewChild := CurrNode.ownerDocument.createNode('element', 'Name', '');
      NewChild.text := PurchHdr."Buy-from Vendor Name";
      CurrNode.appendChild(NewChild);
    
      {...}
    
      // done with 'Buy_from_Vendor' child elements
      // move back to the parent to add more 'Header' elements...
      CurrNode := CurrNode.parentNode;
    
      {...}
    
      // done with the 'Header' element -- add 'Line' elements ...
      CurrNode := CurrNode.parentNode;
    
      IF PurchLin.FIND('-') THEN
        REPEAT
          NewChild := CurrNode.ownerDocument.createNode('element', 'Line', '');
          CurrNode.appendChild(NewChild);
        
          // add 'Line' element children...
          CurrNode := NewChild;
        
          NewChild := CurrNode.ownerDocument.createNode('element', 'Line_Number', '');
          NewChild.text := FORMAT(PurchLin."Line No.");
          CurrNode.appendChild(NewChild);
        
          {...}
        
          CurrNode := CurrNode.parentNode;
        UNTIL PurchLin.NEXT = 0;
    
      // done, save it...
      XMLDOMDocument.save('c:\PurchaseOrder.xml');
    END
    
    The xml file looks something like this:
    <PurchaseOrder>
      <Header>
        <Document_Number>1001</Document_Number>
        <Buy_from_Vendor>
          <Number>10000</Number>
          <Name>London Postmaster</Name>
        </Buy_from_Vendor>
      </Header>
      <Line>
        <Line_Number>10000</Line_Number>
      </Line>
    </PurchaseOrder>
    
  • ErictPErictP Posts: 91Member
    Before using the automation object begin with:

    CLEAR("Automation VAR Name");
    CREATE("Automation VAR Name");
  • Tommy_SchouTommy_Schou Posts: 117Member
    We are working on a project that is taking data out of Navision and dumping it into a xml format. The issue that we have is that we have an "Autmation variable has not been instantiated" and no matter what I change in the CAL Locals to point it to the MSXML it will not get past.

    Any suggestions?

    Is this at runtime or at compile-time? The reason I ask this is that if it is at runtime it may be something as simple as you referring to a node that doesn't exist in the xml-document. It will in my experience give that rather misleading error message.
    Best regards
    Tommy
  • ChristophChristoph Posts: 9Member
    hi there

    I try to save whole tables in the same way as you done above..
    and for a similar one it works - but when I start to safe all tables I got a memoryproblem.
    I create an XML object, adds all content of a table in it and safe it and if it's an big tabe i splitt it to several files. Everthing works fine but as longer as the codeunit runs as bigger is the RAM that's neede even a table was saved and the object cleard. Looks like navision doesn't gives requested memory not complettle back..

    Any Ideas?? Suggestions??

    Thanks
    Christoph
Sign In or Register to comment.