on 2013 May 23 12:52 PM
Hi to all!
We are on SAP BPC 7.5NW SP14.
We need to run DM Package by pushing the button in the input schedule. DM Package can be located in different application than in CV , so we need to switch it before running DM Package.
How to switch BPC application in VBA macro?
Regards,
Oleg.
Request clarification before answering.
Hi Alex,
Alternative solution (we used it many times):
Use RUNLOGIC BADI to launch script from one cube in another cube.
B.R. Vadim
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Aleh,
Try the following code - it will change the application lock:
Option Explicit
Public Sub ChangeApp(strNewAppName As String, strCurrentSheetName As String)
Dim wshSheet As Worksheet
Dim wshCurrentSheet As Worksheet
Dim namName As Name
Dim blnNoLimitedCV As Boolean
' Find other worksheet to temporary activate (the workbook has to contain at least 2 visible worksheets)
For Each wshSheet In ThisWorkbook.Worksheets
If wshSheet.Name <> strCurrentSheetName And wshSheet.Visible = xlSheetVisible Then GoTo OtherFound
Next
MsgBox "Only one visible worksheet in the book!"
Exit Sub
OtherFound:
Set wshCurrentSheet = ThisWorkbook.Worksheets(strCurrentSheetName)
' Test if the sheet already has lock
blnNoLimitedCV = False
For Each namName In wshCurrentSheet.Names
If namName.Name = strCurrentSheetName & "!Ev__LimitedCV" Then GoTo NameFound
Next
blnNoLimitedCV = True
Set namName = wshCurrentSheet.Names.Add("Ev__LimitedCV", "", False)
NameFound:
namName.Value = "Application:" & strNewAppName & "|Application:" & strNewAppName
wshSheet.Activate
wshCurrentSheet.Activate
If blnNoLimitedCV Then
namName.Delete
End If
Set namName = Nothing
Set wshSheet = Nothing
Set wshSheet = Nothing
End Sub
Public Sub ChangeAppCurrentSheet()
ChangeApp "ADVSALES", ThisWorkbook.ActiveSheet.Name
End Sub
B.R. Vadim
Message was edited by: Vadim Kalinin P.S. Some code have to be corrected if the sheet has dimension lock...
Hi Oleg,
Some corrections has to be done. Look here:
Option Explicit
Public Sub ChangeApp(strNewAppName As String, strCurrentSheetName As String)
Dim wshSheet As Worksheet
Dim wshCurrentSheet As Worksheet
Dim namName As Name
Dim blnNoLimitedCV As Boolean
Dim strCurrAppName As String
' Find other worksheet to temporary activate (the workbook has to contain at least 2 visible worksheets)
For Each wshSheet In ThisWorkbook.Worksheets
If wshSheet.Name <> strCurrentSheetName And wshSheet.Visible = xlSheetVisible Then GoTo OtherFound
Next
MsgBox "Only one visible worksheet in the book!"
Exit Sub
OtherFound:
Set wshCurrentSheet = ThisWorkbook.Worksheets(strCurrentSheetName)
' Test if the sheet
blnNoLimitedCV = False
For Each namName In wshCurrentSheet.Names
If namName.Name = strCurrentSheetName & "!Ev__LimitedCV" Then GoTo NameFound
Next
blnNoLimitedCV = True
Set namName = wshCurrentSheet.Names.Add("Ev__LimitedCV", "Application:" & strNewAppName & "|Application:" & strNewAppName, False)
GoTo SwitchSheet
NameFound:
strCurrAppName = Mid(namName.Value, InStr(namName.Value, ":") + 1, InStr(namName.Value, "|") - InStr(namName.Value, ":") - 1)
namName.Value = Replace(namName.Value, strCurrAppName, strNewAppName)
SwitchSheet:
wshSheet.Activate
wshCurrentSheet.Activate
If blnNoLimitedCV Then
namName.Delete
End If
Set namName = Nothing
Set wshSheet = Nothing
Set wshSheet = Nothing
End Sub
Public Sub ChangeAppCurrentSheet()
ChangeApp "INFILE", ThisWorkbook.ActiveSheet.Name
End Sub
B.R. Vadim
Hi again!
There is one more problem that block the use of provided macro. The main purpose of such workbooks with app switching functionality is to link it to the step of BPF. If such workbook is opened from BPF then app switching functionality doesn't work (app switches to app from bpf step CV settings).
Any ideas?
Regards,
Oleg.
Ups,
BPF is a different story... I can't test this scenario now, but is it possible to change app manually within BPF step?
Anyway, in our system we use RUNLOGIC for this task without significant efforts to support a lot of scripts. You will need additional launch script and you can pass $$ and %% variables to the calling script ($$ variables are automatically available to the calling script using the latest version of the RUNLOGIC BADI).
B.R. Vadim
User | Count |
---|---|
11 | |
10 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.