BookmarkSubscribeRSS Feed
elwayfan446
Barite | Level 11

I recently upgraded from SAS EG 7.13 to SAS EG 8.2.  I am getting a "Object reference not set to an instance of an object" error on my import and export tasks within the project/process flow that is being called by the .vbs script (from the scheduler).  All other tasks appear to be working as they did before.  I have modified each of the import/export tasks to "refresh" them but it didn't seem to help.  Before I totally delete and recreate them to see if that fixes the issue, I wanted to ask if anyone else experienced this and if there is a way to resolve it.

1 REPLY 1
elwayfan446
Barite | Level 11

Wanted to add an observation. It appears this is only happening on .vbs files that call the ordered list container for the process flow. For those that are simply running the process flow as is, it is running normally.

 

Here is the code of a .vbs file where an ordered list is called from the scheduler.  You will notice that the "run the project" block is commented out.  I did this based on something I read when setting this up to run the ordered lists a few years ago.  Maybe there is a better way to do this?

 

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 = "M:\NECD\Group\PFS\mortgage\MSR Reporting\MSR Flow Reporting\Freddie Mac\SAS EG Automation\Freddie Mac Daily Dashboard Generation_v5.1.egp"    'Project Name
      
    Set app = CreateObject("SASEGObjectModel.Application.8.1")
    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

    '-----
    ' run the ordered list
    '-----		
  
    Dim orderedListContainer
    Dim orderedList

    Set orderedListContainer = prjObject.ContainerCollection.Item("Ordered Lists")
    For Each orderedList in orderedListContainer.Items
        If orderedList.Name = "MSR0002 - Freddie Mac Flow Order Prod" Then
            orderedList.Run()
        End If
    Next
    If Checkerror("OrderedList.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

Here is the code for a .vbs called by the scheduler that doesn't call an ordered list.

 

Option Explicit
Dim app         ' As SASEGuide.Application

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     ' As String
    Dim prjObject   ' As SASEGuide.Project
    Dim containerName     ' As String
    Dim containerObject   ' As SASEGuide.Container
    Dim containerColl     ' As SASEGuide.ContainerCollection

    prjName = "M:\NECD\Group\PFS\mortgage\MSR Reporting\Automation\SAS EG Project Automation\SAS EG Automation Projects.egp" ' Project Name
    containerName = "MSR0025 - MSR SMP Monthly Funding Report" ' Container Name
      
    Set app = CreateObject("SASEGObjectModel.Application.8.1")
    If Checkerror("CreateObject") = True Then
        Exit Sub
    End If
    
    Set prjObject = app.Open(prjName,"")
    If Checkerror("App.Open") = True Then
        Exit Sub
    End If
    
        
    '-----
    'Get The Container Collection and Object
    '-----    
    Set containerColl = prjObject.ContainerCollection
    If Checkerror("Project.ContainerCollection") = True Then
        Exit Sub
    End If
    
    Dim i       ' As Long
    Dim count   ' As Long
    count = containerColl.count
    For i = 0 To count - 1
        Set containerObject = containerColl.Item(i)
        If Checkerror("ContainerCollection.Item") = True Then
            Exit Sub
        End If
        
        If (containerObject.Name = containerName) Then
            Exit For
        Else
            Set containerObject = Nothing
        End If
    Next 
    
    If not (containerObject Is Nothing) Then
        '----
        ' Run the Container
        '----
        containerObject.Run
        If Checkerror("Container.Run") = True Then
            Exit Sub
        End If               
    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      ' As String
    Dim errNum      ' As Long
    
    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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 914 views
  • 0 likes
  • 1 in conversation