PDA

View Full Version : Siebel



CatDaddy
08-28-2012, 09:56 AM
I found this code at the following website:
http://it.toolbox.com/blogs/siebel-answers/example-siebel-scripting-through-ms-excel-siebel-com-data-server-26861

This cycles through records and prints them to excel, what i am trying to do if find records and update certain fields based on values in a spreadsheet and I am wondering if it can be accomplished in a similiar manner:
Option Explicit

Public oSiebelApp As Object
Public bSiebelLoaded As Boolean

Sub TestSiebel()

On Error GoTo SiebelTestError

'variables
Dim oLOVBO As Object
Dim oLOVBC As Object
Dim sEnv As String
Dim sUserName As String
Dim sPassword As String
Dim ErrCode As Integer
Dim sSearchExpr As String
Dim sErrCode As String
Dim bIsRecord As Boolean
Dim nCounter As Integer
Dim AllView As Integer
Dim ForwardOnly As Integer
Dim sValue As String
'initialize variables
sEnv = "D:\sia77\client\bin\enu\publicsector.cfg,Local"
sUserName = "joshuaw"
sPassword = "joshuaw"
nCounter = 0
AllView = 3
ForwardOnly = 1
'initialize the siebel application
If Not bSiebelLoaded Then
Set oSiebelApp = GetObject("", "SiebelDataServer.ApplicationObject")
oSiebelApp.LoadObjects sEnv, ErrCode
If ErrCode <> 0 Then
MsgBox "Error loading application: " & ErrCode
Resume SiebelTestError
End If
'login to the application
oSiebelApp.Login sUserName, sPassword, ErrCode
If ErrCode <> 0 Then
MsgBox "Error logging in: " & ErrCode
Resume SiebelTestError
End If
bSiebelLoaded = True
End If
'get the LOV business object
Set oLOVBO = oSiebelApp.GetBusObject("List Of Values", ErrCode)
If ErrCode <> 0 Then
MsgBox "Error getting business object: " & ErrCode
Resume SiebelTestError
End If
'get the LOV business component
Set oLOVBC = oLOVBO.GetBusComp("List Of Values", ErrCode)
If ErrCode <> 0 Then
MsgBox "Error getting business component: " & ErrCode
Resume SiebelTestError
End If
'query the LOV bc
With oLOVBC
.ActivateField "Type", ErrCode
If ErrCode <> 0 Then
MsgBox "Error activating field: " & ErrCode
Resume SiebelTestError
End If
.ActivateField "Value", ErrCode
If ErrCode <> 0 Then
MsgBox "Error activating field: " & ErrCode
Resume SiebelTestError
End If
.ActivateField "Active", ErrCode
If ErrCode <> 0 Then
MsgBox "Error activating field: " & ErrCode
Resume SiebelTestError
End If
.ClearToQuery ErrCode
If ErrCode <> 0 Then
MsgBox "Error ClearToQuery: " & ErrCode
Resume SiebelTestError
End If
.SetViewMode AllView, ErrCode
If ErrCode <> 0 Then
MsgBox "Error SetViewMode: " & ErrCode
Resume SiebelTestError
End If
sSearchExpr = "[Type] = " & Chr(34) & "ACCNT_PRD_SEQ_CD" & Chr(34) & _
" AND [Active] = " & Chr(34) & "Y" & Chr(34)
.SetSearchExpr sSearchExpr, ErrCode
If ErrCode <> 0 Then
MsgBox "Error SetSearchExpr: " & ErrCode
Resume SiebelTestError
End If
.ExecuteQuery ForwardOnly, ErrCode
If ErrCode <> 0 Then
MsgBox "Error ExecuteQuery: " & ErrCode
Resume SiebelTestError
End If
bIsRecord = .FirstRecord(ErrCode)
If ErrCode <> 0 Then
MsgBox "Error FirstRecord: " & ErrCode
Resume SiebelTestError
End If
While bIsRecord
'get the LOV value
sValue = .GetFieldValue("Value", ErrCode)
If ErrCode <> 0 Then
MsgBox "Error GetFieldValue: " & ErrCode
Resume SiebelTestError
End If
nCounter = nCounter + 1
'write the LOV value to spreadsheet
Range("A" & CStr(nCounter)).Select
Range("A" & CStr(nCounter)).Value = sValue
bIsRecord = .NextRecord(ErrCode)
If ErrCode <> 0 Then
MsgBox "Error NextRecord: " & ErrCode
Resume SiebelTestError
End If
Wend
End With
MsgBox "Finished!"
Exit Sub
SiebelTestError:
sErrCode = oSiebelApp.GetLastErrText
MsgBox "Unhandled Exception occured: " & sErrCode, vbCritical, "Error"
Set oLOVBC = Nothing
Set oLOVBO = Nothing
Err.Raise 550
Exit Sub
End Sub

CatDaddy
08-28-2012, 10:41 AM
something like this?
While bIsRecord
'get the LOV value
sValue = .GetFieldValue("Value", ErrCode)
If ErrCode <> 0 Then
MsgBox "Error GetFieldValue: " & ErrCode
Resume SiebelTestError
End If

nCounter = nCounter + 1

'If sValue <> Range("A" & nCounter).Value Then
'.SetFieldValue "Value", Range("A" & nCounter).Value
'End If

bIsRecord = .NextRecord(ErrCode)
If ErrCode <> 0 Then
MsgBox "Error NextRecord: " & ErrCode
Resume SiebelTestError
End If
Wend