Skip to main content

Notifications

Community site session details

Community site session details

Session Id : Av7od83xMOD0sM3j6JfL0y
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 Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - General Discussion

#1
Pstork1 Profile Picture

Pstork1 18 Most Valuable Professional

#2
rpersad Profile Picture

rpersad 16

#3
David_MA Profile Picture

David_MA 10 Super User 2025 Season 1

Overall leaderboard