473,386 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Converting COBOL code to C# ?

We have a number of COBOL programs, and some were currently developing, that
simply read TEXT based reports and scrap the reports for various
information.

I'm curious to know if anyone has attempted to do this sort of thing using
C#?

I would love to get rid of my COBOL programmer and especially the code, if I
can. Apparently, it is much simplier to edit/parse text reports in COBOL
than other languages.... so I'm being told.
Any samples or online references would be great.

Please note that some reports are multi-page and some may have special
"binary" coded headers that is used for printers, etc., that are typically
ignored by the parser.

Mar 2 '06 #1
15 9513
I don't know anything about COBOL, so I can't compare the two. But in .NET,
it is fairly straight forward reading and writing files.

Take a look at the System.IO namespace. There are classes in there for
reading files as binary files, text files, file streams, memory streams, etc.
Look at the System.Text namespace for classes for different character
encodings. The System.String class has may methods for common string parsing.

http://msdn.microsoft.com/library/de...classtopic.asp

I have no clue about COBOL, but it's real easy in .NET (C# or VB.NET).

"dm1608" wrote:
We have a number of COBOL programs, and some were currently developing, that
simply read TEXT based reports and scrap the reports for various
information.

I'm curious to know if anyone has attempted to do this sort of thing using
C#?

I would love to get rid of my COBOL programmer and especially the code, if I
can. Apparently, it is much simplier to edit/parse text reports in COBOL
than other languages.... so I'm being told.
Any samples or online references would be great.

Please note that some reports are multi-page and some may have special
"binary" coded headers that is used for printers, etc., that are typically
ignored by the parser.

Mar 2 '06 #2
dm1608,

I am reasonably sure that at least one vendor (Fujitsu, I believe) has a
COBOL.NET language product. You can use the existing COBOL codebase to create
..NET assemblies, and then simply decompile them into C# using a free product
such as Roeder's Reflector.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"dm1608" wrote:
We have a number of COBOL programs, and some were currently developing, that
simply read TEXT based reports and scrap the reports for various
information.

I'm curious to know if anyone has attempted to do this sort of thing using
C#?

I would love to get rid of my COBOL programmer and especially the code, if I
can. Apparently, it is much simplier to edit/parse text reports in COBOL
than other languages.... so I'm being told.
Any samples or online references would be great.

Please note that some reports are multi-page and some may have special
"binary" coded headers that is used for printers, etc., that are typically
ignored by the parser.

Mar 2 '06 #3
I think that if he goes to the trouble of buying a COBOL compiler, he may as
well leave the programs in COBOL (and save his poor programmer's job!).

I have written hundreds of COBOL programs (although not for many years) and it
is good for the applications he describes.

My experience in converting systems is that it is better to recode into the new
language rather than relying on some automatic translation system. You have the
best spec in the world - an existing working system - to verify your results.

Perhaps recoding to VB would be easier ?
Peter Bromberg [C# MVP] wrote:
dm1608,

I am reasonably sure that at least one vendor (Fujitsu, I believe) has a
COBOL.NET language product. You can use the existing COBOL codebase to create
.NET assemblies, and then simply decompile them into C# using a free product
such as Roeder's Reflector.
Peter

Mar 2 '06 #4
> Apparently, it is much simplier to edit/parse text reports in COBOL than other languages.... so I'm being told.

We program in both COBOL and C#. I also have close to 20 years'
experience using C, with some Java and C++ mixed in there.

What COBOL is really good at, parsing-wise, is reading fixed-position
records. That is to say if your report always has the print date at the
56th character position of the 3rd line then getting at it using COBOL
is a breeze.

However, getting at it with C# isn't very difficult, either. It may not
be as elegant as the COBOL program, but then it's not going to be an
ugly mess, either. A bit more complex, but not much.

Where COBOL really falls down is in any of the following situations:

1. Reports with lines of varying lengths, where you may not know the
maximum.
2. Cases in which you want to organize and summarize the report
information before writing it out. C# has far richer data structures
for collecting and reorganizing information (although COBOL is no
slouch).

and the biggie

3. Reports that have information that can move about on a line or on
the page, for which you have to search using some sort of pattern. C#
has Regular Expressions. COBOL has... well, not much.

All in all, if the COBOL is costing you a lot of money, and switching
to another language (like C#) would save you money, I don't see COBOL
being so much better at the job that it would pay for itself.

If you have C# (or VB.NET) programmers on staff, give them a report to
parse and see how it goes. That will tell you a lot.

As for COBOL.NET compilers, yes, Fujitsu makes one. So does MicroFocus.

http://www.netcobol.com/

http://www.microfocus.com/index.asp?bhcp=1

Mar 2 '06 #5


"Peter Bromberg [C# MVP]" wrote:
dm1608,

I am reasonably sure that at least one vendor (Fujitsu, I believe) has a
COBOL.NET language product. You can use the existing COBOL codebase to create
.NET assemblies, and then simply decompile them into C# using a free product
such as Roeder's Reflector.


I'll admit to displaying my ignorance of COBOL here, but I thought it was a
non OO langauge. With .net being completely OO, I'm wondering how the
compiler would be able to convert the COBOL code into, IL at all, never mind
something non nightmarish when reflected back into C#.
Mar 2 '06 #6
Thus wrote Dan,
"Peter Bromberg [C# MVP]" wrote:
dm1608,

I am reasonably sure that at least one vendor (Fujitsu, I believe)
has a COBOL.NET language product. You can use the existing COBOL
codebase to create .NET assemblies, and then simply decompile them
into C# using a free product such as Roeder's Reflector.

I'll admit to displaying my ignorance of COBOL here, but I thought it
was a non OO langauge. With .net being completely OO, I'm wondering
how the compiler would be able to convert the COBOL code into, IL at
all, never mind something non nightmarish when reflected back into C#.


Yes, there is OO COBOL.
No, it's still not pretty. Just like its ancestor.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Mar 2 '06 #7
c# is pretty darn flexible for parsing just about anything. If you could
export the reports into xml, then parsing becomes almost a non-issue for
..Net languages. If not, you can manually parse, use regex, string.split.
Post a simple sample report and am sure you will see many c# ways to do it.

--
William Stacey [MVP]

"dm1608" <dm****@spam.net> wrote in message
news:ej*************@TK2MSFTNGP12.phx.gbl...
| We have a number of COBOL programs, and some were currently developing,
that
| simply read TEXT based reports and scrap the reports for various
| information.
|
| I'm curious to know if anyone has attempted to do this sort of thing using
| C#?
|
| I would love to get rid of my COBOL programmer and especially the code, if
I
| can. Apparently, it is much simplier to edit/parse text reports in COBOL
| than other languages.... so I'm being told.
|
|
| Any samples or online references would be great.
|
| Please note that some reports are multi-page and some may have special
| "binary" coded headers that is used for printers, etc., that are typically
| ignored by the parser.
|
|
|
Mar 2 '06 #8

"Dan Neely" <Da******@discussions.microsoft.com> wrote in message
news:D7**********************************@microsof t.com...
|
|
| "Peter Bromberg [C# MVP]" wrote:
|
| > dm1608,
| >
| > I am reasonably sure that at least one vendor (Fujitsu, I believe) has a
| > COBOL.NET language product. You can use the existing COBOL codebase to
create
| > .NET assemblies, and then simply decompile them into C# using a free
product
| > such as Roeder's Reflector.
|
| I'll admit to displaying my ignorance of COBOL here, but I thought it was
a
| non OO langauge. With .net being completely OO, I'm wondering how the
| compiler would be able to convert the COBOL code into, IL at all, never
mind
| something non nightmarish when reflected back into C#.

COBOL is not the COBOL it was 20 years ago. Microfocus an Fujitsu have both
a version that compiles to MSIL and supports the OO paradigm. As a business
oriented application builder it has some language features not available in
C# (which is a general purpose language) and the Framework.
Ever tried to write some CICS transactions using C#? A few hundred lines of
MF Cobol code is all you need to build a 3270 CICS front-end. Note also that
it perfectly integrates into .NET so it can access all framework features
available to the other .NET languages (think DB connections through ADO.NET,
remoting, enterprise services, XML etc....)
Really a nice product, gaining some popularity in large businesses
(especially main-frame scenarios), but quite expensive.
Willy.
Mar 2 '06 #9
We use MicroFocus COBOL for .NET 2003. One of the other main issues I have
with MicroFocus is that they require me to have a licensing server on the
network. If I write a MicroFocus COBOL program on my development machine,
it will run fine. As soon as I give my EXE to someone else to run... it
will fail because I have to have a license server somewhere on the network.
Very lame.

It's also very costly.

I can write many of the same apps in .NET VB or C# and not have to worry
about a stupid licensing dependencies.

Opinions?


"Joerg Jooss" <ne********@joergjooss.de> wrote in message
news:94**************************@msnews.microsoft .com...
Thus wrote Dan,
"Peter Bromberg [C# MVP]" wrote:
dm1608,

I am reasonably sure that at least one vendor (Fujitsu, I believe)
has a COBOL.NET language product. You can use the existing COBOL
codebase to create .NET assemblies, and then simply decompile them
into C# using a free product such as Roeder's Reflector.

I'll admit to displaying my ignorance of COBOL here, but I thought it
was a non OO langauge. With .net being completely OO, I'm wondering
how the compiler would be able to convert the COBOL code into, IL at
all, never mind something non nightmarish when reflected back into C#.


Yes, there is OO COBOL. No, it's still not pretty. Just like its ancestor.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de

Mar 3 '06 #10
AAJ
I can't help with an answer, but all the programmers in our office agree its
one of the best posts we have ever read - we all feel very nervous !!!

"dm1608" <dm****@spam.net> wrote in message
news:ej*************@TK2MSFTNGP12.phx.gbl...
We have a number of COBOL programs, and some were currently developing,
that simply read TEXT based reports and scrap the reports for various
information.

I'm curious to know if anyone has attempted to do this sort of thing using
C#?

I would love to get rid of my COBOL programmer and especially the code, if
I can. Apparently, it is much simplier to edit/parse text reports in
COBOL than other languages.... so I'm being told.
Any samples or online references would be great.

Please note that some reports are multi-page and some may have special
"binary" coded headers that is used for printers, etc., that are typically
ignored by the parser.

Mar 3 '06 #11


"Willy Denoyette [MVP]" wrote:

"Dan Neely" <Da******@discussions.microsoft.com> wrote in message
news:D7**********************************@microsof t.com...
|
|
| "Peter Bromberg [C# MVP]" wrote:
|
| > dm1608,
| >
| > I am reasonably sure that at least one vendor (Fujitsu, I believe) has a
| > COBOL.NET language product. You can use the existing COBOL codebase to
create
| > .NET assemblies, and then simply decompile them into C# using a free
product
| > such as Roeder's Reflector.
|
| I'll admit to displaying my ignorance of COBOL here, but I thought it was
a
| non OO langauge. With .net being completely OO, I'm wondering how the
| compiler would be able to convert the COBOL code into, IL at all, never
mind
| something non nightmarish when reflected back into C#.

COBOL is not the COBOL it was 20 years ago. Microfocus an Fujitsu have both
a version that compiles to MSIL and supports the OO paradigm.
So the new compilers can only convert Object Cobol into MSIL, and not nonOO
legacy code?

Ever tried to write some CICS transactions using C#? A few hundred lines of
MF Cobol code is all you need to build a 3270 CICS front-end.


I've never had to do anything mainframe related, and never heard of cics
before today.
Mar 3 '06 #12

"Dan Neely" <Da******@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com...
|
|
| "Willy Denoyette [MVP]" wrote:
|
| >
| > "Dan Neely" <Da******@discussions.microsoft.com> wrote in message
| > news:D7**********************************@microsof t.com...
| > |
| > |
| > | "Peter Bromberg [C# MVP]" wrote:
| > |
| > | > dm1608,
| > | >
| > | > I am reasonably sure that at least one vendor (Fujitsu, I believe)
has a
| > | > COBOL.NET language product. You can use the existing COBOL codebase
to
| > create
| > | > .NET assemblies, and then simply decompile them into C# using a free
| > product
| > | > such as Roeder's Reflector.
| > |
| > | I'll admit to displaying my ignorance of COBOL here, but I thought it
was
| > a
| > | non OO langauge. With .net being completely OO, I'm wondering how the
| > | compiler would be able to convert the COBOL code into, IL at all,
never
| > mind
| > | something non nightmarish when reflected back into C#.
| >
| > COBOL is not the COBOL it was 20 years ago. Microfocus an Fujitsu have
both
| > a version that compiles to MSIL and supports the OO paradigm.
|
| So the new compilers can only convert Object Cobol into MSIL, and not
nonOO
| legacy code?
|
|

No at all, the .NET Cobol compiler can emit CIL to run under the CLR or
just native code and integrates with VS.

| > Ever tried to write some CICS transactions using C#? A few hundred lines
of
| > MF Cobol code is all you need to build a 3270 CICS front-end.
|
| I've never had to do anything mainframe related, and never heard of cics
| before today.

I see, but there other features included, for instance you can expose COBOL
objects (CLR objects) as JavaBeans, COBOL can call Java objects and Java can
call COBOL objects through their built-in J2EE connector.

Willy.
Mar 3 '06 #13
Thus wrote dm1608,
We use MicroFocus COBOL for .NET 2003. One of the other main issues
I have with MicroFocus is that they require me to have a licensing
server on the network. If I write a MicroFocus COBOL program on my
development machine, it will run fine. As soon as I give my EXE to
someone else to run... it will fail because I have to have a license
server somewhere on the network. Very lame.

It's also very costly.

I can write many of the same apps in .NET VB or C# and not have to
worry about a stupid licensing dependencies.

Opinions?


I thought they'd got rid of that with their latest version of NetExpress
and ServerExpress... ouch!
--
Joerg Jooss
ne********@joergjooss.de
Mar 3 '06 #14
Yeah--I basically told their sales person that I'd rewrite any new apps
using less expensive solutions going forward because they just priced
themselves out of the market. If every application created its own
licensing server... I think I would have to find a new field.

"Joerg Jooss" <ne********@joergjooss.de> wrote in message
news:94**************************@msnews.microsoft .com...
Thus wrote dm1608,
We use MicroFocus COBOL for .NET 2003. One of the other main issues
I have with MicroFocus is that they require me to have a licensing
server on the network. If I write a MicroFocus COBOL program on my
development machine, it will run fine. As soon as I give my EXE to
someone else to run... it will fail because I have to have a license
server somewhere on the network. Very lame.

It's also very costly.

I can write many of the same apps in .NET VB or C# and not have to
worry about a stupid licensing dependencies.

Opinions?


I thought they'd got rid of that with their latest version of NetExpress
and ServerExpress... ouch!
--
Joerg Jooss
ne********@joergjooss.de

Mar 3 '06 #15
I believe that the licensing is for the COBOL runtime: all of that
extra "COBOL" stuff without which a COBOL program can't survive.

My impression is that their target for this whole rig-up is "big iron"
shops that want to get their COBOL programs off of their big machines
and onto smaller servers, with the added bonus of being able to port
them to .NET and maybe slap a WinForms front end on them.

I'm heading down to the MicroFocus conference ten days, but my
impression from a couple of years ago is that they have no illusions
that they're going to get a lot of new business jumping on board making
COBOL their "language of choice" for development. As Joerg points out,
it's not a pretty language, and the O-O version is even worse. If I
were writing a program to distribute to all and sundry, I wouldn't be
doing it in COBOL. In fact, in our shop, all client-side development is
in C# or Access (ugh). We couldn't care less about COBOL.NET.

So, I think that MicroFocus is targeting the legacy "big iron" market,
where paying for a license server is no big deal, and IMHO it's a smart
move on their part.

Mar 3 '06 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

242
by: James Cameron | last post by:
Hi I'm developing a program and the client is worried about future reuse of the code. Say 5, 10, 15 years down the road. This will be a major factor in selecting the development language. Any...
3
by: KLomax | last post by:
I work at a small company that has custom software written in cobol. This software performs financial payment processing. There are about 300 programs with I’m guessing 1M+ lines of code. The...
2
by: none | last post by:
Hi, Any one know of some code to read cobol data files.... thanks timb
30
by: Stuart Turner | last post by:
Hi Everyone, I'm working hard trying to get Python 'accepted' in the organisation I work for. I'm making some good in-roads. One chap sent me the text below on his views of Python. I wondered...
4
by: Spufi | last post by:
I have read several messages on converting packed decimals (EBCDIC) in a C++ program, but they were all for AS400 systems. I am looking for a way to convert the packed decimals in a COBOL program...
0
by: cobug | last post by:
Dear COBOL Users, Articles are being sought for the COBOL User Groups (COBUG) newsletters. Will you help us in our efforts to provide newsletters for the COBOL community at large? The...
1
by: michel abboud | last post by:
hello , i have a lot of software commercial packages made in cobol language but this ( cobol ) language is not used anymore thousands of programs will be rejected with my...
1
by: SLC via DBMonster.com | last post by:
Hello I'm a newbie to this and I need help, please My question is, we currently have a IDMS db and will be converting to DB2. What are the things I should do? The IDMS has not been documented very...
2
by: clintonb | last post by:
Victor said: The double value that I'm trying to convert to GCSMoney (which is implemented as cents) was produced by multiplying a dollar amount by an interest rate to get interest. double...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.