Renaming Fields
Forums
Hi Brian
I have imported multiple SAP outputs. I am finding that the column headings are in German, but I know what each if them mean. I was wondering is there a script of a way to rename each of the fields, if field manipulation prevents change of column names.
Thank you
Regards
Aveen
Renaming fields
Hi Aveen, below is an example piece of code that will rename fields. You would need a new db.TableDef.NewField section for each field you want to change. The script below will change three fields, one a date, one numerica and one is character. I have justed added 1 to the end of the field name. Hopefully this will help you out.
Sub Main
Call ModifyField() 'General Ledger-GL.IMD
End Sub
' Modify Field
Function ModifyField
Set db = Client.OpenDatabase("General Ledger-GL.IMD")
Set task = db.TableManagement
Set field = db.TableDef.NewField
field.Name = "PERIOD1" 'new field name
field.Description = ""
field.Type = WI_NUM_FIELD 'numeric field
field.Equation = ""
field.Decimals = 0
task.ReplaceField "PERIOD", field 'old field name
task.PerformTask
Set field = db.TableDef.NewField
field.Name = "DATE1" 'new field name
field.Description = ""
field.Type = WI_DATE_FIELD 'date field
field.Equation = "YYYYMMDD"
task.ReplaceField "DATE", field 'old field name
task.PerformTask
Set field = db.TableDef.NewField
field.Name = "SOURCE1" 'new field name
field.Description = ""
field.Type = WI_CHAR_FIELD 'character field
field.Equation = ""
field.Length = 2
task.ReplaceField "SOURCE", field 'old field name
task.PerformTask
Set task = Nothing
Set db = Nothing
Set field = Nothing
End Function
Hi Elías,
Hi Elías,
There is a function in the Progract Management object that will allow you to do this. Here is some example code. Your database should be closed when doing this or else IDEA will probably give you an error.
Brian
Sub Main
Set task = Client.ProjectManagement
task.RenameDatabase "Old Name.IMD", "New Name.IMD"
Set task = Nothing
End Sub
looks interesting. the other
looks interesting. the other day I was thinking of a method that would rename databases to a standard name so that generic scrips can be run with these renamed databases. In terms of SAP databases for different years appear to have different prefixes like A_TXW_TABLE1, B_TXW_TABLE2 which could be clensed so that standard scripts will work...
Hi Aveen, I am not sure what
Hi Aveen, I am not sure what you mean by the field manipulation preventing you changing the column names, you should be able to do it via the field manipulation but you can also change column names by a script. I don't have access to IDEA right now but I will post the code on how to change a field name tonight.