#!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 #### #!perl -Tw use strict; use DBI; 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 $dbh = DBI->connect("DBI:CSV:") or die "Cannot connect: " . $DBI::errstr; my $sth = $dbh->prepare("SELECT Customer, Service, Duration, Date FROM data") or die "Cannot prepare: " . $dbh->errstr(); $sth->execute() or die "Cannot execute: " . $sth->errstr(); $sth->bind_columns(\my($customer, $service, $duration, $date)); while ($sth->fetch) { 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 (ACTUAL, ">actual.xml") or die "Can't open actual.xml for writing - $!"; print ACTUAL $xml_req; close ACTUAL; my $xml_res= $connection->ProcessRequest($ticket, $xml_req); } $sth->finish(); $dbh->disconnect(); # Gracefully end everything $connection->EndSession($ticket); $connection->CloseConnection; #### Customer,Service,Duration,Date 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 #### OLE exception from "QBXMLRP.RequestProcessor.1": QuickBooks found an error when parsing the provided XML text stream. Win32::OLE(0.1502) error 0x80040400 in METHOD/PROPERTYGET "ProcessRequest" at parse.pl line ### #### 20030102.134136 I -75547941 RequestProcessor ========= Started Connection ========= 20030102.134136 I -75547941 RequestProcessor Connection opened by app named 'Timer Import' 20030102.134136 E -75547941 CRLInstaller Failed to query registry value. The parameter is incorrect. 20030102.134136 I -75547941 CertVerifier The file does not contain an Authenticode signature. 20030102.134136 I -75547941 RequestProcessor Opening the file in the DoNotCare mode. 20030102.134137 I -898753 QBSDKProcessRequest Application named 'Timer Import' starting requests (process -75547941). 20030102.134137 E -898753 XMLDtdMapper Invalid DOCTYPE 20030102.134137 E -898753 XercesSAXParseManager Invalid DOCTYPE - unable to transform from PUBLIC to SYSTEM 20030102.134137 I -898753 MsgSetHandler Parser error, finishing. 20030102.134137 I -898753 QBSDKProcessRequest Application named 'Timer Import' finishing requests (process -75547941), ret = 1. 20030102.134137 E -75547941 RequestProcessor Process Request error = 80042500, There was an error when parsing the provided XML file. 20030102.134137 I -75547941 RequestProcessor "EndSession" has not been called. 20030102.134137 I -75547941 RequestProcessor "CloseConnection" has not been called.