-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathABAP2XLSX.Generator.vbs
205 lines (176 loc) · 7.13 KB
/
ABAP2XLSX.Generator.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
'-Begin-----------------------------------------------------------------
'-
'- Important hint
'- This script is deprecated, please use instead the PowerShell script
'- ABAP2XLSX.Generator.ps1
'-
'-----------------------------------------------------------------------
'-Directives----------------------------------------------------------
Option Explicit
'-Variables-----------------------------------------------------------
Dim xmlDoc, xmlRoot, xmlNodes, xmlNode
Dim Lines()
Dim PrefixOld, PrefixNew, NodeName, NewNodeName, Signal, ClassName
Dim FileName, i, Text, FSO, File
'-Function CorrectNodeName--------------------------------------------
Function CorrectNodeName(NodeName)
'-Variables-------------------------------------------------------
Dim NewNodeName
NewNodeName = Replace(UCase(NodeName), "_EXCEL_", "_")
NewNodeName = Replace(UCase(NewNodeName), "_WORKSHEET_", "_WKS_")
NewNodeName = Replace(UCase(NewNodeName), "_CONVERTER", "_CONV")
NewNodeName = Replace(UCase(NewNodeName), "_CONDITIONAL", "_COND")
NewNodeName = Replace(UCase(NewNodeName), "_CONDITION", "_COND")
NewNodeName = Replace(UCase(NewNodeName), "_COMPONENT", "_COMP")
NewNodeName = Replace(UCase(NewNodeName), "_PROTECTION", "_PROT")
NewNodeName = Replace(UCase(NewNodeName), "MAPPING", "MAP")
If UCase(Right(NewNodeName, 14)) = "_NUMBER_FORMAT" Then
NewNodeName = Left(NewNodeName, Len(NewNodeName) - 14) + "_NUMFMT"
End If
CorrectNodeName = NewNodeName
End Function
'-Main----------------------------------------------------------------
PrefixOld = "Z"
PrefixNew = "/MNS/MPA_"
Set xmlDoc = CreateObject("MSXML.DOMDocument")
FileName = "ABAP2XLSX_V_7_0_3.nugg"
If IsObject(xmlDoc) Then
xmlDoc.Async = False
If xmlDoc.Load(FileName) Then
Set xmlRoot = xmlDoc.documentElement
Set xmlNodes = xmlRoot.childNodes
ReDim Preserve Lines(1)
Lines(0) = "Line;Type;OldName;ClassName;NewName;Length;Signal"
For Each xmlNode In xmlNodes
ReDim Preserve Lines(UBound(Lines) + 1)
ClassName = ""
Select Case UCase(xmlNode.nodeName)
Case "CLAS"
NodeName = xmlNode.getAttribute("CLSNAME")
If UCase(Left(NodeName, 4)) = PrefixOld + "CL_" Then
NewNodeName = PrefixNew + "CL_" + Right(NodeName, _
Len(NodeName) - Len(PrefixOLd) - 3)
ElseIf UCase(Left(NodeName, 4)) = PrefixOld + "CX_" Then
NewNodeName = Left(PrefixNew, 5) + "CX_" + _
Right(PrefixNew, Len(PrefixNew) - 5) + _
Right(NodeName, Len(NodeName) - 4)
End If
NewNodeName = CorrectNodeName(NewNodeName)
If Len(NewNodeName) > 30 Then
Signal = "1"
Else
Signal = "0"
End If
Case "DOMA"
NodeName = xmlNode.getAttribute("DOMNAME")
NewNodeName = PrefixNew + Right(NodeName, _
Len(NodeName) - Len(PrefixOld))
NewNodeName = CorrectNodeName(NewNodeName)
If Len(NewNodeName) > 30 Then
Signal = "1"
Else
Signal = "0"
End If
Case "DTEL"
NodeName = xmlNode.getAttribute("ROLLNAME")
NewNodeName = PrefixNew + Right(NodeName, _
Len(NodeName) - Len(PrefixOld))
NewNodeName = CorrectNodeName(NewNodeName)
If Len(NewNodeName) > 30 Then
Signal = "1"
Else
Signal = "0"
End If
Case "INTF"
NodeName = xmlNode.getAttribute("CLSNAME")
If UCase(Left(NodeName, 4)) = PrefixOld + "IF_" Then
NewNodeName = PrefixNew + "IF_" + Right(NodeName, _
Len(NodeName) - Len(PrefixOld) - 3)
End If
NewNodeName = CorrectNodeName(NewNodeName)
If Len(NewNodeName) > 30 Then
Signal = "1"
Else
Signal = "0"
End If
Case "MSAG"
NodeName = xmlNode.getAttribute("ARBGB")
NewNodeName = PrefixNew + Right(NodeName, _
Len(NodeName) - Len(PrefixOld))
NewNodeName = CorrectNodeName(NewNodeName)
If Len(NewNodeName) > 20 Then
Signal = "1"
Else
Signal = "0"
End If
Case "PROG"
NodeName = xmlNode.getAttribute("NAME")
NewNodeName = PrefixNew + Right(NodeName, _
Len(NodeName) - Len(PrefixOld))
NewNodeName = CorrectNodeName(NewNodeName)
If Len(NewNodeName) > 30 Then
Signal = "1"
Else
Signal = "0"
End If
Case "TABL"
NodeName = xmlNode.getAttribute("TABNAME")
NewNodeName = PrefixNew + Right(NodeName, _
Len(NodeName) - Len(PrefixOld))
NewNodeName = CorrectNodeName(NewNodeName)
Select Case UCase(xmlNode.getAttribute("TABCLASS"))
Case "INTTAB"
ClassName = "INTTAB"
If Len(NewNodeName) > 30 Then
Signal = "1"
Else
Signal = "0"
End If
Case "TRANSP"
ClassName = "TANSP"
If Len(NewNodeName) > 16 Then
Signal = "1"
Else
Signal = "0"
End If
End Select
Case "TTYP"
NodeName = xmlNode.getAttribute("TYPENAME")
NewNodeName = PrefixNew + Right(NodeName, _
Len(NodeName) - Len(PrefixOld))
NewNodeName = CorrectNodeName(NewNodeName)
If Len(NewNodeName) > 30 Then
Signal = "1"
Else
Signal = "0"
End If
Case "XSLT"
NodeName = xmlNode.getAttribute("XSLTDESC")
NewNodeName = PrefixNew + Right(NodeName, _
Len(NodeName) - Len(PrefixOld))
NewNodeName = CorrectNodeName(NewNodeName)
If Len(NewNodeName) > 30 Then
Signal = "1"
Else
Signal = "0"
End If
End Select
Lines(UBound(Lines)) = CStr(UBound(Lines) - 1) & ";" & _
UCase(xmlNode.nodeName) & ";" & NodeName & ";" & _
ClassName & ";" & NewNodeName & ";" & _
CStr(Len(NewNodeName)) & ";" & Signal
Next
End If
Set xmlDoc = Nothing
End If
Text = Lines(0) & vbCrLf
For i = UBound(Lines) To 2 Step -1
Text = Text & Lines(i) & vbCrLf
Next
Set FSO = CreateObject("Scripting.FileSystemObject")
If IsObject(FSO) Then
Set File = FSO.CreateTextFile(FileName & ".csv", True)
File.Write Text
File.Close
End If
'-End-------------------------------------------------------------------