Quantcast
Channel: SCN : Discussion List - SAP BusinessObjects Analysis, edition for Microsoft Office
Viewing all articles
Browse latest Browse all 1521

Using Excel VBA to automate reporting

$
0
0

Hi,

 

I am trying to automate some reporting. I need to change the prompt variables and then refresh.

 

I have tried the code below, and a LOT of variations around it.

 

If some one could point out my newbie error, or perhaps even post some simple examples, that would be great.

 

tia,

Peter

 

Sub RefreshPrompts() 
    DoSAPRefreshPrompts InputBox("Enter in format mm.yyyy", "Run Month/Year", "09.2012")
End Sub

Sub DoSAPRefreshPrompts(CalMonth As String)
    Dim iRet

    ' Logon to the application, returns no errors
    iRet = Application.Run("SAPLogon", "DS_1", "100", UserId, password)
    If val(iRet) <> 1 Then MsgBox "Logon failure. iRet = " & iRet, vbOKOnly, "Error"
      
    iRet = Application.Run("SAPSetRefreshBehaviour", "Off") ' Usually returns no error
    If val(iRet) <> 1 Then MsgBox "Refresh behaviou off. iRet = " & iRet, vbOKOnly, "Error"
    
    iRet = Application.Run("SAPExecuteCommand", "PauseVariableSubmit", "On") ' Usually returns no error
    If val(iRet) <> 1 Then MsgBox "Pause Variable. iRet = " & iRet, vbOKOnly, "Error"
    
    iRet = Application.Run("SAPSetVariable", "CAS_SM_CALMONTH", CalMonth) ' Returns error
    If val(iRet) <> 1 Then MsgBox "Set calender Month to " & CalMonth & ". iRet = " & iRet, vbOKOnly, "Error"
    
    iRet = Application.Run("SAPSetVariable", "FIM_COMP_CODE_AU", "AU10") ' Returns error
    If val(iRet) <> 1 Then MsgBox "Set AU10 variable. iRet = " & iRet, vbOKOnly, "Error"
    
    iRet = Application.Run("SAPSetVariable", "FIMPBDGV", "1") ' Returns error
    If val(iRet) <> 1 Then MsgBox "set '1' variable. iRet = " & iRet, vbOKOnly, "Error"
    
    iRet = Application.Run("SAPExecuteCommand", "PauseVariableSubmit", "Off") ' Usually returns no error
    If val(iRet) <> 1 Then MsgBox "Pause Variable submit off. iRet = " & iRet, vbOKOnly, "Error"
    
    iRet = Application.Run("SAPSetRefreshBehaviour", "On") ' Usually returns no error
    If val(iRet) <> 1 Then MsgBox "Refresh behaviour On. iRet = " & iRet, vbOKOnly, "Error"
End Sub


Viewing all articles
Browse latest Browse all 1521

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>