Consulting

Results 1 to 2 of 2

Thread: Siebel

  1. #1
    VBAX Expert CatDaddy's Avatar
    Joined
    Jun 2011
    Posts
    581
    Location

    Siebel

    I found this code at the following website:
    http://it.toolbox.com/blogs/siebel-a...a-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:
    [VBA]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[/VBA]
    ------------------------------------------------
    Happy Coding my friends

  2. #2
    VBAX Expert CatDaddy's Avatar
    Joined
    Jun 2011
    Posts
    581
    Location
    something like this?
    [VBA]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[/VBA]
    ------------------------------------------------
    Happy Coding my friends

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •