Highlighted
Absent Member.
Absent Member.
1416 views

Global Variables in VISUAL COBOL

Jump to solution

Hi

I need to consume a .NET COM+ dll in Visual Cobol but there are certain problem which i am facing while trying to consume that.

I have native COBOL DLL which is internally calling a Native DLL which is interacting with the .NET COM+ component.

COBOL DLL(Base) --> Native COBOL DLL(Layer) --> .NET COM+ DLL

The call is driven by Base DLL to Layer DLL , The layer DLL create an object of COM+ class and execute the method and return the values to Layer Dll and dispose the object.

I need to retain the object and its value in Base Layer can someone suggest me solution for the same.

I am thinking of declaring a Global/external variable so that i can retain the values in the base layer. I can change the base layer so i am avoid using linkage variables.

Please suggest me the usage of Global or external variable in Visual COBOL

Thanks 

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

You can store the object in the Base class by defining it as an external item in both Base class and in Layer

example:

01 anInstance    object reference external.

This data item will then be referring to the same memory storage and will be shared between the two.

The object will only be valid on the second call if it has not been disposed of first.

So if your called Layer and it created the instance of the COM class and stored it in anInstance then it would automatically still be available in Base even if Layer has been canceled.

You could also just pass the object as a parameter back and forth between the Base and the Layer and store it as a non-external item in the base class.

View solution in original post

0 Likes
1 Reply
Highlighted
Micro Focus Expert
Micro Focus Expert

You can store the object in the Base class by defining it as an external item in both Base class and in Layer

example:

01 anInstance    object reference external.

This data item will then be referring to the same memory storage and will be shared between the two.

The object will only be valid on the second call if it has not been disposed of first.

So if your called Layer and it created the instance of the COM class and stored it in anInstance then it would automatically still be available in Base even if Layer has been canceled.

You could also just pass the object as a parameter back and forth between the Base and the Layer and store it as a non-external item in the base class.

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.