Created On: 7 July 2010
Problem:
We created a COBOL COM Server program using the Net Express Class Wizard and have a file defined within the Input-Output section within the Object itself. When trying to open the file for output a file status 9/004 "Invalid Filename" is returned.
Resolution:
This is happening due to the location of the file definition within the COM Server program. Although it will compile cleanly, file definitions cannot be placed within the Instance Object itself. Files need to be defined as shown in the following example:
$set ooctrl( p)
class-id. testobj
inherits from olebase.
object section.
class-control.
testobj is class "testobj"
*> OCWIZARD - start list of classes
olebase is class "olebase"
oleSafeArray is class "olesafea"
oleVariant is class "olevar"
*> OCWIZARD - end list of classes
*>---USER-CODE. Add any additional class names below.
.
Input-Output Section.
File-Control.
Select ERRTEMP-FILE Assign to external ERRTEMP
Organization is SEQUENTIAL
File Status is ERR-FILE-STATUS.
Data Division.
File Section.
FD ERRTEMP-FILE
Label Records STANDARD.
01 ERRTEMP-RECORD. PIC X(80).
*>-----------------------------------------------------------
working-storage section. *> Definition of global data
*>-----------------------------------------------------------
01 ERR-FILE-STATUS PIC X(2).
01 any-key pic x.
*>-----------------------------------------------------------
class-object. *> Definition of class data and methods
*>-----------------------------------------------------------
object-storage section.
*> OCWIZARD - start standard class methods
*>-----------------------------------------------------------
*> Return details about the class.
*> If you have a type library, theClassId and theInterfaceId
*> here MUST match.
*> theProgId must match the registry entry for this class
*> (a zero length string implies using the class file name)
*> theClassId must match the CLSID stored in the registry.
*> theVersion is currently ignored (default 1 used).
*>-----------------------------------------------------------
method-id. queryClassInfo.
linkage section.
01 theProgId pic x(256).
01 theClassId pic x(39).
01 theInterfceId pic x(39).
01 theVersion pic x(4) comp-5.
01 theDescription pic x(256).
01 theThreadModel pic x(20).
procedure division using by reference theProgId
by reference theClassId
by reference theInterfceId
by reference theVersion
by reference theDescription
by reference theThreadModel.
move z"CCtestobj" to theProgId
move z"{975E38EE-C99B-4114-A7EE-C1D7004BA186}" to theClassId
move z"{AC9F4E30-368B-40DA-8A77-F844C34A41D7}" to theInterfceI
move z"Description for class testobj"
to theDescription
move z"Apartment" to theThreadModel
exit method.
end method queryClassInfo.
*>-----------------------------------------------------------
*> Return details about the type library - delete if unused.
*> theLocale is currently ignored (default 0 used).
*> theLibraryName is a null terminated string used for auto
*> registration, and supports the following values:
*> - Library is embedded in this binary
*> - As above, with this resource number
*> path - Library is at this (full path) location
*>-----------------------------------------------------------
method-id. queryLibraryInfo.
linkage section.
01 theLibraryName pic x(512).
01 theMajorVersion pic x(4) comp-5.
01 theMinorVersion pic x(4) comp-5.
01 theLibraryId pic x(39).
01 theLocale pic x(4) comp-5.
procedure division using by reference theLibraryName
by reference theMajorVersion
by reference theMinorVersion
by reference theLibraryId
by reference theLocale.
move 1 to theMajorVersion
move 0 to theMinorVersion
move z"{0F5F86C9-4311-4E16-8C85-8BF51F55E5B2}" to theLibraryId
exit method.
end method queryLibraryInfo.
*>-----------------------------------------------------------
end class-object.
object. *> Definition of instance data and methods
object-storage section.
*>---------------------------------------------------------------
method-id. "testfiles" .
local-storage Section.
01 actual-value pic x(60).
linkage Section.
procedure division.
call 'cbl_debugbreak'.
OPEN OUTPUT ERRTEMP-FILE.
...
exit method.
end method "testfiles".
end object.
$set ooctrl( p)
class-id. testobj
inherits from olebase.
object section.
class-control.
testobj is class "testobj"
*> OCWIZARD - start list of classes
olebase is class "olebase"
oleSafeArray is class "olesafea"
oleVariant is class "olevar"
*> OCWIZARD - end list of classes
*>---USER-CODE. Add any additional class names below.
.
Input-Output Section.
File-Control.
Select ERRTEMP-FILE Assign to external ERRTEMP
Organization is SEQUENTIAL
File Status is ERR-FILE-STATUS.
Data Division.
File Section.
FD ERRTEMP-FILE
Label Records STANDARD.
01 ERRTEMP-RECORD. PIC X(80).
*>-----------------------------------------------------------
working-storage section. *> Definition of global data
*>-----------------------------------------------------------
01 ERR-FILE-STATUS PIC X(2).
01 any-key pic x.
*>-----------------------------------------------------------
class-object. *> Definition of class data and methods
*>-----------------------------------------------------------
object-storage section.
*> OCWIZARD - start standard class methods
*>-----------------------------------------------------------
*> Return details about the class.
*> If you have a type library, theClassId and theInterfaceId
*> here MUST match.
*> theProgId must match the registry entry for this class
*> (a zero length string implies using the class file name)
*> theClassId must match the CLSID stored in the registry.
*> theVersion is currently ignored (default 1 used).
*>-----------------------------------------------------------
method-id. queryClassInfo.
linkage section.
01 theProgId pic x(256).
01 theClassId pic x(39).
01 theInterfceId pic x(39).
01 theVersion pic x(4) comp-5.
01 theDescription pic x(256).
01 theThreadModel pic x(20).
procedure division using by reference theProgId
by reference theClassId
by reference theInterfceId
by reference theVersion
by reference theDescription
by reference theThreadModel.
move z"CCtestobj" to theProgId
move z"{975E38EE-C99B-4114-A7EE-C1D7004BA186}" to theClassId
move z"{AC9F4E30-368B-40DA-8A77-F844C34A41D7}" to theInterfceI
move z"Description for class testobj"
to theDescription
move z"Apartment" to theThreadModel
exit method.
end method queryClassInfo.
*>-----------------------------------------------------------
*> Return details about the type library - delete if unused.
*> theLocale is currently ignored (default 0 used).
*> theLibraryName is a null terminated string used for auto
*> registration, and supports the following values:
*> - Library is embedded in this binary
*> - As above, with this resource number
*> path - Library is at this (full path) location
*>-----------------------------------------------------------
method-id. queryLibraryInfo.
linkage section.
01 theLibraryName pic x(512).
01 theMajorVersion pic x(4) comp-5.
01 theMinorVersion pic x(4) comp-5.
01 theLibraryId pic x(39).
01 theLocale pic x(4) comp-5.
procedure division using by reference theLibraryName
by reference theMajorVersion
by reference theMinorVersion
by reference theLibraryId
by reference theLocale.
move 1 to theMajorVersion
move 0 to theMinorVersion
move z"{0F5F86C9-4311-4E16-8C85-8BF51F55E5B2}" to theLibraryId
exit method.
end method queryLibraryInfo.
*>-----------------------------------------------------------
end class-object.
object. *> Definition of instance data and methods
object-storage section.
*>---------------------------------------------------------------
method-id. "testfiles" .
local-storage Section.
01 actual-value pic x(60).
linkage Section.
procedure division.
call 'cbl_debugbreak'.
OPEN OUTPUT ERRTEMP-FILE.
...
exit method.
end method "testfiles".
end object.
Incident #2462050
Old KB# 31387