Import XML and automation controle

andhildaandhilda Member Posts: 26
Hi there,

I do need some help.


I try to import a XML-file.

The "LoadnodeList"-function is successful.

During "FindNodes" appears an error:

"This message ist for C/AL programmers:

This automation variable hast not been instantiated
You can instantiate it by either creating or assigning it."

but this is only after the header information in the XML file and when the InvoiceLine is trying to be handled.

The thing is, that on my laptop with XP Pro it works, but on the customers PC with W2000 the above error appears. I've checked the regional setting and whatever, but I can't find any difference between the machine, other than the OS version. The Attain version is 3.70 both runtime and database.


I'm using the codeunit 6224.

Some of the code:
XMLimpIndkøbsFakturaHoved.INIT;
XMLimpIndkøbsFakturaLinier.INIT;

XMLNode := XMLDocIn.documentElement;
XMLRootNode := XMLDocIn.documentElement;

WITH XMLDOMManagement DO BEGIN
XMLDOMManagement.SetNormalCase;
//Start header
  IF FindNode(XMLNode,'InvoiceHeader',XMLNodeFound) THEN BEGIN
    XMLNode := XMLNodeFound;
    IF FindNode(XMLNode,'InvoiceTypeCode',XMLNodeFound) THEN
      IF STRLEN(XMLNodeFound.text) > 0 THEN
      EVALUATE(XMLimpIndkøbsFakturaHoved.Bilagstype,XMLNodeFound.text);

    IF FindNode(XMLNode,'CurrencyCode',XMLNodeFound) THEN
      IF STRLEN(XMLNodeFound.text) > 0 THEN
      EVALUATE(XMLimpIndkøbsFakturaHoved."Valuta code",XMLNodeFound.text);
  END;

  IF FindNode(XMLNode,'Document',XMLNodeFound) THEN BEGIN
    XMLNode := XMLNodeFound;
    IF FindNode(XMLNode,'DocumentNumber',XMLNodeFound) THEN
      IF STRLEN(XMLNodeFound.text) > 0 THEN BEGIN
        XMLimpIndkøbsFakturaHoved."Faktura nr." := XMLNodeFound.text;
        CurrentInvoiceNo := XMLNodeFound.text;
      END;
    IF FindNode(XMLNode,'Date',XMLNodeFound) THEN
      IF STRLEN(XMLNodeFound.text) > 0 THEN BEGIN
        EVALUATE(År,COPYSTR(XMLNode.selectNodes('Date').item(0).text,1,4));
        EVALUATE(Måned,COPYSTR(XMLNode.selectNodes('Date').item(0).text,5,2));
        EVALUATE(Dag,COPYSTR(XMLNode.selectNodes('Date').item(0).text,7,2));
        XMLimpIndkøbsFakturaHoved.Dato := DMY2DATE(Dag,Måned,År);
      END;
    XMLNode := XMLNode.parentNode;
  END;

  IF FindNode(XMLNode,'InvoiceReferences',XMLNodeFound) THEN BEGIN
    XMLNode := XMLNodeFound;
    IF FindNode(XMLNode,'OrderNumberBuyer',XMLNodeFound) THEN
      IF STRLEN(XMLNodeFound.text) > 0 THEN
        EVALUATE(XMLimpIndkøbsFakturaHoved."Eget ordre nr.",XMLNodeFound.text);
    XMLNode := XMLNode.parentNode;
  END;
//Supplier
  IF FindNode(XMLNode,'Supplier',XMLNodeFound) THEN BEGIN
    XMLNode := XMLNodeFound;
    IF FindNode(XMLNode,'VATregistrationNumber',XMLNodeFound) THEN
      IF STRLEN(XMLNodeFound.text) > 0 THEN BEGIN
        XMLimpIndkøbsFakturaHoved."Leverandørens VAT nr." := XMLNodeFound.text;
      END;
    XMLNode := XMLNode.parentNode;
  END;
  IF FindNode(XMLNode,'DeliveryDate',XMLNodeFound) THEN BEGIN
    XMLNode := XMLNodeFound;
    IF FindNode(XMLNode,'Date',XMLNodeFound) THEN
      IF STRLEN(XMLNodeFound.text) > 0 THEN BEGIN
        EVALUATE(År,COPYSTR(XMLNode.selectNodes('Date').item(0).text,1,4));
        EVALUATE(Måned,COPYSTR(XMLNode.selectNodes('Date').item(0).text,5,2));
        EVALUATE(Dag,COPYSTR(XMLNode.selectNodes('Date').item(0).text,7,2));
        XMLimpIndkøbsFakturaHoved."Ordre Leveringsdato" := DMY2DATE(Dag,Måned,År);
      END;
    XMLNode := XMLNode.parentNode;
  END;

  IF FindNode(XMLNode,'BasicPaymentTerm',XMLNodeFound) THEN BEGIN
    XMLNode := XMLNodeFound;
    IF FindNode(XMLNode,'NumberOfDays',XMLNodeFound) THEN
      IF STRLEN(XMLNodeFound.text) > 0 THEN
        XMLimpIndkøbsFakturaHoved."Respitdage betaling" := XMLNodeFound.text;
    XMLNode := XMLNode.parentNode;
  END;

  XMLNode := XMLDocIn.documentElement;

  IF FindNode(XMLNode,'InvoiceSummary',XMLNodeFound) THEN BEGIN
    XMLNode := XMLNodeFound;
    IF FindNode(XMLNode,'InvoiceTotals',XMLNodeFound) THEN BEGIN
      XMLNode := XMLNodeFound;
      IF FindNode(XMLNode,'LineItemAmount',XMLNodeFound) THEN
        IF STRLEN(XMLNodeFound.text) > 0 THEN
          XMLimpIndkøbsFakturaHoved.Fakturatotal := CONVERTSTR(XMLNodeFound.text,'.',',');
      XMLNode := XMLNode.parentNode;
    END;
  END;
  XMLNode := XMLDocIn.documentElement;
  IF FindNode(XMLNode,'InvoiceSummary',XMLNodeFound) THEN BEGIN
    XMLNode := XMLNodeFound;
    IF FindNode(XMLNode,'TaxSpecification',XMLNodeFound) THEN BEGIN
      XMLNode := XMLNodeFound;
      IF FindNode(XMLNode,'Tax',XMLNodeFound) THEN BEGIN
        XMLNode := XMLNodeFound;
      IF FindNode(XMLNode,'TaxRate',XMLNodeFound) THEN
        IF STRLEN(XMLNodeFound.text) > 0 THEN
          XMLimpIndkøbsFakturaHoved."Moms sats" := CONVERTSTR(XMLNodeFound.text,'.',',');
      IF FindNode(XMLNode,'BasisAmount',XMLNodeFound) THEN
        IF STRLEN(XMLNodeFound.text) > 0 THEN
          XMLimpIndkøbsFakturaHoved.Momsgrundlag := CONVERTSTR(XMLNodeFound.text,'.',',');
      IF FindNode(XMLNode,'TaxAmount',XMLNodeFound) THEN
        IF STRLEN(XMLNodeFound.text) > 0 THEN
          XMLimpIndkøbsFakturaHoved.Momsbeløb := CONVERTSTR(XMLNodeFound.text,'.',',');
      XMLNode := XMLNode.parentNode;
      END;
    END
  END;

XMLimpIndkøbsFakturaHoved."Linie nr." := 0;
IF NOT XMLimpIndkøbsFakturaHoved.INSERT THEN   //Header information
  MESSAGE('XML filen %1 er allerede indlæst',"XML-Filepath".Path+"XML-Filepath".Name)
ELSE BEGIN

  //Slut på header

  //Start linier

//  XMLimpIndkøbsFakturaHoved.INIT;

    XMLNode := XMLDocIn.documentElement;

    IF FindNodes(XMLNode,'InvoiceLine',XMLNodeList) THEN BEGIN
      XMLNodeList.reset();
      XMLNode:= XMLNodeList.nextNode();
      WHILE NOT ISCLEAR(XMLNode) DO BEGIN
        XMLimpIndkøbsFakturaLinier."Faktura nr." := CurrentInvoiceNo;

The XMl file:
<?xml version="1.0" encoding="UTF-8" ?>
<Invoice xmlns....deleted>
	<InvoiceHeader>
		<InvoiceVersion>1.3</InvoiceVersion>
		<InvoiceTypeCode>380</InvoiceTypeCode>
		<Document>
			<DocumentNumber>0246147659</DocumentNumber>
			<Date>20051110</Date>
			<Time />
			<TimeZone />
			<FreeText />
		</Document>
		<CurrencyCode>DKK</CurrencyCode>
		<InvoiceReferences>
			<OrderNumberBuyer>1234</OrderNumberBuyer>
			<SupplierOrderReference>
				<OrderNumberSupplier />
				<Date />
			</SupplierOrderReference>
			<DespatchAdviceNumber>0245189407</DespatchAdviceNumber>
			<InvoiceNumber>0246147659</InvoiceNumber>
			<ProjectNumber />
		</InvoiceReferences>
		<Supplier>
			<PartyNumberId>
				<PartyNumber>1234</PartyNumber>
				<PartyNumberTypeCode>9</PartyNumberTypeCode>
			</PartyNumberId>
			<PartyName />
			<StreetAndNumber />
			<Postcode />
			<CityName />
			<CountryCode />
			<VATregistrationNumber>1234</VATregistrationNumber>
			<Employee />
			<Telephone />
		</Supplier>
		<Buyer>
			<PartyNumberId>
				<PartyNumber>1234</PartyNumber>
				<PartyNumberTypeCode>9</PartyNumberTypeCode>
			</PartyNumberId>
			<PartyName />
			<StreetAndNumber />
			<Postcode />
			<CityName />
			<CountryCode />
			<VATregistrationNumber>1234</VATregistrationNumber>
			<Employee />
			<Telephone />
		</Buyer>
		<Invoicee>
			<PartyNumberId>
				<PartyNumber>1234</PartyNumber>
				<PartyNumberTypeCode>9</PartyNumberTypeCode>
			</PartyNumberId>
			<PartyName />
			<StreetAndNumber />
			<Postcode />
			<CityName />
			<CountryCode />
			<VATregistrationNumber>1234</VATregistrationNumber>
			<Employee />
			<Telephone />
		</Invoicee>
		<DeliveryParty>
			<PartyNumberId>
				<PartyNumber>1234</PartyNumber>
				<PartyNumberTypeCode>9</PartyNumberTypeCode>
			</PartyNumberId>
			<PartyName>bla bla A/S</PartyName>
			<StreetAndNumber>some where</StreetAndNumber>
			<Postcode>3000</Postcode>
			<CityName>afasdfasdf</CityName>
			<CountryCode>DK</CountryCode>
			<Employee />
			<Telephone />
		</DeliveryParty>
		<UltimateCustomer>
			<PartyNumberId>
				<PartyNumber>1234</PartyNumber>
				<PartyNumberTypeCode>9</PartyNumberTypeCode>
			</PartyNumberId>
			<PartyName />
			<StreetAndNumber />
			<Postcode />
			<CityName />
			<CountryCode />
			<Employee />
			<Telephone />
		</UltimateCustomer>
		<Carrier>
			<PartyNumberId>
				<PartyNumber>1234</PartyNumber>
				<PartyNumberTypeCode>9</PartyNumberTypeCode>
			</PartyNumberId>
			<PartyName />
			<StreetAndNumber />
			<Postcode />
			<CityName />
			<CountryCode />
			<Employee />
			<Telephone />
		</Carrier>
		<UltimateConsignee>
			<PartyNumberId>
				<PartyNumber>1234</PartyNumber>
				<PartyNumberTypeCode>9</PartyNumberTypeCode>
			</PartyNumberId>
			<PartyName />
			<StreetAndNumber />
			<Postcode />
			<CityName />
			<CountryCode />
			<Employee />
			<Telephone />
		</UltimateConsignee>
		<TermOfDeliveryCode />
		<DeliveryDate>
			<Date>20051110</Date>
			<Time />
			<TimeZone />
		</DeliveryDate>
		<BasicPaymentTerm>
			<NumberOfDays>8</NumberOfDays>
		</BasicPaymentTerm>
	</InvoiceHeader>
	<InvoiceLine>
		<LineItemNumber />
		<GTIN>166892</GTIN>
		<TradeItemId>
			<TradeItemNumber />
			<TradeItemNumberTypeCode />
		</TradeItemId>
		<ItemDescription>asdf asdfasfasdf BASE Z</ItemDescription>
		<DeliveredQuantity>
			<Quantity>3.000</Quantity>
			<MeasureUnitQualifier>PCE</MeasureUnitQualifier>
		</DeliveredQuantity>
		<InvoicedQuantity>
			<Quantity>3.000</Quantity>
			<MeasureUnitQualifier>PCE</MeasureUnitQualifier>
		</InvoicedQuantity>
		<LineItemAmount>194.79</LineItemAmount>
		<LineItemPVC>5.82</LineItemPVC>
		<AdditionalIdentification>
			<BatchNumber />
			<HarmonisedSytemNumber />
			<PromotionalDealNumber />
		</AdditionalIdentification>
		<NetUnitPrice>
			<Price>93.00</Price>
			<UnitPriceBasis>1</UnitPriceBasis>
			<MeasureUnitQualifier>LTR</MeasureUnitQualifier>
		</NetUnitPrice>
		<GrossUnitPrice>
			<Price />
			<UnitPriceBasis />
			<MeasureUnitQualifier />
		</GrossUnitPrice>
		<LineItemReference />
	</InvoiceLine>
	<InvoiceSummary>
		<InvoiceTotals>
			<LineItemAmount>250.76</LineItemAmount>
			<AllowanceOrCharge />
			<TaxAmount>50.15</TaxAmount>
			<MessageAmount>250.76</MessageAmount>
			<BasisAmount />
		</InvoiceTotals>
		<TaxSpecification>
			<Tax>
				<TaxCategoryCode>S</TaxCategoryCode>
				<TaxRate>25.000</TaxRate>
				<BasisAmount>250.76</BasisAmount>
				<TaxAmount>50.15</TaxAmount>
			</Tax>
		</TaxSpecification>
	</InvoiceSummary>
</Invoice>

Comments

  • pdjpdj Member Posts: 643
    andhilda wrote:
    The thing is, that on my laptop with XP Pro it works, but on the customers PC with W2000 the above error appears. I've checked the regional setting and whatever, but I can't find any difference between the machine, other than the OS version. The Attain version is 3.70 both runtime and database.
    Then I guess the problem is the version of the installed XMLDOM. Try getting the customer to install an updated version from Microsoft - i.e. http://msdn.microsoft.com/XML/XMLDownloads/default.aspx

    It can be difficult to find which components (or versions of components) are installed at customer sites. However; MS actually provides quite a good tool to find answers to these types of questions: http://support.microsoft.com/servicedesks/fileversion/ and an article about dll-hell at http://msdn.microsoft.com/library/defau ... anger1.asp
    Regards
    Peter
  • andhildaandhilda Member Posts: 26
    Thankz,

    I'll look into it on my next visit at the customers site. I think that I have forgotten the installation af XML core services 6.

    I'll post the result later.

    Best regards

    Andhilda
  • andhildaandhilda Member Posts: 26
    Nope this didn't solve the issue. I've installed XML Core 6 and everything updated from MS and I'm still getting this error message. Any other advise on solving this issue?

    Best regards

    Andhilda
Sign In or Register to comment.