Dim objApp As Object
Dim objModel As Object
Dim objDataSource As Object
Dim objQuery As Object
Dim objCube As Object

Dim filename as String
Dim folder as String
Dim logfile As String


Sub Main ()
    On Error Resume Next

    folder = "C:\GlobalCube\System\AUDEV_CARIT\Models"
    filename = "s_offene_auftraege.pyj"
    logfile = "C:\GlobalCube\Tasks\config\models\s_offene_auftraege.pyj.log"

    folder = GetField(Command, 1, ",")
    filename = GetField(Command, 2, ",")
    logfile = GetField(Command, 3, ",")

    Set objApp = CreateObject("IBMCognosTransformer.ApplicationCtrl.1")
    Set objModel = objApp.OpenModel(folder + "\" + filename)
   
    Open logfile for Output as #1

    Set objCube = objModel.Cubes.Item(1)
    Write #1, objCube.MDCFile

    Write #1, "--"
    For i = 1 to objModel.DataSources.Count
        Set objDataSource = objModel.DataSources.Item(i)

        If objDataSource.Type = 38 Then
            rem Package
            Write #1, "[", objDataSource.Name, "]"
            For j = 1 to objDataSource.Queries.Count
                Set objQuery = objDataSource.Queries.Item(j)
                Write #1, objQuery.Name 
            Next
            Exit For
        End If
        If objDataSource.Type = 6 Then
           Write #1, objDataSource.LocalPath
        Else
           Write #1, objDataSource.Name
        End If     
    Next

    Close #1   
    objModel.Close
    Set objQuery = Nothing
    Set objDataSource = Nothing
    Set objModel = Nothing
    Set objApp = Nothing
End Sub
