I am trying to get the table counts from the table and what columns are available in each table. This information I need to get in the Excel sheet with table name, counts, field names. I have generated VBA script. I don't have much access to the SAP GUI. I run SE16
to get the table counts. The below is the script that got generated.
It's very difficult to take the counts one by one entering the table and taking the counts.
I am looking for something to pass the table names as file to the SAP GUI and outputs the results as a file that contains "table name", "counts","field names".
The below code does the login, runs SE16
, enters table QPRS
, presses Enter and then the button Ctrl+F7 to display the number of entries of the table, and do the same for the next tables, TQ43
, TQ43T
, TQ45
and TQ45T
.
If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
Set connection = application.Children(0)
End If
If Not IsObject(session) Then
Set session = connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject application, "on"
End If
session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/txtRSYST-MANDT").text = "900"
session.findById("wnd[0]/usr/txtRSYST-BNAME").text = "12345"
session.findById("wnd[0]/usr/pwdRSYST-BCODE").text = "*****"
session.findById("wnd[0]/usr/pwdRSYST-BCODE").setFocus
session.findById("wnd[0]/usr/pwdRSYST-BCODE").caretPosition = 12
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[0]/okcd").text = "/nse16"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtDATABROWSE-TABLENAME").text = "QPRS"
session.findById("wnd[0]/usr/ctxtDATABROWSE-TABLENAME").caretPosition = 4
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[1]/btn[31]").press
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/okcd").text = "/nse16"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtDATABROWSE-TABLENAME").text = "TQ43"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[1]/btn[31]").press
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/okcd").text = "/nse16"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtDATABROWSE-TABLENAME").text = "TQ43T"
session.findById("wnd[0]/usr/ctxtDATABROWSE-TABLENAME").caretPosition = 5
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[1]/btn[31]").press
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/okcd").text = "/nse16"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtDATABROWSE-TABLENAME").text = "TQ45"
session.findById("wnd[0]/usr/ctxtDATABROWSE-TABLENAME").caretPosition = 4
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[1]/btn[31]").press
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/okcd").text = "/nse16"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtDATABROWSE-TABLENAME").text = "TQ45T"
session.findById("wnd[0]/usr/ctxtDATABROWSE-TABLENAME").caretPosition = 5
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[1]/btn[31]").press
session.findById("wnd[1]/tbar[0]/btn[0]").press