sap gui scripting bank creation problem (fi01)

Mar 29, 2017 at 05:20 AM


avatar image
Former Member

hi friends,

i try to create bank (sample) through excel .

when i press login button its connect to sap via RFC ,i saw through "SM04" T-Code

no issue to connect sap .i recorded sap gui(.vbs file) then i assign that code for another one macro but it's doesn't work .i attached my excel vba code with variant .

Dim objBAPIControl, objConnection As Object
Dim objTeste As SAPFunctionsOCX.Function
Dim objTable As SAPTableFactoryCtrl.Table
Dim login As Boolean

Public SapGuiAuto, WScript, msgcol
Public objGui  As GuiApplication
Public objConn As GuiConnection
Public objSess As GuiSession
Public objSBar As GuiStatusbar
Public objSheet As Worksheet
Dim W_System
Sub Button2_Click()
Set objBAPIControl = CreateObject("SAP.Functions.unicode")
Set objConnection = objBAPIControl.Connection
objConnection.Client = "500"
objConnection.User = "abap"
objConnection.Language = "EN"
If objConnection.LOGON(0, False) Then
login = True
MsgBox "Login sucessfull."
End If
End Sub
Sub dwonload()
On Error Resume Next
Set objTable = Nothing
objSess.FindById("wnd[0]/tbar[0]/okcd").Text = "FI01"
objSess.FindById("wnd[0]").SendVKey 0
objSess.FindById("wnd[0]/usr/ctxtBNKA-BANKS").Text = "IN"
objSess.FindById("wnd[0]/usr/ctxtBNKA-BANKL").Text = "123-323"
objSess.FindById("wnd[0]/usr/ctxtBNKA-BANKL").CaretPosition = 7
objSess.FindById("wnd[0]/usr/txtBNKA-BANKA").Text = "THOR OF CLASSMATE"
objSess.FindById("wnd[0]/usr/ctxtBNKA-PROVZ").Text = "22"
objSess.FindById("wnd[0]/usr/txtBNKA-STRAS").Text = "FIRST DTRRET"
objSess.FindById("wnd[0]/usr/txtBNKA-ORT01").Text = "CHENNAI"
objSess.FindById("wnd[0]/usr/txtBNKA-BRNCH").Text = "CHENNAI"
objSess.FindById("wnd[0]/usr/txtBNKA-SWIFT").Text = "SWIFTBIS"
objSess.FindById("wnd[0]/usr/txtBNKA-BNKLZ").Text = "123-323"
objSess.FindById("wnd[0]/usr/txtBNKA-BNKLZ").CaretPosition = 7
End Sub
Sub logout1()
Set objConnection = Nothing
Set objBAPIControl = Nothing
Set objTeste = Nothing
Set objTable = Nothing
MsgBox "Logout sucessfull."
End Sub



10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Raymond Giuseppi
Mar 29, 2017 at 07:12 AM

I would suggest an alternative as using the RFC connection to execute BAPI_BANK_CREATE (BUS1011, Bank.Create)

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi raymond,

Thanks for your reply ,I'm new to create VBA and GUI script ,i try with RFC FM to get data from sap it's working perfect but if i want trigger custom t-code to create record in sap via excel VBA ,How can i do this ? that's why i try with standard T-Code "FI01".if you have any idea about my requirement please let me share ..i'm using SAP GUI version 740 Patch level 8 and MS-Office 2007.


Look at a sample like Remote Function Call to SAP System using Microsoft Excel on how to call a BAPI (actually calling the RFC FM which implements the BAPI) Call BAPI_BANK_CREATE and BAPI_TRANSACTION_COMMIT. (Seems you already used such RFC call)

IMHO it's not a good idea/best pratices to execute a transaction with script (smell like an old Batch Input) when a BAPI with a persistent signature is available. Also the script may be different between different users with screens of different sizes?

Skip to Content