avatar image
Former Member

sap gui scripting bank creation problem (fi01)

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



Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • 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)

    Add comment
    10|10000 characters needed characters exceeded

    • 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