cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Multiple variables selection - Macro

0 Likes
1,232

Hi,

is it possible to select two variables (US and DE) with the below code? How should it be adjusted?

Call Application.Run("SAPSetRefreshBehaviour", "Off")

Call Application.Run("SAPExecuteCommand", "PauseVariableSubmit", "On")

Call Application.Run("SAPSetVariable", "0BWVC_COUNTRY", "US")

Call Application.Run("SAPSetVariable", "0BWVC_COUNTRY", "DE")

Call Application.Run("SAPExecuteCommand", "PauseVariableSubmit", "Off")

Call Application.Run("SAPSetRefreshBehaviour", "On")

Thanks!
View Entire Topic
MKreitlein
Active Contributor

Hello Gasper,

it should work like:

Call Application.Run("SAPSetVariable", "0BWVC_COUNTRY", "US;DE")

BR,

Martin

0 Likes

Hi Martin!

Thank you! This works 🙂
Do you maybe have a solution also for the below code? I would like to use dynamic variables (Datex1 and Datex2) instead of fixed variables (in " "). Please see my code below.

Sub UpdateData()

Dim Datex As String
Worksheets("Sheet1").Select
Datex1 = Range("G2").Text
Datex2 = Range("E2").Text

SetReportingUnit = Application.Run("SAPSetVariable", "Select FCRSCode-Child(s) Opt", Datex2;Datex3, "INPUT_STRING", "DS_1")

MKreitlein
Active Contributor

Hello Gasper,

for the 2nd example you probably need to concat the texts into one Variable:

Datex = Datex1 & ";" & Datex2

And then use this one:

SetReportingUnit = Application.Run("SAPSetVariable", "Select FCRSCode-Child(s) Opt", Datex, "INPUT_STRING", "DS_1")
0 Likes

Hi Martin,

this is exactly what I was looking for 🙂

Thank you so much!!