Skip to Content
0

Automate enrtry FBCJ t-code from excel list

Jun 12, 2017 at 11:23 AM

46

avatar image

Dear Experts,

Really need help (newbie in programming). I have VBS attached to automate entry the SAP cash journal FBCJ. I write the script attached just based on seeing example and try to make my own. but not working. every time I run the script from SAP Playback it keep showing me error massage type mismatch: worksheet:-. truly I don't know what it's mean.

here is the script:

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
REM ADDED BY EXCEL *************************************

'Telling it that once it has found the header row that it needs to move to the next row

If Book2("Sheet1").Cells(R, c) = "Business Transaction" Then
R = R + 1
End If

'Telling it that it needs to keep going until it finds an empty row

Do Until Book2("Sheet1").Cells(R, c) = ""


session.findById("wnd[0]/tbar[0]/btn[83]").press
session.findById("wnd[0]/usr/tabsF_TABSTRIP/tabpTAB1/ssubF_SUBSCREEN:SAPMFCJ0:0110/tblSAPMFCJ0FTCJ_E_POSTINGS/ctxtISCJ_E_POSTINGS-TRANSACT_NAME[0,0]").text = Book2("Sheet1").Cells(R, 1).Value
session.findById("wnd[0]/usr/tabsF_TABSTRIP/tabpTAB1/ssubF_SUBSCREEN:SAPMFCJ0:0110/tblSAPMFCJ0FTCJ_E_POSTINGS/ctxtISCJ_E_POSTINGS-H_PAYMENTS[1,0]").text = Book2("Sheet1").Cells(R, 2).Value
session.findById("wnd[0]/usr/tabsF_TABSTRIP/tabpTAB1/ssubF_SUBSCREEN:SAPMFCJ0:0110/tblSAPMFCJ0FTCJ_E_POSTINGS/ctxtISCJ_E_POSTINGS-TAX_CODE[4,0]").text = Book2("Sheet1").Cells(R, 3).Value
session.findById("wnd[0]/usr/tabsF_TABSTRIP/tabpTAB1/ssubF_SUBSCREEN:SAPMFCJ0:0110/tblSAPMFCJ0FTCJ_E_POSTINGS/ctxtISCJ_E_POSTINGS-GL_ACCOUNT[5,0]").text = Book2("Sheet1").Cells(R, 4).Value
session.findById("wnd[0]/usr/tabsF_TABSTRIP/tabpTAB1/ssubF_SUBSCREEN:SAPMFCJ0:0110/tblSAPMFCJ0FTCJ_E_POSTINGS/ctxtISCJ_E_POSTINGS-POSITION_TEXT[6,0]").text = Book2("Sheet1").Cells(R, 5).Value
session.findById("wnd[0]/usr/tabsF_TABSTRIP/tabpTAB1/ssubF_SUBSCREEN:SAPMFCJ0:0110/tblSAPMFCJ0FTCJ_E_POSTINGS/ctxtISCJ_E_POSTINGS-POSTING_DATE[7,0]").text = Book2("Sheet1").Cells(R, 6).Value
session.findById("wnd[0]/usr/tabsF_TABSTRIP/tabpTAB1/ssubF_SUBSCREEN:SAPMFCJ0:0110/tblSAPMFCJ0FTCJ_E_POSTINGS/ctxtISCJ_E_POSTINGS-DOCUMENT_DATE[10,0]").text = Book2("Sheet1").Cells(R, 7).Value
session.findById("wnd[0]/usr/tabsF_TABSTRIP/tabpTAB1/ssubF_SUBSCREEN:SAPMFCJ0:0110/tblSAPMFCJ0FTCJ_E_POSTINGS/txtISCJ_E_POSTINGS-DOCUMENT_NUMBER[11,0]").text = Book2("Sheet1").Cells(R, 8).Value
session.findById("wnd[0]/usr/tabsF_TABSTRIP/tabpTAB1/ssubF_SUBSCREEN:SAPMFCJ0:0110/tblSAPMFCJ0FTCJ_E_POSTINGS/txtISCJ_E_POSTINGS-ALLOC_NMBR[13,0]").text = Book2("Sheet1").Cells(R, 9).Value
session.findById("wnd[0]/usr/tabsF_TABSTRIP/tabpTAB1/ssubF_SUBSCREEN:SAPMFCJ0:0110/tblSAPMFCJ0FTCJ_E_POSTINGS/ctxtISCJ_E_POSTINGS-KOSTL[16,0]").text = Book2("Sheet1").Cells(R, 11).Value
session.findById("wnd[0]/usr/tabsF_TABSTRIP/tabpTAB1/ssubF_SUBSCREEN:SAPMFCJ0:0110/tblSAPMFCJ0FTCJ_E_POSTINGS/txtISCJ_E_POSTINGS-TEXT1[17,0]").text = Book2("Sheet1").Cells(R, 12).Value
session.findById("wnd[0]/usr/tabsF_TABSTRIP/tabpTAB1/ssubF_SUBSCREEN:SAPMFCJ0:0110/tblSAPMFCJ0FTCJ_E_POSTINGS/txtISCJ_E_POSTINGS-TEXT2[18,0]").text = Book2("Sheet1").Cells(R, 13).Value
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[0]/btn[83]").press

R = R + 1

LOOP

and this is the excel data list I intend to copy to FBCJ :

start from A1 cell.

l7o4d.png (34.2 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers