Hi,
I managed to get the field names of the table I got when I'm using the FBL3N transaction in SAP.
To do so please find below my code:
Sub Get_Column_ID()
Application.ScreenUpdating = False
On Error Resume Next
Dim SapGuiAuto, objGui
Dim strConnection, strTransaction, session, openedtransaction
Dim i, j As Long, colOrd_ctn As Long, lastRow As Long
Dim msg
Set SapGuiAuto = GetObject("SAPGUI")
Set objGui = SapGuiAuto.GetScriptingEngine
Set strConnection = objGui.Children(i + 0)
Set strTransaction = strConnection.Children(i + 0)
For i = 0 To strConnection.Children.Count - 1
If strConnection.Children(i + 0).info.Transaction = "FBL3N" Then
Set openedtransaction = strConnection.Children(i + 0)
Let colOrd_ctn = openedtransaction.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").columnOrder.Count
ReDim colOrd_arr(0 To colOrd_ctn - 1)
For j = 0 To colOrd_ctn - 1
colOrd_arr(j) = openedtransaction.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").columnOrder.Item(j)
msg = msg & "Field " & j & ": " & colOrd_arr(j) & vbCrLf & vbCrLf
Next j
Else
End If
Next i
MsgBox msg
End Sub
The MsgBox gets me the full list of the fields.
My question is as follow: is it possible to modify the order of the fields using VBA? Is it also possible to add some extra fields using VBA? (i.e if I want to add the field "BUDAT" in column 11, how can I code that in VBA?)
Your help will be much appreciated!
Request clarification before answering.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.