XMLport losing global variable when inserting line records Nav 2009

dsummerdsummer Member Posts: 7
When creating an import for a Sales Document XML file, where the file import is to create the Sales Invoice No for the Header, then attach several Sales Lines, I'm finding that the Global Variable that the SH.No. is assigned to is lost when the Sales Lines section is reached.

Code behind the Sales Header table section inserts the header correctly, and the SH No. is assigned to a global variable, but the code behind the Sales Line table section doesn't have the value in the global variable when the lines are to be inserted at that point. I've added a message to screen to show me what values are missing, and it's the DocNo and SalesHeader."No." that are blank.

Can you help with suggestions for what I'm doing wrong, or what else needs to be done to fix this?

XMLport layout
Node Name Node Type Source Type Data Source
RentalBills Element Text <RentalBills>
RentalBill Element Table <Sales Header>(Sales Header)
ClientId Element Text <ClientId>
RentalBillLineItems Element Text <RentalBillLineItems>
RentalBillLineItem Element Table <Sales Line>(Sales Line)
Description Element Text <Description>
TotalDays Element Text <TotalDays>
Rate Element Text <Rate>
RentalCharge Element Text <RentalCharge>

Import file layout
<?xml version="1.0"?>
<RentalBills>
<RentalBill>
<ClientId>MGCC0015</ClientId>
<RentalBillLineItems>
<RentalBillLineItem>
<Description>AR336</Description>
<TotalDays>366</TotalDays>
<Rate>$0.100</Rate>
<RentalCharge>$36.60</RentalCharge>
</RentalBillLineItem>
<RentalBillLineItem>
<Description>AR80</Description>
<TotalDays>122</TotalDays>
<Rate>$0.100</Rate>
<RentalCharge>$12.20</RentalCharge>
</RentalBillLineItem>
<RentalBillLineItem>
<Description>HE110</Description>
<TotalDays>244</TotalDays>
<Rate>$0.100</Rate>
<RentalCharge>$24.40</RentalCharge>
</RentalBillLineItem>
<RentalBillLineItem>
<Description>Industrial // Industrial Cylinder :: Acetylene :: AC145</Description>
<TotalDays>244</TotalDays>
<Rate>$0.100</Rate>
<RentalCharge>$24.40</RentalCharge>
</RentalBillLineItem>
<RentalBillLineItem>
<Description>OX125</Description>
<TotalDays>34</TotalDays>
<Rate>$0.100</Rate>
<RentalCharge>$3.40</RentalCharge>
</RentalBillLineItem>
</RentalBillLineItems>
</RentalBill>
</RentalBills>

Code behind Sales Header
SalesHeader.VALIDATE("Document Type",SalesHeader."Document Type"::Invoice);
SalesHeader."No." := '';
SalesHeader.INSERT(TRUE);
DocNo := SalesHeader."No.";

Code behind Sales Lines
MESSAGE('line doc %1, line %2, Desc %3, sh %4',DocNo,LineNo,Description,SalesHeader."No.");
SalesLine.VALIDATE("Document Type",SalesLine."Document Type"::Invoice);
SalesLine.VALIDATE("Document No.",DocNo);
SalesLine.VALIDATE("Line No.",LineNo);
SalesLine.INSERT(TRUE);
Thanks

Debbie
Sign In or Register to comment.