Skip to Content
0

Bug with answer file access for VBA API RunPackage

Apr 14, 2017 at 02:53 PM

104

avatar image

I am working with EPM SP27 patch 2 and trying to implement RunPackage API to pass answer prompt to DM package. Everything correctly but I am unable to delete answer file after RunPackage execution.

    epmDM.RunPackage epmDMPackage, strAnswerFileName
    Kill strAnswerFileName

The file strAnswerFileName is still open after RunPackage execution!

After decompile of EPM code in ILSpy I can see the reason:

Public Sub RunPackage(package As IADMPackage, filename As String)
    Try
        SAPModuleNameInspectorBehavior.ModuleOverride = "DataManager"
        If package Is Nothing Then
            Throw New InvalidArgException(String.Format(Resources.ExceptionParameterIsNull, "package"))
        End If
        package.CheckParameters()
        If filename Is Nothing Then
            Throw New InvalidArgException(String.Format(Resources.ExceptionParameterIsNull, "filename"))
        End If
        If filename.Trim() = "" Then
            Throw New InvalidArgException(String.Format(Resources.ExceptionPropertyOfObjectIsAnEmptyString, MyBase.[GetType]().ToString(), "filename"))
        End If
        Try
            Dim fi As System.IO.FileInfo = New System.IO.FileInfo(filename)
            If Not fi.Exists Then
                Throw New InvalidArgException("File doesn't exists")
            End If
            Dim fs As System.IO.FileStream = fi.OpenRead()
            Dim sr As System.IO.StreamReader = New System.IO.StreamReader(fs)
            Dim content As String = sr.ReadToEnd()
            ...

But I don't see sr.Close until the end of procedure

Looks like bug!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers