web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / error for SAP VBScript...
Power Automate
Answered

error for SAP VBScript compilation error: Unterminated string constant

(0) ShareShare
ReportReport
Posted on by 62

Hi,

I try to use SAP script in PAD,It does not work and get error message as below:

 

C:\Users\U252414\AppData\Local\Temp\Robin\5fvbityrif2.tmp(19, 65) Microsoft VBScript compilation error: Unterminated string constant

 

Below is the SAP code, I just replace some field to variable ,which highlighted in red. Could you pls help check this issue.

 

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
session.findById("wnd[0]/tbar[0]/okcd").text = "/n/OPT/VIM_VA2 - VIM Analytics 7.50 "
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtS_LIFNR-LOW").text = "%Entity%"
session.findById("wnd[0]/usr/txtS_XBLNR-LOW").text = "%invoice%"
session.findById("wnd[0]/usr/ctxtS_BUKRS-LOW").text = "%Vendor%"
session.findById("wnd[0]/usr/ctxtS_BUKRS-LOW").setFocus
session.findById("wnd[0]/usr/ctxtS_BUKRS-LOW").caretPosition = 4
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/usr/cntlCCTRL_MAIN/shellcont/shell/shellcont[0]/shell").pressToolbarButton "EXT004"
session.findById("wnd[1]/usr/cntlCUSTOM_CONTAINER_100/shellcont/shell").setCurrentCell -1,"BITM_DESCR"
session.findById("wnd[1]/usr/cntlCUSTOM_CONTAINER_100/shellcont/shell").selectColumn "BITM_DESCR"
session.findById("wnd[1]/usr/cntlCUSTOM_CONTAINER_100/shellcont/shell").pressColumnHeader "BITM_DESCR"
session.findById("wnd[1]/usr/cntlCUSTOM_CONTAINER_100/shellcont/shell").setCurrentCell -1,"BITM_DESCR"
session.findById("wnd[1]/usr/cntlCUSTOM_CONTAINER_100/shellcont/shell").selectColumn "BITM_DESCR"
session.findById("wnd[1]/usr/cntlCUSTOM_CONTAINER_100/shellcont/shell").pressColumnHeader "BITM_DESCR"
session.findById("wnd[1]/usr/cntlCUSTOM_CONTAINER_100/shellcont/shell").setCurrentCell -1,"BITM_DESCR"
session.findById("wnd[1]/usr/cntlCUSTOM_CONTAINER_100/shellcont/shell").selectColumn "BITM_DESCR"
session.findById("wnd[1]/usr/cntlCUSTOM_CONTAINER_100/shellcont/shell").contextMenu
session.findById("wnd[1]/usr/cntlCUSTOM_CONTAINER_100/shellcont/shell").selectContextMenuItem "&FILTER"
session.findById("wnd[2]/usr/ssub%%_SUBSCREEN_FREESEL:SAPLSSEL:1105/ctxt%%DYN001-LOW").text = "*VIM*"
session.findById("wnd[2]/usr/ssub%%_SUBSCREEN_FREESEL:SAPLSSEL:1105/ctxt%%DYN001-LOW").caretPosition = 5
session.findById("wnd[2]/tbar[0]/btn[0]").press
session.findById("wnd[1]/usr/cntlCUSTOM_CONTAINER_100/shellcont/shell").currentCellColumn = "BITM_DESCR"
session.findById("wnd[1]/usr/cntlCUSTOM_CONTAINER_100/shellcont/shell").selectedRows = "0"
session.findById("wnd[1]/usr/cntlCUSTOM_CONTAINER_100/shellcont/shell").contextMenu
session.findById("wnd[1]/usr/cntlCUSTOM_CONTAINER_100/shellcont/shell").selectContextMenuItem "%%ATTA_EXPORT"
session.findById("wnd[2]/usr/ctxtDY_PATH").text = "C:\Invoice list"
session.findById("wnd[2]/usr/ctxtDY_FILENAME").text = "%invoice%&%Entity%.PDF"
session.findById("wnd[2]/usr/ctxtDY_FILENAME").caretPosition = 19
session.findById("wnd[2]/tbar[0]/btn[0]").press
session.findById("wnd[1]/tbar[0]/btn[12]").press

I have the same question (0)
  • Highboy Profile Picture
    1,185 Super User 2024 Season 1 on at

    Hi
    I am using SAP VBSCRIPT i Power automate desktop without any issuses
    session.findById("wnd[1]/usr/tabsG_SELONETABSTRIP/tabpTAB001/ssubSUBSCR_PRESEL:SAPLSDH4:0220/sub:SAPLSDH4:0220/ctxtG_SELFLD_TAB-LOW[7,24]").text = "%YesterDay%"

    If you try to set the original VB SCRIPT created by SAP into PAD and run it without modifications, do you get the same error?

  • Verified answer
    Sophiegong Profile Picture
    62 on at

    Final update.

    I got the rout cause for the SAP VBScript error.I used wrong variable in script.That I run script with action "for each",But I have not use varible"currentitem" in script,that will cause script error.Then I replace "currentitem" into script, it will work well in this cycle"for each"

    屏幕截图 2022-09-20 112156.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 592

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard