SAP coding

Jordan2

New Member
Joined
Apr 4, 2024
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi All,

How to insert an IF function into SAP VBA Code so that IF a pop up comes up "Data has been changed:", "Do you want to save the changes?" Yes, No or Cancel and I want to Press Yes and enter to continue but I can't seem to figure this out.

This is my code after it's done the excel portion and connects to SAP

session.StartTransaction "DE9"
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "ZVP1A"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/tabsTABSTR/tabpVOR").Select
session.findById("wnd[0]/tbar[1]/btn[31]").press
session.findById("wnd[1]/usr/ctxtDY_PATH").Text = "C:\folder\setup\"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").Text = "Preallocation.txt"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").caretPosition = 17
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[11]").press
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/usr/tabsTABSTR/tabpBAS").Select
session.findById("wnd[0]/tbar[1]/btn[31]").press
session.findById("wnd[1]/usr/ctxtDY_PATH").Text = "C:\folder\setup\"

TIA.
 

Attachments

  • SAP Pop Up.png
    SAP Pop Up.png
    16.7 KB · Views: 5

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
generally like this:
VBA Code:
    If a = b Then
        x = MsgBox("Data has been changed." & vbLf & _
                    "Do you want to save the changes?", _
                    vbQuestion + vbYesNoCancel, "some title")
        If x = vbYes Then
            'do something
        End If
    End If
 
Upvote 0
I've tried to put that in but that's more for excel, I believe rather than SAP code I've put.

I have seen the code below online as well but I can't seem to get it to work with it, do you know much on SAP?

If session.ActiveWindow.Name = "wnd[1]" Then
session.findById("wnd[1]/usr/btnZSPOP_PRIMARY-OPTION1").press
End If
 
Upvote 0

Forum statistics

Threads
1,215,212
Messages
6,123,653
Members
449,111
Latest member
ghennedy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top