In Native COBOL you can have something like this:
01 MyData.
05 MyString1 Object Reference.
05 MyString2 Object Reference.
05 MyString3 Object Reference.
05 MyString4 Object Reference.
*> This is just a simplist list, there could be 100's
01 ProgramToCall PIC X(6).
procedure division.
*> Program Names are build dynamically and called in a variable.
move "ABCDEF" to ProgramToCall
Call ProgramToCall using MyData
Now moving to COBOL .NET this has to change as Object References must be on an 01 Level.
All of my programs are in separate projects.
All program Names are called inside a variable
All Linkages to different programs change depending on the program being called, some might not have any Object References, others my have 100's
Q1. How do I simulate the same process in COBOL .NET?
Q2. Can I do it without creating a project references? (Make it more dynamic)
Ideas?
Neil
------------------------------
Neil Hayes
Software Development Specialist
Syspro (Pty) Ltd
Rivonia GB
------------------------------
One option is to make MyData a valuetype, for example:
valuetype-id MyValueType.
working-storage section.
01 MyString1 string public.
01 MyString2 string public.
01 MyString3 string public.
01 MyString4 string public.
end valuetype.
identification division.
program-id. man.
01 MyData type MyValueType.
01 ProgramToCall PIC X(6).
procedure division.
set MyData::MyString1 = "Hello"
set MyData::MyString2 = "World"
set MyData::MyString3 = "From"
set MyData::MyString4 = "COBOL"
*> Program Names are build dynamically and called in a variable
move "ABCDEF" to ProgramToCall
Call ProgramToCall using by value MyData
stop run
.
end program man.
identification division.
program-id. ABCDEF.
procedure division using by value MyData as type MyValueType.
display MyData::MyString1
display MyData::MyString2
display MyData::MyString3
display MyData::MyString4
goback.
end program ABCDEF.
------------------------------
Stephen Gennard
Distinguished Technologist
Rocket Software Forum Member
------------------------------
One option is to make MyData a valuetype, for example:
valuetype-id MyValueType.
working-storage section.
01 MyString1 string public.
01 MyString2 string public.
01 MyString3 string public.
01 MyString4 string public.
end valuetype.
identification division.
program-id. man.
01 MyData type MyValueType.
01 ProgramToCall PIC X(6).
procedure division.
set MyData::MyString1 = "Hello"
set MyData::MyString2 = "World"
set MyData::MyString3 = "From"
set MyData::MyString4 = "COBOL"
*> Program Names are build dynamically and called in a variable
move "ABCDEF" to ProgramToCall
Call ProgramToCall using by value MyData
stop run
.
end program man.
identification division.
program-id. ABCDEF.
procedure division using by value MyData as type MyValueType.
display MyData::MyString1
display MyData::MyString2
display MyData::MyString3
display MyData::MyString4
goback.
end program ABCDEF.
------------------------------
Stephen Gennard
Distinguished Technologist
Rocket Software Forum Member
------------------------------
Close...but still not right - What did I do wrong?
Created a Solution.
Created ProgramA project
Created ProgramB Project which compiles to ProgramA's folder.
valuetype-id MyValueType.
working-storage section.
01 MyString1 string public.
01 MyString2 string public.
01 MyString3 string public.
01 MyString4 string public.
end valuetype.
identification division.
program-id. ProgramA.
01 MyData type MyValueType.
01 ProgramToCall PIC X(256).
procedure division.
set MyData::MyString1 = "Hello"
set MyData::MyString2 = "World"
set MyData::MyString3 = "From"
set MyData::MyString4 = "COBOL"
*> Program Names are build dynamically and called in a variable
move "ProgramB" to ProgramToCall
Call ProgramToCall using by value MyData
on Exception
display "Failed"
stop run.
end program ProgramA.
valuetype-id MyValueType.
working-storage section.
01 MyString1 string public.
01 MyString2 string public.
01 MyString3 string public.
01 MyString4 string public.
end valuetype.
identification division.
program-id. ProgramB.
procedure division using by value MyData as type MyValueType.
display MyData::MyString1
display MyData::MyString2
display MyData::MyString3
display MyData::MyString4
goback.
end program ProgramB.
System.InvalidCastException: '[A]MyValueType cannot be cast to [B]MyValueType. Type A originates from 'ProgramA, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:\\TestProgramLinks\\ProgramA\\bin\\Debug\\net8.0\\ProgramA.dll'. Type B originates from 'ProgramB, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:\\TestProgramLinks\\ProgramA\\bin\\Debug\\net8.0\\ProgramB.dll'.'
------------------------------
Neil Hayes
Software Development Specialist
Syspro (Pty) Ltd
Rivonia GB
------------------------------
Close...but still not right - What did I do wrong?
Created a Solution.
Created ProgramA project
Created ProgramB Project which compiles to ProgramA's folder.
valuetype-id MyValueType.
working-storage section.
01 MyString1 string public.
01 MyString2 string public.
01 MyString3 string public.
01 MyString4 string public.
end valuetype.
identification division.
program-id. ProgramA.
01 MyData type MyValueType.
01 ProgramToCall PIC X(256).
procedure division.
set MyData::MyString1 = "Hello"
set MyData::MyString2 = "World"
set MyData::MyString3 = "From"
set MyData::MyString4 = "COBOL"
*> Program Names are build dynamically and called in a variable
move "ProgramB" to ProgramToCall
Call ProgramToCall using by value MyData
on Exception
display "Failed"
stop run.
end program ProgramA.
valuetype-id MyValueType.
working-storage section.
01 MyString1 string public.
01 MyString2 string public.
01 MyString3 string public.
01 MyString4 string public.
end valuetype.
identification division.
program-id. ProgramB.
procedure division using by value MyData as type MyValueType.
display MyData::MyString1
display MyData::MyString2
display MyData::MyString3
display MyData::MyString4
goback.
end program ProgramB.
System.InvalidCastException: '[A]MyValueType cannot be cast to [B]MyValueType. Type A originates from 'ProgramA, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:\\TestProgramLinks\\ProgramA\\bin\\Debug\\net8.0\\ProgramA.dll'. Type B originates from 'ProgramB, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:\\TestProgramLinks\\ProgramA\\bin\\Debug\\net8.0\\ProgramB.dll'.'
------------------------------
Neil Hayes
Software Development Specialist
Syspro (Pty) Ltd
Rivonia GB
------------------------------
I think MyValueType will need to be a shared assembly used by both programs
------------------------------
Stephen Gennard
Distinguished Technologist
Rocket Software Forum Member
------------------------------
In Native COBOL you can have something like this:
01 MyData.
05 MyString1 Object Reference.
05 MyString2 Object Reference.
05 MyString3 Object Reference.
05 MyString4 Object Reference.
*> This is just a simplist list, there could be 100's
01 ProgramToCall PIC X(6).
procedure division.
*> Program Names are build dynamically and called in a variable.
move "ABCDEF" to ProgramToCall
Call ProgramToCall using MyData
Now moving to COBOL .NET this has to change as Object References must be on an 01 Level.
All of my programs are in separate projects.
All program Names are called inside a variable
All Linkages to different programs change depending on the program being called, some might not have any Object References, others my have 100's
Q1. How do I simulate the same process in COBOL .NET?
Q2. Can I do it without creating a project references? (Make it more dynamic)
Ideas?
Neil
------------------------------
Neil Hayes
Software Development Specialist
Syspro (Pty) Ltd
Rivonia GB
------------------------------
Neil, for this simple example you could just add the string items to a list and pass that.
But as I suspect that your real code doesn't just contain a collection of strings, as an alternative to Stephen's suggestion how about defining an interface for MyData? Your programA project could then contain a class that implements that interface and pass that to your programB project which uses the interface.
Gael
------------------------------
Gael Wilson
Lead Software Engineer
Rocket Forum Shared Account
Newbury United Kingdom
------------------------------