I have started playing around with scripting in
PowerDesigner, and have managed to, by script, connect to
our repository and fetch a model ( With the FindChildByPath
command ). At the same time I am able to create a local
model, in which I reverse engineer a database. All working
fine.

So I now have a RepositoryModel and a Model, and the
question is: How do I 'checkin' this Model to the
RepositoryModel?

I have gotten the CheckInNew method to work, but this only
allows me to make a new model, that doesn't exist in the
repository already, not update the one i fetched from the
repository.

What I am trying to achieve, is to update our reflection of
our SQL server in PD automatically, and all I seem to miss
is to be able to merge the local model with the
repositorymodel.

Note: I am trying to do this with a local and repository
PDM.

option explicit

' To use a user or system datasource, define constant with "ODBC:<datasourcename>"
' -> Const cnxDSN = "ODBC:ASA 9.0 sample"
' To use a datasource file, define constant with the full path to the DSN file
' -> Const cnxDSN = "\\romeo\public\DATABASES\_filedsn\sybase_asa9_sample.dsn"

' use ODBC datasource
Const cnxDSN = "ODBC:datasourceTest"
Const cnxUSR = ""
Const cnxPWD = ""
Const GenDir = "H:\Sybase\"
Const filename = "H:\Sybase\dw_linfo.pdm"
Const ExtFile = "H:\Sybase\extract.pdm"


' Call to main function with the newly created PDM
' This sample use an ASA9 database
Start CreateModel(PdPDM.cls_Model, "|DBMS=Microsoft SQL Server 2008")

Sub Start(pModel)

If (pModel is Nothing) then
output "Unable to create a physical model for selected DBMS"
Exit Sub
End If

InteractiveMode = im_Batch

' Navngiv modellen.
pModel.Name = "dw Linfo"
pModel.Code = "dw_linfo"

' Reverse database phase
' First connect to the database with connection parameters
pModel.ConnectToDatabase cnxDSN, cnxUSR, cnxPWD
' Get the reverse option of the model

Dim pOpt
Set pOpt = pModel.GetPackageOptions()

' Force ODBC Reverse of all listed objects
pOpt.ReversedScript = False
pOpt.ReverseAllTables = true
pOpt.ReverseAllViews = true
pOpt.ReverseAllStorage = true
pOpt.ReverseAllTablespace = False
pOpt.ReverseAllDomain = true
pOpt.ReverseAllUser = true
pOpt.ReverseAllProcedures = False
pOpt.ReverseAllTriggers = true
pOpt.ReverseAllSystemTables = False
pOpt.ReverseAllSynonyms = False
' Go !
pModel.ReverseDatabase
pModel.save(filename)
' close model at the end
'


' Connect til Repos
Dim Repos

Set Repos = RepositoryConnection
Repos.Open "Server","User","Password", "", ""

Dim obj, Checkout
' The model I try to update
set obj = Repos.FindChildByPath("Udvikling/Bibliotek BI (Udvikling)/ArkitekturReferencer/Datawarehouse/Logiske datawarehouse tabeller/dw Linfo", Cls_RepositoryModel)
if not obj is nothing then
output "Object found: " & obj.ClassName + " type: " + obj.ObjectType
end if

' They are of diffrent types - Model and RepositoryModel. Reason for error?
output " type: " + obj.ObjectType
output " type: " + pModel.ObjectType

'pModel.ConsolidateNew obj

'obj.ConsolidateObject pModel.name, 1
'pModel.Consolidate 1


'pModel.Merge obj

'pModel.CheckIn 1

pModel.Close


End Sub