Skip to main content

Hi , Please help on passing value from C# to Cobol using Class Type project. I have for example a declaration :

01 tmp-rec-date.
   05 date-mm pic x(2).
   05 date-dd pic x(2).
   05 date-yy pic x(4).

 

How can I pass string / structured value from C# to Cobol using that declaration in Cobol. I'm getting "String cannot be converted to Microfocus.COBOL.Program.Reference". What will be the correct type declaration in C#? Please help.

 

 

Regards,

jhayvi

Hi , Please help on passing value from C# to Cobol using Class Type project. I have for example a declaration :

01 tmp-rec-date.
   05 date-mm pic x(2).
   05 date-dd pic x(2).
   05 date-yy pic x(4).

 

How can I pass string / structured value from C# to Cobol using that declaration in Cobol. I'm getting "String cannot be converted to Microfocus.COBOL.Program.Reference". What will be the correct type declaration in C#? Please help.

 

 

Regards,

jhayvi

In native COBOL a C# string is a COBOL character array depending how you class library has been build.

So in COBOL you receive an object reference, you then examine the object reference to determine its type, ie Character array, then you can get the value.

Is it for example COM class or more of a native dll where a load library is performed?
How have you defined your COBOL linkage section?

Neil

Hi , Please help on passing value from C# to Cobol using Class Type project. I have for example a declaration :

01 tmp-rec-date.
   05 date-mm pic x(2).
   05 date-dd pic x(2).
   05 date-yy pic x(4).

 

How can I pass string / structured value from C# to Cobol using that declaration in Cobol. I'm getting "String cannot be converted to Microfocus.COBOL.Program.Reference". What will be the correct type declaration in C#? Please help.

 

 

Regards,

jhayvi

Try this:

/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>

public partial class MainWindow : Window
{
private CobClass1 cobCl;

public MainWindow()
{
InitializeComponent();

cobCl = new CobClass1();
}

private void PBCall_Click(object sender, RoutedEventArgs e)
{
tdtDateOut.Text = cobCl.ConvertDateString(tdtDateIn.Text);
}
}

class-id ClassCobol.CobClass1.

working-storage section.

01 w-date.
05 date-dd pic xx.
05 date-mm pic xx.
05 date-yy pic xxxx.

method-id ConvertDateString.
local-storage section.
procedure division using by value InputString as string
returning OutputString as string.

set w-date to InputString
set OutputString to date-dd & "." & date-mm & "." & date-yy

goback.
end method.

end class.

If you send me your mail address I can send you the VS solution as ZIP file.