# Ruby and Cobol

**URL:** <https://www.ruby-forum.com/t/ruby-and-cobol/95831>\
**Category:** Ruby\
**Created:** [June 15, 2006, 10:33am UTC](https://www.ruby-forum.com/t/ruby-and-cobol/95831 "2006-06-15T10:33:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ppalmer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/858c86/32.png) [@ppalmer](https://www.ruby-forum.com/u/ppalmer)\
**Post date:** [June 15, 2006, 10:33am UTC](https://www.ruby-forum.com/t/ruby-and-cobol/95831/1 "2006-06-15T10:33:21Z")

</div>

Hi,

The company I’m working for at present has everything written in  
acuCOBOL with flat indexed files. They’re trying to migrate to Oracle  
but that’s a long way off. Is there any way to access these data files  
from Ruby or would anyone have the expertise to create such an  
interface? I wouldn’t know where to start but there’s so much more I  
could do for them if Ruby had access to that mine of information!

Cheers,

Pete

---

<div class="post-metadata">

**Author:** ![ppalmer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/858c86/32.png) [@ppalmer](https://www.ruby-forum.com/u/ppalmer)\
**Post date:** [June 15, 2006, 11:06am UTC](https://www.ruby-forum.com/t/ruby-and-cobol/95831/2 "2006-06-15T11:06:23Z")

</div>

Maybe use something like this?

[http://www.siber.com/sct/datafile/data-viewer.html](http://www.siber.com/sct/datafile/data-viewer.html)

T.

---

<div class="post-metadata">

**Author:** ![ppalmer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/858c86/32.png) [@ppalmer](https://www.ruby-forum.com/u/ppalmer)\
**Post date:** [June 15, 2006, 11:59am UTC](https://www.ruby-forum.com/t/ruby-and-cobol/95831/3 "2006-06-15T11:59:18Z")

</div>

Hi,

Unfortunately that won’t work ☹

Whilst we can extract the data and import it into say Oracle or  
Postgres,  
the problem is that the live system uses the cobol files. The acuCOBOL  
SQL  
interface is far too slow to switch to Oracle directly and so Oracle is  
only used for data mining.

One of the programs I want to write is a kiosk type application for use  
in  
the stores where customers can take stock, see what’s available and what  
sizes etc and see if they can either get it in this store or another.

Unfortunately the Oracle data is a day old and thus won’t be accurate  
enough for the task - which was why I was asking about accessing the  
cobol  
files directly…

Cheers,

Pete

---

<div class="post-metadata">

**Author:** ![ppalmer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/858c86/32.png) [@ppalmer](https://www.ruby-forum.com/u/ppalmer)\
**Post date:** [June 16, 2006, 11:00pm UTC](https://www.ruby-forum.com/t/ruby-and-cobol/95831/4 "2006-06-16T23:00:24Z")

</div>

On Thu, Jun 15, 2006 at 05:33:36PM +0900, Pete Palmer wrote:

> Pete
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

Hi Pete,

I’ve written similar things for Microfocus COBOL, using calls to C API  
to small COBOL program to acess ISAM data, but what’s much easier  
is to just write small COBOL program that reads and writes from socket  
or pipe to talk to external programs, Then you just basically send  
and receive all data as strings.

Ralph “PJPizza” Siegler

---

<div class="post-metadata">

**Author:** ![ppalmer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/858c86/32.png) [@ppalmer](https://www.ruby-forum.com/u/ppalmer)\
**Post date:** [June 15, 2006, 12:59pm UTC](https://www.ruby-forum.com/t/ruby-and-cobol/95831/5 "2006-06-15T12:59:24Z")

</div>

Peter P. wrote:

> Hi,
> 
> Unfortunately that won’t work ☹
> 
> Whilst we can extract the data and import it into say Oracle or Postgres,  
> the problem is that the live system uses the cobol files. The acuCOBOL SQL  
> interface is far too slow to switch to Oracle directly and so Oracle is  
> only used for data mining.

Do you have a data format specification? In my limited experience, COBOL  
data files tend to be a simple fixed-length record format, which should  
make it easy to extract data using scan(/.{length}/) and pack/unpack.

Cheers,  
Dave
