如何通过 VB 将扩展属性添加到数据项



我正在尝试通过VBS将Excel电子表格导入PD来创建CDM。

1 - 加载电子表格 2 - 创建清洁发展机制 3 - 创建具有扩展属性的数据项。

我可以加载和创建 CDM,并创建数据项,只要我没有扩展属性,但是我无法在 VBS 中创建扩展属性 - 但需要创建扩展属性才能加载电子表格的其余部分。任何想法。

代码当前如下所示:

> Option Explicit
> 
> InteractiveMode = im_Dialog
> 
> Dim Model, objExcel, objWorkbook, intRow, LogFile, lobj, MyExa Set
> Model = ActiveModel Dim MyModel, t, r, sym set MyModel =
> CreateModel(PdCDM.Cls_Model,"DBMS=SYASA12")
> 
> 
> Set objExcel = CreateObject("Excel.Application") Set objWorkbook =
> objExcel.Workbooks.Open ("C:Users Models9.
> DictionaryDataDictionaryTestImport.xlsx")
> 
> intRow = 2
> 
> DIM Name, Stewards, LongDescription, ParentCategory,
> DomainSubCategory,  BusinessUnit, BusinessUnitArea,
> BusinessUnitDepartment, Calculations, DataOwner, ValidationRule,
> DataQualityBusinessRules, Format, SourceSystemName, 
> GoldenSourceSystem, ElementType DIM v_tp
> 
> 
> Do Until objExcel.Cells(intRow,1).Value = ""    Name              = 
> objExcel.Cells(intRow, 1).Value    Stewards       =  objExcel.Cells(intRow,
> 2).Value    LongDescription       =  objExcel.Cells(intRow, 3).Value   
> ParentCategory    =  objExcel.Cells(intRow, 4).Value   
> DomainSubCategory =  objExcel.Cells(intRow, 5).Value   
> BusinessUnit      =  objExcel.Cells(intRow, 6).Value   
> BusinessUnitArea          =  objExcel.Cells(intRow, 7).Value   
> BusinessUnitDepartment    =  objExcel.Cells(intRow, 8).Value   
> Calculations      =  objExcel.Cells(intRow, 9).Value    DataOwner     = 
> objExcel.Cells(intRow, 10).Value    DataQualityBusinessRules  = 
> objExcel.Cells(intRow, 11).Value    ValidationRule    = 
> objExcel.Cells(intRow, 12).Value    Format        =  objExcel.Cells(intRow,
> 13).Value    SourceSystemName         =  objExcel.Cells(intRow, 14).Value   
> GoldenSourceSystem    =  objExcel.Cells(intRow, 15).Value   
> ElementType   =  objExcel.Cells(intRow, 16).Value
>        Set t=MyModel.dataitems.CreateNew()
>        t.Name             =  objExcel.Cells(intRow, 1).Value
>     CreateAttributes t
>       Logger LogFile, Year(Date) & "-" & Month(Date) & "-" & Day(Date) & " " & Time & " - Object: " & name
>        intRow = intRow + 1    loop
>        'Create Data Items For idx = 1 to 12
>     Next
>      
>       'Log file Sub Logger (LogFilename, LogText)     Dim fso     Dim LogFile         Set fso = CreateObject("Scripting.FileSystemObject")    Set
> LogFile = fso.OpenTextFile(LogFilename, 8, True)  LogFile.WriteLine
> LogText    End Sub
> 
> 
> Function CreateAttributes(t)  Dim attr  Set attr =
> t.CreateObject(Pdcdm.cls_Attribute)    t=MyModel.dataitems.CreateNew()
> attr.Name = "ID"  attr.Code = "ID"  attr.DataType = "int" 
> attr.Persistent = True  attr.PersistentCode = "ID" 
> attr.PersistentDataType = "I"  attr.PrimaryIdentifier = True  Set attr
> = t.CreateObject(Pdcdm.cls_Attribute)  attr.Name = "Name"  attr.Code = "Name"  attr.DataType = "String"  attr.Persistent = True 
> attr.PersistentCode = "NAME"  attr.PersistentDataType = "A30"
> 
>  CreateAttributes = True End Function

我想你想设置一个与你选择的Sybase SQL Anywhere 12DBMS相关的扩展属性。

你应该把它写成:

obj.设置扩展属性"SYASA12。强制数据类型",值

我猜如果你不指定目标代码,它会假设扩展属性是在当前模型中定义的,而不是在某个外部模型/目标中定义的。

.. 事实上,引用"SAP PowerDesigner Scripting"(安装目录中的 pdvbs.chm(:

更改扩展属性的值,由其标识 限定名 - 以 定义它的生成目标对象的代码。为 例如:"MyGenerationTarget.MyExtendedAttribute"。

在交付的目标中,这被写为obj.SetExtendedAttribute "%CurrentTargetCode%.CastDataType", value,其中%CurrentTargetCode%在准备和执行 VBscript 之前被实际的目标代码替换。

如果扩展属性不是文本类型,则可以使用 SetExtendedAttributeText 进行尝试,并使用从文本到实际属性类型的自动转换。

相关内容

  • 没有找到相关文章

最新更新