K
KBRJ
Guest
I am reading a text file which a COBOL program reads successfully. I am writing the replacement code in c#.net using Struct. Here is reference that i am using. https://www.codeproject.com/Articles/7357/How-to-copy-a-String-into-a-struct-using-C
Here is the cobol
05 NUM PIC X(6)
05 FLAG PIC XX
05 IP PIC X(12)
Here is C#.net
public struct ORDER
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 6)] public string NUM;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2)] public string FLAG;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 12)] public string CUSIP;
}
I am able to read the variables correctly so far to an x position starting from the begining of the 1st line of the text file.
My output is also matching; but this block of Cobol program is having OCCUR clause and I am trying to figure out; how i can add this to the ORDER struct which i have shared above and read the value as i am able to read the fields NUM, FLAG and CUSIP.
05 AN-AREA.
10 COST OCCURS 5 TIMES.
15 TYPE PIC XX.
15 ISO PIC XXX.
15 CODE PIC X(6).
15 IND-X
PIC XX.
15 IND
REDEFINES
IND-X
PIC 99.
15 AMT PIC X(20).
Thanks
Continue reading...
Here is the cobol
05 NUM PIC X(6)
05 FLAG PIC XX
05 IP PIC X(12)
Here is C#.net
public struct ORDER
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 6)] public string NUM;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2)] public string FLAG;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 12)] public string CUSIP;
}
I am able to read the variables correctly so far to an x position starting from the begining of the 1st line of the text file.
My output is also matching; but this block of Cobol program is having OCCUR clause and I am trying to figure out; how i can add this to the ORDER struct which i have shared above and read the value as i am able to read the fields NUM, FLAG and CUSIP.
05 AN-AREA.
10 COST OCCURS 5 TIMES.
15 TYPE PIC XX.
15 ISO PIC XXX.
15 CODE PIC X(6).
15 IND-X
PIC XX.
15 IND
REDEFINES
IND-X
PIC 99.
15 AMT PIC X(20).
Thanks
Continue reading...