on 01-30-2018 10:15 AM
Hello!
I need some help to fix the following error.
I have a script to map the entities and attributes with a excel spreadsheet.
The first and second loop works fine and mapped the entities and attributes. I can see them in the "Mapping Editor". But in the third round i get the following error.
Dim TargetM, SourceM, TargetEnt, SourceEnt, TargetAtt, ds ,m1, NSE
Dim NTE, NSA, NTA, attm
'Open the Excel Sheet with the mapping information
Set objExcel = CreateObject ("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("C:/...")
'Open the two Models for mapping
set TargetM = OpenModel ("C:\...")
set SoureM = ActiveModel
'Mapping the two Models
Set ds = SourceM.DataSources.CreateNew(cls_DefaultDataSource)
ds.SetNameandCode "Vorsystem_SAP_GP", "Vorsystem"
ds.AddSource(TargetM)
'Loop to create the mappings between the Entities and Attributes
For j = 2 To 100
Set NSE = objWorkbook.Sheets(2).Cells(j, 4)
Set NTE = objWorkbook.Sheets(2).Cells(j, 1)
Set SourceEnt = SourceM.FindChildByName(NSE, PdLDM.cls_entity)
Set TargetEnt = TargetM.FindChildByName(NTE, PdLDM.cls_entity)
Set m1 = ds.createMapping(SourceEnt)
m1.AddSource(TargetEnt)
Set NSA = objWorkbook.Sheets(2).Cells(j, 5)
Set NTA = objWorkbook.Sheets(2).Cells(j, 2)
Set SourceEnt = SourceEnt.FindChildByName(NSE, PdLDM.cls_EntityAttribute)
Set TargetEnt = TargetEnt.FindChildByName(NTE, PdLDM.cls_EntityAttribute)
Set attm = ds.createMapping(SourceAtt)
attm.AddSource(TargetAtt) 'Error
Next
Microsoft VBScript runtime error ->Object requierd: 'attm' (0x800A01A8)
any help, advice, corrections or comments are welcomed!
thanks
You do not define SourceAtt in
Set attm = ds.createMapping(SourceAtt)
I guess correct code should be
Set attm = ds.createMapping(SourceEnt)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I found the mistake. The problem is the formatting of the excel cells.
Does anyone know this problem and its solution
?You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try this script, based on yours:
Dim TargetM, SourceM, TargetEnt, SourceEnt, TargetAtt, ds ,m1, NSE
Dim NTE, NSA, NTA, attm, wBookName, sourcePath, targetPath, dataSourceName, sheet, range, rangeMax
' from https://answers.sap.com/questions/417299/mapping-vb-script-error-object-required-0x800a01a8.html wBookName = "C:\...\Mappings Import.xlsx"
sourcePath = "C:\...\Source.ldm"
targetPath = "C:\...\Target.ldm"
dataSourceName = "Mapping Test" 'Open the two Models for mapping
output "Opening source model " & sourcePath
set SourceM = OpenModel (sourcePath) output "Opening target model " & targetPath
set TargetM = OpenModel (targetPath) 'Mapping the two Models
output "Creating the Data Source - " & dataSourceName
Set ds = TargetM.DataSources.CreateNew(cls_DefaultDataSource)
ds.Name = dataSourceName
ds.SetNameToCode()
' link to source model
ds.AddSource(SourceM) 'Open the Excel Sheet with the mapping information
output "Opening " & wBookName
Set objExcel = CreateObject ("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open(wBookName)
Set sheet = objWorkbook.worksheets(1)
Set range = sheet.usedrange
'get count for loop
rangeMax = range.rows.Count
output "There are " & rangeMax & " rows in the worksheet" 'Loop to create the mappings between the Entities and Attributes
For j = 2 To rangeMax
'output vbtab & " - Processing row " & j
Set NSE = objWorkbook.Sheets(1).Cells(j, 1)
Set NTE = objWorkbook.Sheets(1).Cells(j, 3)
Set SourceEnt = SourceM.FindChildByName(NSE, PdLDM.cls_entity)
Set TargetEnt = TargetM.FindChildByName(NTE, PdLDM.cls_entity) Set m1 = ds.createMapping(TargetEnt)
m1.Name = "source - " & SourceEnt.Name
m1.SetNameToCode()
m1.AddSource(SourceEnt) Set NSA = objWorkbook.Sheets(1).Cells(j, 2)
Set NTA = objWorkbook.Sheets(1).Cells(j, 4)
Set SourceAtt = SourceEnt.FindChildByName(NSA, PdLDM.cls_EntityAttribute)
Set TargetAtt = TargetEnt.FindChildByName(NTA, PdLDM.cls_EntityAttribute) Set attm = ds.createMapping(TargetAtt)
m1.Name = "source - " & SourceAtt.Name
m1.SetNameToCode()
attm.AddSource(SourceAtt) Next output " ** FINISHED **"
' close the workbook
objExcel.workbooks.Close
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.