Skip to main content

Notifications

Community site session details

Community site session details

Session Id : ITue4TVpF2BulK6W3gXJm0
Power Automate - General Discussion
Unanswered

Power Automate desktop and sap Scripting, (VBS)

Like (0) ShareShare
ReportReport
Posted on 22 Sep 2022 10:07:58 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

  • RF_Dante Profile Picture
    5 on 20 Oct 2023 at 12:17:38
    Re: Power Automate desktop and sap Scripting, (VBS)

    Perfect!

  • natalia Profile Picture
    26 on 29 Sep 2023 at 16:39:08
    Re: Power Automate desktop and sap Scripting, (VBS)

    Try using %% instead of a single %:

    ex-pad.jpg

    I hope this helps 🙂

  • RF_Dante Profile Picture
    5 on 29 Jun 2023 at 12:58:02
    Re: Power Automate desktop and sap Scripting, (VBS)

    @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.

  • AS-06081019-0 Profile Picture
    1,736 Super User 2024 Season 1 on 26 Sep 2022 at 12:24:14
    Re: Power Automate desktop and sap Scripting, (VBS)

    use sendkeys. It should work

  • Mona_Sultan Profile Picture
    19 on 23 Sep 2022 at 16:09:22
    Re: Power Automate desktop and sap Scripting, (VBS)

    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 23 Sep 2022 at 07:38:30
    Re: Power Automate desktop and sap Scripting, (VBS)

    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 23 Sep 2022 at 07:11:50
    Re: Power Automate desktop and sap Scripting, (VBS)

    Dear Mr Ankesh 

    can you tell me how to use delay 

  • AS-06081019-0 Profile Picture
    1,736 Super User 2024 Season 1 on 23 Sep 2022 at 07:05:52
    Re: Power Automate desktop and sap Scripting, (VBS)

    @Mona_Sultan  Try using delay

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,658 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,999 Most Valuable Professional

Leaderboard
Loading started