Find the internal name of a column in a grid control
In order to use SAP GUI scripting methods or native control methods for the SAP grid control you will often need the internal column names, for example "AUFNR" for the column "Order". Here we describe three possible ways to ascertain these internal names.
Solution 1: Use the SAP GUI scripting recorder
Then change the width of each column for which you want to find
out the name. Stop the recording and display the generated .vbs file; it
will contain the internal column names. Example:
The column names in this example are AUFNR, AUART,GSTRP, KTEXT.
Solution 2: Use a SAP GUI trace
Then start the transaction so that the grid is displayed. Switch off the trace and display the trace file. It will contain lines of the following kind:
Here you see the internal column names and the corresponding column titles.
Solution 3: Use the GuiXT "Native control Interface"
The "Native conrol interface" is available in GuiXT Controls version 2019 Q1 1 and above. You can use it to write a small helper function that returns the column names and titles.
Add the following Visual Basic function in one of your VB.NET dlls in a suitable class, e.g. dll "utilities.dll" and class "grid":
' return internal column names Public Function DevHelpColumnNames() As String Dim gridview As GridView = guixt.getcontrol("grid") If gridview Is Nothing Then Return "Grid not found" End If Dim msg As String = "" For k As Integer = 1 To gridview.GetColCount() msg &= "// " & gridview.GetColIDFromPos(k) & vbTab _ & OCXUTF8(gridview.GetColText(k)) & vbCrLf Next Return msg End Function Private Function OCXUTF8(str As String) As String Return System.Text.Encoding.UTF8.GetChars _ (System.Text.Encoding.Default.GetBytes(str)) End Function
Add a GuiXT button in the SAP grid screen which calls up the "DevHelpColumnNames" function via an InputScript:
pushbutton (toolbar) "Show column names" process="show_column_names.txt"
The InputScript (see below) will also insert the column names into the Windows clipboard so that you can paste the names into your script or VB program:
/ Development only: show internal column names
Message "&V[column_names]" title="Column names Insert via Ctrl+V"
// copy to Windows clipboard for script insertion
CopyText fromText="column_names" -toClipboard