Skip to Content
0

Invalid character fail in script recording in BD87

Jun 30, 2017 at 11:08 AM

60

avatar image
Former Member

i am trying to use Script recording to correct BD87 fails where the article has not been included in a vendor EDI response.

The BD87 fail report contains the idoc number (COL1) and what the correct reference should be (COL4). COL2 and COL3 are to and from dates (because i didn't know whether putting "" in both fields was causing the prolem.

The problem is that i am getting "invalid character" - ihave read these Q&As, adapted where suggested but to no avail. Any suggestions?

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

Dim objExcel
Dim objSheet, intRow, i
Set objExcel = GetObject(,"Excel.Application")
Set objSheet = objExcel.ActiveWorkbook.ActiveSheet

For i = 2 to objSheet.UsedRange.Rows.Count
COL1 = Trim(CStr(objSheet.Cells(i, 1).Value)) 'Column1
COL2 = Trim(CStr(objSheet.Cells(i, 2).Value)) 'Column2
COL3 = Trim(CStr(objSheet.Cells(i, 3).Value)) 'Column3
COL4 = Trim(CStr(objSheet.Cells(i, 4).Value)) 'Column4

session.findById("wnd[0]/tbar[0]/okcd").text = "/NBD87"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtSX_DOCNU-LOW").text = COL1
session.findById("wnd[0]/usr/ctxtSX_UPDDA-LOW").text = COL2
session.findById("wnd[0]/usr/ctxtSX_UPDDA-HIGH").text = COL3
session.findById("wnd[0]/usr/ctxtSX_UPDDA-HIGH").setFocus
session.findById("wnd[0]/usr/ctxtSX_UPDDA-HIGH").caretPosition = 0
session.findById("wnd[0]").sendVKey 8
session.findById("wnd[0]/usr/cntlTREE_CONTAINER/shellcont/shell").selectItem "N5","Column1"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER/shellcont/shell").ensureVisibleHorizontalItem "N5","Column1"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER/shellcont/shell").doubleClickItem "N5","Column1"
session.findById("wnd[0]/usr/cntlCUST_200/shellcont/shell").doubleClickCurrentCell
session.findById("wnd[0]/shellcont/shell").selectedNode = "Datarecords"
session.findById("wnd[0]/shellcont/shell").doubleClickNode "Datarecords"
session.findById("wnd[1]").sendVKey 0
session.findById("wnd[0]/shellcont/shell").expandNode "Datarecords"
session.findById("wnd[0]/shellcont/shell").topNode = "IDoc"
session.findById("wnd[0]/shellcont/shell").selectedNode = "000003"
session.findById("wnd[0]/shellcont/shell").doubleClickNode "000003"
session.findById("wnd[0]").sendVKey 5
session.findById("wnd[0]/shellcont/shell").doubleClickNode "000003"
session.findById("wnd[0]").sendVKey 19
session.findById("wnd[0]").sendVKey 19
session.findById("wnd[0]").sendVKey 19
session.findById("wnd[0]/mbar/menu[0]/menu[0]").select
session.findById("wnd[1]").sendVKey 0
session.findById("wnd[0]/usr/tblSAPLEDI5TCTRL_INT_SEG/ctxtINT_SEG-STRING[1,1]").text = COL4
session.findById("wnd[0]/usr/tblSAPLEDI5TCTRL_INT_SEG/ctxtINT_SEG-STRING[1,1]").setFocus
session.findById("wnd[0]/usr/tblSAPLEDI5TCTRL_INT_SEG/ctxtINT_SEG-STRING[1,1]").caretPosition = 0
session.findById("wnd[0]").sendVKey 11
session.findById("wnd[0]").sendVKey 3
session.findById("wnd[0]").sendVKey 3
session.findById("wnd[0]").sendVKey 3
session.findById("wnd[0]").sendVKey 3
session.findById("wnd[0]").sendVKey 3
session.findById("wnd[0]").sendVKey 2
session.findById("wnd[1]").sendVKey 12
session.findById("wnd[0]").sendVKey 8
session.findById("wnd[0]/usr/cntlTREE_CONTAINER/shellcont/shell").selectItem "N7","Column1"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER/shellcont/shell").ensureVisibleHorizontalItem "N7","Column1"
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]").sendVKey 3
session.findById("wnd[0]").sendVKey 3
session.findById("wnd[0]").sendVKey 3

aux=col1 & ” ” & col2 & ” ” & col3 & ” ” & col4
CreateObject(“WScript.Shell”).run(“cmd /c @echo %date% %time% ” & aux & ” >> C:\SCRIPT\PlOrCreationLog.txt”)
next
msgbox “Process Completed”

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

0 Answers