#!c:/perl/bin/perl.exe -w
use strict;
use Win32::OLE;
use Win32::OLE::Variant;
my $schema = {
'Contact' => [
'Birth Date', 'Created', 'Created By Name', 'Email Address', 'Fax Phone #',
'First Name', 'Id', 'Job Title', 'Last Name', 'Updated', 'Updated By Name',
'Work Phone #']
};
my $cfg = "C:/sea/client/OBJECTS/siebel.cfg";
my $sa = Win32::OLE->new("SiebelDataServer.ApplicationObject") or die "failed";
sub x
{
my ($tag, $rc) = @_;
if ($rc != 0) {warn("[$tag] " . $sa->GetLastErrText());}
}
sub main
{
my ($bo, $bc, $key, $field, $moreResults, $rcref);
$rcref = Variant(VT_I2|VT_BYREF, 0);
$sa->LoadObjects($cfg, $rcref); &x("a", $rcref);
$sa->Login("user", "password", $rcref); &x("b", $rcref);
foreach $key (keys(%$schema)) {
$bo = $sa->GetBusObject($key, $rcref); &x("c", $rcref);
$bc = $bo->GetBusComp($key, $rcref); &x("d", $rcref);
foreach $field (@{$schema->{$key}}) {
$bc->ActivateField($field, $rcref); &x("e", $rcref);
}
$bc->ClearToQuery($rcref); &x("f", $rcref);
$bc->SetSearchExpr("[Email Address] IS NOT NULL AND [Last Name] LIKE 'R*'", $rcref);
&x("g", $rcref);
$bc->ExecuteQuery(1, $rcref); &x("h", $rcref);
$moreResults = $bc->FirstRecord($rcref); &x("i", $rcref);
while ($moreResults) {
printf("-----\n");
foreach $field (@{$schema->{$key}}) {
printf ("%40s: %s\n",$field, $bc->GetFieldValue($field, $rcref));
&x("j", $rcref);
}
$moreResults = $bc->NextRecord($rcref); &x("k", $rcref);
}
}
}
&main;
Monday, March 17, 2008
Siebel COM programming with Perl
I wanted to play around with the Siebel COM interface using a dynamic language instead of having to re-compile after every change. I happened to have perl installed on my machine so it was the natural choice. Since google didn't show me any usable hits beforehand and it took a bit of investigation, I'm posting my results here.
Subscribe to:
Post Comments (Atom)
2 comments:
Cool! Great example. I've used Perl for many Siebel related things, but there are very few examples on the web... none that I know of for the COM interface. (recursivetechnology.com)
Great Stuff! I will try something similar with Ruby :)
Post a Comment