Thank you in advance for your assistance!!! UE rocks!
Instructions for script:
There are multiple xml invoice files per xml file. This sample has 4 xml invoice files in it. Each file has a header level area and a line level area.
In the line level area there are some line items with a Buyer Part Number of "999" (<edi:BuyerPartNumber>999</edi:BuyerPartNumber>), that needs the '999' change to the correct code found in the parms csv file, based upon matches found in three other elements. The elements to match agains in the xml file are, <edi:SellerPartNumber> (which is the first field in the Parms csv file), <edi:PartNumberDescription> (which is the second field in the Parms csv file), <edi:SellerMfrCode> (which is the third field in the Parms csv file). If a match is found in the csv file for a line in the xml file that contains a '999' in the <edi:BuyerPartNumber> element, then replace the '999' in the xml file with the fourth field in the matching csv file line. If a match is not found, make not change to the xml file. If the xml line does not contain a '999' in the Buyer Part Number, then make no change to the xml file.
File samples:
>>>>>>>>>>>>>>>>>>>
Parm_File.csv
41-601,SPARK PLUG,AC,222,
41-602,SPARK PLUG,AC,222,
34352229018,NIF Part,XBO,237
INV PR DIFF,NIF Part,XBO,222
1275602,NIF Part,WPC,222
>>>>>>>>>>>>>>>>>>>>>>>
XML file to be changed:
sample_batchfile_xml.txt
- Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<edi:NAInvoice xmlns:edi="http://www.carquest.com/edi">
<edi:Sender>
<edi:Qualifier>01</edi:Qualifier>
<edi:ID>101735868</edi:ID>
</edi:Sender>
<edi:Receiver>
<edi:Qualifier>01</edi:Qualifier>
<edi:ID>004467924</edi:ID>
</edi:Receiver>
<edi:BatchNumber>31</edi:BatchNumber>
<edi:NAInvoiceHeader>
<edi:StoreKey>2988</edi:StoreKey>
<edi:POSAccountCode>K1780</edi:POSAccountCode>
<edi:SellerAssignedCustomerID>459470</edi:SellerAssignedCustomerID>
<edi:MemberCode>GPI-JV</edi:MemberCode>
<edi:BuyerAssignedCustomerID>1034</edi:BuyerAssignedCustomerID>
<edi:BillTo>
<edi:Name>GOODYEAR 1034</edi:Name>
<edi:Address1>5913 PENN CIR N</edi:Address1>
<edi:Address2/>
<edi:City>PITTSBURGH</edi:City>
<edi:StateOrProvince>PA</edi:StateOrProvince>
<edi:PostalCode>15206</edi:PostalCode>
<edi:CountryCode>US</edi:CountryCode>
</edi:BillTo>
<edi:Payee>
<edi:Name>27779</edi:Name>
</edi:Payee>
<edi:ShipTo>
<edi:Name>GOODYEAR</edi:Name>
<edi:Address1>5913 PENN CIRCLE NORTH</edi:Address1>
<edi:Address2></edi:Address2>
<edi:City>PITTSBURGH</edi:City>
<edi:StateOrProvince>PA</edi:StateOrProvince>
<edi:PostalCode>15206</edi:PostalCode>
<edi:CountryCode></edi:CountryCode>
</edi:ShipTo>
<edi:RemitTo>
<edi:Address1>CARQUEST AUTO PARTS STORES</edi:Address1>
<edi:Address2>PO BOX 503628</edi:Address2>
<edi:City>ST LOUIS</edi:City>
<edi:StateOrProvince>MO</edi:StateOrProvince>
<edi:PostalCode>63150-3628</edi:PostalCode>
<edi:CountryCode>United States</edi:CountryCode>
</edi:RemitTo>
<edi:CurrencyCode>USD</edi:CurrencyCode>
<edi:InvoiceDate>2008-07-24</edi:InvoiceDate>
<edi:CorporateInvoiceNumber>2988-ID-73806</edi:CorporateInvoiceNumber>
<edi:StoreInvoiceNumber>73806</edi:StoreInvoiceNumber>
<edi:PrintedInvoiceNumber>2988-73806</edi:PrintedInvoiceNumber>
<edi:ManualInvoiceNumber>2988-ID-73806</edi:ManualInvoiceNumber>
<edi:ModeTwoInvoiceNumber></edi:ModeTwoInvoiceNumber>
<edi:PONumber>159768</edi:PONumber>
<edi:PODate>2008-07-24</edi:PODate>
<edi:ShippedDate>2008-07-24</edi:ShippedDate>
<edi:TransactionType>INV</edi:TransactionType>
<edi:TransactionTotal>18.85</edi:TransactionTotal>
<edi:StateSalesTax>0.0000</edi:StateSalesTax>
<edi:CountySalesTax>0.0000</edi:CountySalesTax>
<edi:OtherSalesTax>0.0000</edi:OtherSalesTax>
<edi:SalesTaxTotal>0.0000</edi:SalesTaxTotal>
<edi:FreightTotal>0.0000</edi:FreightTotal>
<edi:LaborTotal>0.0000</edi:LaborTotal>
<edi:CoreTotal>0.0000</edi:CoreTotal>
<edi:InvoiceDiscountTotal>0.0000</edi:InvoiceDiscountTotal>
<edi:ServiceCharge>0.0000</edi:ServiceCharge>
<edi:SpecialUse>0.0000</edi:SpecialUse>
<edi:StateSurcharge>0.0000</edi:StateSurcharge>
<edi:CustomerTrxId>278031715</edi:CustomerTrxId>
</edi:NAInvoiceHeader>
<edi:NAInvoiceLine>
<edi:LineNumber>1</edi:LineNumber>
<edi:SellerMfrCode>XBO</edi:SellerMfrCode>
<edi:SellerPartNumber>34352229018</edi:SellerPartNumber>
<edi:BuyerPartNumber>999</edi:BuyerPartNumber>
<edi:PartNumberDescription>NIF Part</edi:PartNumberDescription>
<edi:QuantityInvoiced>1</edi:QuantityInvoiced>
<edi:UnitOfMeasureCode>EA</edi:UnitOfMeasureCode>
<edi:UnitPrice>18.8500</edi:UnitPrice>
<edi:InvoiceDiscount>0.0000</edi:InvoiceDiscount>
<edi:ExtendedAmount>18.8500</edi:ExtendedAmount>
<edi:CoreCharge>0.0000</edi:CoreCharge>
<edi:LineItemMessage></edi:LineItemMessage>
<edi:OrderedElectronically>false</edi:OrderedElectronically>
<edi:ItemType>PART</edi:ItemType>
<edi:ServiceCharge>0.0000</edi:ServiceCharge>
<edi:SpecialUse>0.0000</edi:SpecialUse>
<edi:Tax>0.00000</edi:Tax>
<edi:StateSurcharge>0.0000</edi:StateSurcharge>
</edi:NAInvoiceLine>
</edi:NAInvoice><?xml version="1.0" encoding="UTF-8"?>
<edi:NAInvoice xmlns:edi="http://www.carquest.com/edi">
<edi:Sender>
<edi:Qualifier>01</edi:Qualifier>
<edi:ID>101735868</edi:ID>
</edi:Sender>
<edi:Receiver>
<edi:Qualifier>01</edi:Qualifier>
<edi:ID>004467924</edi:ID>
</edi:Receiver>
<edi:BatchNumber>31</edi:BatchNumber>
<edi:NAInvoiceHeader>
<edi:StoreKey>2149</edi:StoreKey>
<edi:POSAccountCode>031176</edi:POSAccountCode>
<edi:SellerAssignedCustomerID>608861</edi:SellerAssignedCustomerID>
<edi:MemberCode>GPI-JV</edi:MemberCode>
<edi:BuyerAssignedCustomerID>6720</edi:BuyerAssignedCustomerID>
<edi:BillTo>
<edi:Name>GOODYEAR 6720 DOWNTOWN</edi:Name>
<edi:Address1>627 NORTH DELAWARE ST</edi:Address1>
<edi:Address2/>
<edi:City>INDIANAPOLIS</edi:City>
<edi:StateOrProvince>IN</edi:StateOrProvince>
<edi:PostalCode>46204</edi:PostalCode>
<edi:CountryCode>US</edi:CountryCode>
</edi:BillTo>
<edi:Payee>
<edi:Name>27779</edi:Name>
</edi:Payee>
<edi:ShipTo>
<edi:Name>GOODYEAR DOWNTOWN</edi:Name>
<edi:Address1>627 N DELAWARE ST</edi:Address1>
<edi:Address2></edi:Address2>
<edi:City>INDIANAPOLIS</edi:City>
<edi:StateOrProvince>IN</edi:StateOrProvince>
<edi:PostalCode></edi:PostalCode>
<edi:CountryCode></edi:CountryCode>
</edi:ShipTo>
<edi:RemitTo>
<edi:Address1>CARQUEST AUTO PARTS STORES</edi:Address1>
<edi:Address2>PO BOX 503601</edi:Address2>
<edi:City>ST LOUIS</edi:City>
<edi:StateOrProvince>MO</edi:StateOrProvince>
<edi:PostalCode>63150-3601</edi:PostalCode>
<edi:CountryCode>United States</edi:CountryCode>
</edi:RemitTo>
<edi:CurrencyCode>USD</edi:CurrencyCode>
<edi:InvoiceDate>2008-07-24</edi:InvoiceDate>
<edi:CorporateInvoiceNumber>2149-ID-104139</edi:CorporateInvoiceNumber>
<edi:StoreInvoiceNumber>104139</edi:StoreInvoiceNumber>
<edi:PrintedInvoiceNumber>2149-104139</edi:PrintedInvoiceNumber>
<edi:ManualInvoiceNumber>2149-ID-104139</edi:ManualInvoiceNumber>
<edi:ModeTwoInvoiceNumber></edi:ModeTwoInvoiceNumber>
<edi:PONumber>6720</edi:PONumber>
<edi:PODate>2008-07-24</edi:PODate>
<edi:ShippedDate>2008-07-24</edi:ShippedDate>
<edi:TransactionType>INV</edi:TransactionType>
<edi:TransactionTotal>103.44</edi:TransactionTotal>
<edi:StateSalesTax>0.0000</edi:StateSalesTax>
<edi:CountySalesTax>0.0000</edi:CountySalesTax>
<edi:OtherSalesTax>0.0000</edi:OtherSalesTax>
<edi:SalesTaxTotal>0.0000</edi:SalesTaxTotal>
<edi:FreightTotal>0.0000</edi:FreightTotal>
<edi:LaborTotal>0.0000</edi:LaborTotal>
<edi:CoreTotal>0.0000</edi:CoreTotal>
<edi:InvoiceDiscountTotal>0.0000</edi:InvoiceDiscountTotal>
<edi:ServiceCharge>0.0000</edi:ServiceCharge>
<edi:SpecialUse>0.0000</edi:SpecialUse>
<edi:StateSurcharge>0.0000</edi:StateSurcharge>
<edi:CustomerTrxId>278023523</edi:CustomerTrxId>
</edi:NAInvoiceHeader>
<edi:NAInvoiceLine>
<edi:LineNumber>1</edi:LineNumber>
<edi:SellerMfrCode>XBO</edi:SellerMfrCode>
<edi:SellerPartNumber>12378508</edi:SellerPartNumber>
<edi:BuyerPartNumber>237</edi:BuyerPartNumber>
<edi:PartNumberDescription>NIF Part</edi:PartNumberDescription>
<edi:QuantityInvoiced>12</edi:QuantityInvoiced>
<edi:UnitOfMeasureCode>EA</edi:UnitOfMeasureCode>
<edi:UnitPrice>8.6200</edi:UnitPrice>
<edi:InvoiceDiscount>0.0000</edi:InvoiceDiscount>
<edi:ExtendedAmount>103.4400</edi:ExtendedAmount>
<edi:CoreCharge>0.0000</edi:CoreCharge>
<edi:LineItemMessage></edi:LineItemMessage>
<edi:OrderedElectronically>false</edi:OrderedElectronically>
<edi:ItemType>PART</edi:ItemType>
<edi:ServiceCharge>0.0000</edi:ServiceCharge>
<edi:SpecialUse>0.0000</edi:SpecialUse>
<edi:Tax>0.00000</edi:Tax>
<edi:StateSurcharge>0.0000</edi:StateSurcharge>
</edi:NAInvoiceLine>
</edi:NAInvoice><?xml version="1.0" encoding="UTF-8"?>
<edi:NAInvoice xmlns:edi="http://www.carquest.com/edi">
<edi:Sender>
<edi:Qualifier>01</edi:Qualifier>
<edi:ID>101735868</edi:ID>
</edi:Sender>
<edi:Receiver>
<edi:Qualifier>01</edi:Qualifier>
<edi:ID>004467924</edi:ID>
</edi:Receiver>
<edi:BatchNumber>31</edi:BatchNumber>
<edi:NAInvoiceHeader>
<edi:StoreKey>12966</edi:StoreKey>
<edi:POSAccountCode>510165</edi:POSAccountCode>
<edi:SellerAssignedCustomerID>992478</edi:SellerAssignedCustomerID>
<edi:MemberCode>GPI-JV</edi:MemberCode>
<edi:BuyerAssignedCustomerID>6651</edi:BuyerAssignedCustomerID>
<edi:BillTo>
<edi:Name>GOODYEAR 6651</edi:Name>
<edi:Address1>3690 BIRD RD</edi:Address1>
<edi:Address2/>
<edi:City>CORAL GABLES</edi:City>
<edi:StateOrProvince>FL</edi:StateOrProvince>
<edi:PostalCode>33133</edi:PostalCode>
<edi:CountryCode>US</edi:CountryCode>
</edi:BillTo>
<edi:Payee>
<edi:Name>27779</edi:Name>
</edi:Payee>
<edi:ShipTo>
<edi:Name>GOODYEAR 6651</edi:Name>
<edi:Address1>3690 BIRD RD</edi:Address1>
<edi:Address2></edi:Address2>
<edi:City>CORAL GABLES</edi:City>
<edi:StateOrProvince>FL</edi:StateOrProvince>
<edi:PostalCode>33133</edi:PostalCode>
<edi:CountryCode></edi:CountryCode>
</edi:ShipTo>
<edi:RemitTo>
<edi:Address1>CARQUEST AUTO PARTS STORES</edi:Address1>
<edi:Address2>PO Box 404875</edi:Address2>
<edi:City>ATLANTA</edi:City>
<edi:StateOrProvince>GA</edi:StateOrProvince>
<edi:PostalCode>30384-4875</edi:PostalCode>
<edi:CountryCode>United States</edi:CountryCode>
</edi:RemitTo>
<edi:CurrencyCode>USD</edi:CurrencyCode>
<edi:InvoiceDate>2008-07-24</edi:InvoiceDate>
<edi:CorporateInvoiceNumber>12966-ID-1145</edi:CorporateInvoiceNumber>
<edi:StoreInvoiceNumber>1145</edi:StoreInvoiceNumber>
<edi:PrintedInvoiceNumber>12966-1145</edi:PrintedInvoiceNumber>
<edi:ManualInvoiceNumber>12966-ID-1145</edi:ManualInvoiceNumber>
<edi:ModeTwoInvoiceNumber></edi:ModeTwoInvoiceNumber>
<edi:PONumber>134399</edi:PONumber>
<edi:PODate>2008-07-24</edi:PODate>
<edi:ShippedDate>2008-07-24</edi:ShippedDate>
<edi:TransactionType>INV</edi:TransactionType>
<edi:TransactionTotal>65.88</edi:TransactionTotal>
<edi:StateSalesTax>0.0000</edi:StateSalesTax>
<edi:CountySalesTax>0.0000</edi:CountySalesTax>
<edi:OtherSalesTax>0.0000</edi:OtherSalesTax>
<edi:SalesTaxTotal>0.0000</edi:SalesTaxTotal>
<edi:FreightTotal>0.0000</edi:FreightTotal>
<edi:LaborTotal>0.0000</edi:LaborTotal>
<edi:CoreTotal>0.0000</edi:CoreTotal>
<edi:InvoiceDiscountTotal>0.0000</edi:InvoiceDiscountTotal>
<edi:ServiceCharge>0.0000</edi:ServiceCharge>
<edi:SpecialUse>0.0000</edi:SpecialUse>
<edi:StateSurcharge>0.0000</edi:StateSurcharge>
<edi:CustomerTrxId>278070030</edi:CustomerTrxId>
</edi:NAInvoiceHeader>
<edi:NAInvoiceLine>
<edi:LineNumber>1</edi:LineNumber>
<edi:SellerMfrCode>WPC</edi:SellerMfrCode>
<edi:SellerPartNumber>1275602</edi:SellerPartNumber>
<edi:BuyerPartNumber>999</edi:BuyerPartNumber>
<edi:PartNumberDescription>NIF Part</edi:PartNumberDescription>
<edi:QuantityInvoiced>1</edi:QuantityInvoiced>
<edi:UnitOfMeasureCode>EA</edi:UnitOfMeasureCode>
<edi:UnitPrice>65.8800</edi:UnitPrice>
<edi:InvoiceDiscount>0.0000</edi:InvoiceDiscount>
<edi:ExtendedAmount>65.8800</edi:ExtendedAmount>
<edi:CoreCharge>0.0000</edi:CoreCharge>
<edi:LineItemMessage></edi:LineItemMessage>
<edi:OrderedElectronically>false</edi:OrderedElectronically>
<edi:ItemType>PART</edi:ItemType>
<edi:ServiceCharge>0.0000</edi:ServiceCharge>
<edi:SpecialUse>0.0000</edi:SpecialUse>
<edi:Tax>0.00000</edi:Tax>
<edi:StateSurcharge>0.0000</edi:StateSurcharge>
</edi:NAInvoiceLine>
</edi:NAInvoice><?xml version="1.0" encoding="UTF-8"?>
<edi:NAInvoice xmlns:edi="http://www.carquest.com/edi">
<edi:Sender>
<edi:Qualifier>01</edi:Qualifier>
<edi:ID>101735868</edi:ID>
</edi:Sender>
<edi:Receiver>
<edi:Qualifier>01</edi:Qualifier>
<edi:ID>004467924</edi:ID>
</edi:Receiver>
<edi:BatchNumber>31</edi:BatchNumber>
<edi:NAInvoiceHeader>
<edi:StoreKey>11599</edi:StoreKey>
<edi:POSAccountCode>720001</edi:POSAccountCode>
<edi:SellerAssignedCustomerID>1013172</edi:SellerAssignedCustomerID>
<edi:MemberCode>GPI-JV</edi:MemberCode>
<edi:BuyerAssignedCustomerID>2433</edi:BuyerAssignedCustomerID>
<edi:BillTo>
<edi:Name>GOODYEAR 2433</edi:Name>
<edi:Address1>675 SKYMARKS DR</edi:Address1>
<edi:Address2/>
<edi:City>JACKSONVILLE</edi:City>
<edi:StateOrProvince>FL</edi:StateOrProvince>
<edi:PostalCode>32218</edi:PostalCode>
<edi:CountryCode>US</edi:CountryCode>
</edi:BillTo>
<edi:Payee>
<edi:Name>27779</edi:Name>
</edi:Payee>
<edi:ShipTo>
<edi:Name>GOODYEAR #2433</edi:Name>
<edi:Address1>675 SKYMARKS DR</edi:Address1>
<edi:Address2></edi:Address2>
<edi:City>JACKSONVILLE</edi:City>
<edi:StateOrProvince>FL</edi:StateOrProvince>
<edi:PostalCode>32218</edi:PostalCode>
<edi:CountryCode></edi:CountryCode>
</edi:ShipTo>
<edi:RemitTo>
<edi:Address1>CARQUEST AUTO PARTS STORES</edi:Address1>
<edi:Address2>PO Box 404875</edi:Address2>
<edi:City>ATLANTA</edi:City>
<edi:StateOrProvince>GA</edi:StateOrProvince>
<edi:PostalCode>30384-4875</edi:PostalCode>
<edi:CountryCode>United States</edi:CountryCode>
</edi:RemitTo>
<edi:CurrencyCode>USD</edi:CurrencyCode>
<edi:InvoiceDate>2008-07-24</edi:InvoiceDate>
<edi:CorporateInvoiceNumber>11599-ID-20368</edi:CorporateInvoiceNumber>
<edi:StoreInvoiceNumber>20368</edi:StoreInvoiceNumber>
<edi:PrintedInvoiceNumber>11599-20368</edi:PrintedInvoiceNumber>
<edi:ManualInvoiceNumber>11599-ID-20368</edi:ManualInvoiceNumber>
<edi:ModeTwoInvoiceNumber></edi:ModeTwoInvoiceNumber>
<edi:PONumber>2433TP</edi:PONumber>
<edi:PODate>2008-07-24</edi:PODate>
<edi:ShippedDate>2008-07-24</edi:ShippedDate>
<edi:TransactionType>INV</edi:TransactionType>
<edi:TransactionTotal>132.06</edi:TransactionTotal>
<edi:StateSalesTax>0.0000</edi:StateSalesTax>
<edi:CountySalesTax>0.0000</edi:CountySalesTax>
<edi:OtherSalesTax>0.0000</edi:OtherSalesTax>
<edi:SalesTaxTotal>0.0000</edi:SalesTaxTotal>
<edi:FreightTotal>0.0000</edi:FreightTotal>
<edi:LaborTotal>0.0000</edi:LaborTotal>
<edi:CoreTotal>0.0000</edi:CoreTotal>
<edi:InvoiceDiscountTotal>0.0000</edi:InvoiceDiscountTotal>
<edi:ServiceCharge>0.0000</edi:ServiceCharge>
<edi:SpecialUse>0.0000</edi:SpecialUse>
<edi:StateSurcharge>0.0000</edi:StateSurcharge>
<edi:CustomerTrxId>278068737</edi:CustomerTrxId>
</edi:NAInvoiceHeader>
<edi:NAInvoiceLine>
<edi:LineNumber>1</edi:LineNumber>
<edi:SellerMfrCode>XBO</edi:SellerMfrCode>
<edi:SellerPartNumber>ICMD308086</edi:SellerPartNumber>
<edi:BuyerPartNumber>999</edi:BuyerPartNumber>
<edi:PartNumberDescription>TIMING TENSIONER ACTUATOR</edi:PartNumberDescription>
<edi:QuantityInvoiced>1</edi:QuantityInvoiced>
<edi:UnitOfMeasureCode>EA</edi:UnitOfMeasureCode>
<edi:UnitPrice>132.0600</edi:UnitPrice>
<edi:InvoiceDiscount>0.0000</edi:InvoiceDiscount>
<edi:ExtendedAmount>132.0600</edi:ExtendedAmount>
<edi:CoreCharge>0.0000</edi:CoreCharge>
<edi:LineItemMessage></edi:LineItemMessage>
<edi:OrderedElectronically>false</edi:OrderedElectronically>
<edi:ItemType>PART</edi:ItemType>
<edi:ServiceCharge>0.0000</edi:ServiceCharge>
<edi:SpecialUse>0.0000</edi:SpecialUse>
<edi:Tax>0.00000</edi:Tax>
<edi:StateSurcharge>0.0000</edi:StateSurcharge>
</edi:NAInvoiceLine>
</edi:NAInvoice>


