Desktop productivity for business analysts and programmers

Change to VBScript in EG 4.3

Reply
N/A
Posts: 1

Change to VBScript in EG 4.3

Hallo,

I'm have just started using EG 4.3 on Windows 7 to run about 250 jobs in batch via a remote server every night.I would like to direct the logs from these jobs to a central folder for further log scanning analysis. I'm thinking that I need to add some code to my VBScripts in order each project to direct the log to my predefined folder.Does anyone have a suggestion as to what I need to add to be below stated VBScript in order for this to succesfully happen?

Thanks!

Option Explicit

Dim app

Call dowork

'shut down the app

If not (app Is Nothing) Then

    app.Quit

    Set app = Nothing

End If

Sub dowork()

    On Error Resume Next

    '----

    ' Start up Enterprise Guide using the project name

    '----

    Dim prjName

    Dim prjObject

    prjName = "C:\_Services\Scheduling\finance.egp"    'Project Name

    Set app = CreateObject("SASEGObjectModel.Application.4.3")

    If Checkerror("CreateObject") = True Then

        Exit Sub

    End If   

    '-----

    ' open the project

    '-----

    Set prjObject = app.Open(prjName,"")

    If Checkerror("app.Open") = True Then

        Exit Sub

    End If      

    '-----

    ' run the project

    '-----

    prjObject.run

    If Checkerror("Project.run") = True Then

        Exit Sub

    End If          

    '-----

    ' Save the new project

    '-----

    prjObject.Save

    If Checkerror("Project.Save") = True Then

        Exit Sub

    End If  

    '-----

    ' Close the project

'-----

    prjObject.Close

    If Checkerror("Project.Close") = True Then

        Exit Sub

    End If      

End Sub

Function Checkerror(fnName)

    Checkerror = False

   

    Dim strmsg

    Dim errNum

   

    If Err.Number <> 0 Then

        strmsg = "Error #" & Hex(Err.Number) & vbCrLf & "In Function " & fnName & vbCrLf & Err.Description

        'MsgBox strmsg  'Uncomment this line if you want to be notified via MessageBox of Errors in the script.

        Checkerror = True

    End If

        

End Function

Community Manager
Posts: 2,697

Re: Change to VBScript in EG 4.3

You can add a bit of script that will iterate through and export each SAS log that is produced in the project.

For background information, see:

Doing more with SAS Enterprise Guide automation - The SAS Dummy

with more examples from this sasCommunity.org page:

http://www.sascommunity.org/wiki/Not_Just_for_Scheduling:_Doing_More_with_SAS_Enterprise_Guide_Autom...

And specifically, this example:

http://support.sas.com/documentation/onlinedoc/guide/examples/SASGF2012/ExtractCodeAndLog.vbs.txt

Chris

Contributor
Posts: 30

Re: Change to VBScript in EG 4.3

Chris,

I saw the script ExtractCodeAndLog.vbs and found very useful. Now if I want to email the log file if there is an error in the code, how should I make the change?

Respected Advisor
Posts: 3,837

Re: Change to VBScript in EG 4.3

As a general and possibly not welcome comment:

If this is about 250 jobs then scheduling using EG is may be the wrong approach as it needs a client computer with EG running. There is commercial scheduling software like LSF on the market which should be used. EG scheduling is imho only appropriate for some small scale scheduling tasks in a more "informal" environment. 250 jobs clearly exceed such a definition.

Community Manager
Posts: 2,697

Re: Change to VBScript in EG 4.3

I agree with Patrick's sentiment on scalability. 

However, I know that there are sometimes competing factors, including the ability to engage IT in the activity.  With EG automation you can achieve some of the benefits of scheduling (including auditing logs) if you write your scripts correctly. 

At some point you may outgrow that approach, or your IT organization may want to "operationalize" the process differently.

Chris

Trusted Advisor
Posts: 1,214

Re: Change to VBScript in EG 4.3

Another option would be to redirect the logs in SAS, rather than your script, using PROC PRINTTO.

--Q.

Ask a Question
Discussion stats
  • 5 replies
  • 1157 views
  • 0 likes
  • 5 in conversation