Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

sap gui scripting bank creation problem (fi01)

Former Member
0 Kudos

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()
'session.FindById("wnd[0]").Maximize
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").SetFocus
objSess.FindById("wnd[0]/usr/ctxtBNKA-BANKL").CaretPosition = 7
objSess.FindById("wnd[0]/tbar[0]/btn[0]").Press
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").SetFocus
objSess.FindById("wnd[0]/usr/txtBNKA-BNKLZ").CaretPosition = 7
objSess.FindById("wnd[0]/tbar[0]/btn[11]").Press
objSess.FindById("wnd[0]/tbar[0]/btn[3]").Press
End Sub
Sub logout1()
Set objConnection = Nothing
Set objBAPIControl = Nothing
Set objTeste = Nothing
Set objTable = Nothing
MsgBox "Logout sucessfull."
End Sub


Thanks

raja

3 REPLIES 3

raymond_giuseppi
Active Contributor
0 Kudos

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

0 Kudos

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.

0 Kudos

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?