#!perl -Tw use strict; use Win32::OLE; use XML::Generator; my $list_id = '40000-1022206382'; my $request_id = 1; # Be paranoid about error messages Win32::OLE->Option(Warn => 3); # Start the Processor my $connection = Win32::OLE->new('QBXMLRP.RequestProcessor'); # Name your program $connection->OpenConnection("qbtmr", "Timer Import"); # Open the currently open QuickBooks file, in "DoNotCare" mode. my $ticket = $connection->BeginSession('', 2); my @data = ; foreach my $line (@data) { my ($customer, $service, $duration, $date) = split(/,/, $line); my $gen = XML::Generator->new( escape => 'always', conformance => 'strict', pretty => 2, dtd => [ 'QBXML', 'PUBLIC', "'-//INTUIT//DTD", "QBXML QBD 1.1//EN'"], version => '1.0' ); my $xml = $gen->xmldecl; $xml = $gen->QBXML( $gen->QBXMLMsgsRq( {'onError' => 'stopOnError'}, $gen->TimeTrackingAddRq({requestID => 1}, $gen->TimeTrackingAdd( $gen->TxnDate($date), $gen->EntityRef( $gen->ListID($list_id) ), $gen->CustomerRef( $gen->FullName($customer) ), $gen->ItemServiceRef( $gen->FullName($service) ), $gen->Duration($duration), ), ), ), ); my $xml_req = $gen->xml($xml); $request_id++; open (REINVENT, ">reinvent.xml") or die "Can't open reinvent.xml for writing - $!"; print REINVENT $xml_req; close REINVENT; my $xml_res= $connection->ProcessRequest($ticket, $xml_req); } # Gracefully end everything $connection->EndSession($ticket); $connection->CloseConnection; __DATA__ Cahoots Sports Bar & Grill,AP,PT00H01M,2003-01-01 Cahoots Sports Bar & Grill,AP,PT00H01M,2003-01-01 Cahoots Sports Bar & Grill,AR,PT00H01M,2003-01-01