Highlighted
Absent Member.
Absent Member.
625 views

Use of "AS" keyword in Visual COBOL R4

Jump to solution

[Migrated content. Thread originally posted on 07 June 2011]

Hi - We're currently testing Visual COBL R4 in our project. We are compiling a COBOL program that uses the AS keyword in a .NET C# method. These programs are working in a later version before (R3).

Example:
IF FORMAT-NAME = "FORMATNAME"
INVOKE CSHARP_CLASS::"CSharp_Method" (BY REFERENCE OBJ-COBOL AS CobolClass, BY REFERENCE RECORD)
END-IF


We get an error COBCH0919: An AS expression cannot be used as a receiving item

Any thoughts on this?



Thanks in advance! 🙂
0 Likes
1 Solution

Accepted Solutions
Highlighted
Absent Member.
Absent Member.

RE: Use of "AS" keyword in Visual COBOL R4

Jump to solution
I suspect the issue is that you are passing OBJ-COBOL by reference rather than by value. Passing BY REFERENCE means that the CSharpMethod can actually pass back a different object to the caller, making OBJ-COBOL a receiving item.

Most parameters in the .NET world are passed by value rather than by reference, so unless you need to be able to pass back a different instance to the one being passed in to the method, change everything to BY VALUE and it should work OK.

View solution in original post

0 Likes
1 Reply
Highlighted
Absent Member.
Absent Member.

RE: Use of "AS" keyword in Visual COBOL R4

Jump to solution
I suspect the issue is that you are passing OBJ-COBOL by reference rather than by value. Passing BY REFERENCE means that the CSharpMethod can actually pass back a different object to the caller, making OBJ-COBOL a receiving item.

Most parameters in the .NET world are passed by value rather than by reference, so unless you need to be able to pass back a different instance to the one being passed in to the method, change everything to BY VALUE and it should work OK.

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.