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 / Power Automate desktop...
Power Automate
Unanswered

Power Automate desktop and sap Scripting, (VBS)

(0) ShareShare
ReportReport
Posted on by 19

Dears

I am training to automate sap process to attach documents via transaction code FB03 add attachment . but when recording the steps with SAP with the VBS and taking the script in (Run VBScript) in power automate it gives me syntax error 

the below is the script recorded from SAP

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 = "fb03"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/txtRF05L-BELNR").text = "1726000004"
session.findById("wnd[0]/usr/ctxtRF05L-BUKRS").text = "1000"
session.findById("wnd[0]/usr/ctxtRF05L-BUKRS").setFocus
session.findById("wnd[0]/usr/ctxtRF05L-BUKRS").caretPosition = 4
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/titl/shellcont/shell").pressContextButton "%GOS_TOOLBOX"

 

the main issue is in the last sentence

session.findById("wnd[0]/titl/shellcont/shell").pressContextButton "%GOS_TOOLBOX"

 

i can not find why it is not accepting it

Categories:
I have the same question (0)
  • AS-06081019-0 Profile Picture
    1,736 Super User 2024 Season 1 on at

    @Mona_Sultan  Try using delay

  • Mona_Sultan Profile Picture
    19 on at

    Dear Mr Ankesh 

    can you tell me how to use delay 

  • AS-06081019-0 Profile Picture
    1,736 Super User 2024 Season 1 on at

    In VB script, use this wscript.sleep 6000

    The script will wait 60 seconds an then continue the code.

     

    My recommendation would to use Power automate desktop to automate, rather than generating a vbs from SAP GUI recording and then running it form PAD. For reference: https://learn.microsoft.com/en-us/power-automate/guidance/rpa-sap-playbook/creating-sap-desktop-flow-action-based-gui


    Thanks

    Ankesh

  • Mona_Sultan Profile Picture
    19 on at

    Dear Ankesh

    i already tried to automate the process with ui element but the button to press and attach the document does not make the action that is why i am trying to use vbs

  • AS-06081019-0 Profile Picture
    1,736 Super User 2024 Season 1 on at

    use sendkeys. It should work

  • RF_Dante Profile Picture
    5 on at

    @Mona_Sultan This is due to the limitation of PAD, % is reserved to be only used to call variables within PAD. Unfortunately, I am also stuck at this stage. Sending Keys and UI elements within PAD haven't been very robust replacements to SAP Scripts.

  • natalia Profile Picture
    26 on at

    Try using %% instead of a single %:

    ex-pad.jpg

    I hope this helps 🙂

  • RF_Dante Profile Picture
    5 on at

    Perfect!

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