Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cobol workbook to java sturctures

Status
Not open for further replies.

amarg

Programmer
Nov 19, 2002
106
IN
Hi,

How I can convert cobol copybook (structure) into Java variables.

I want to write a program which can convert simple extract
file in xls or txt or something else. My extract file is
written by cobol exe.

I don't have any Idea How I should convet cobol structure in java structure.

I got one jar file which can convert my cobol structure in XML file. but still I have to do lot.

If anyone can help me to guide what else I can check.

Regards,
Amar
 
And for those of us who don't know what a "cobol copybook (structure)" looks like ...

--------------------------------------------------
Free Database Connection Pooling Software
 
Sorry for that. You are right, Cobol is too old language, not used for new product.

copybook like struct in c, which are defined in header file and used in the .cbl files.

 
I've used Cobol, but still don't understand what you're talking about.

Translate Cobol copies into Java code?

Maybe you should provide a little example of input to your program and expected output.

Cheers,

Dian
 
ok, I am making it simple.

There is a extract file written by cobol process.
Cobol sturcture is something like

44 ROWID PIC X(18) .
44 CYCLE-CODE PIC S9(2) COMP .
44 CYCLE-MONTH PIC S9(2) COMP .
44 CYCLE-YEAR PIC S9(4) COMP .
44 ACTV-CODE PIC X(4) .

Now this extract I have to read but using java.
Is there any clue what I can do for this.

Thanks,
Amar
 
Ok, let's see if I understood.

You have a Cobol program that generates an output file and you want a Java program to read the contents of that file.

If so, you need a couple of things:

1.- Know the format of the data written by the Cobol program
2.- Know the encoding Cobol uses. From my experience, EBCDIC
3.- Know how to read files in Java: (There was a better one but I can't find it)
4.- Know what you want to do with the parsed data.

Cheers,

Dian
 
It depends on what cobol it is, could be EBCDIC or ASCII.


Looks like data expectd is

String[18]
2 bit int
2 bit int
4 bit int
String[4]

It is 9 years since I was a pro at cobol but I think that is it.

[blue]Arguably the best cat skinner around ! [/blue]

Cheers
Scott
 
Hi,

It's EBCDIC.
Input structure can be anything like

05 FBF-VERB PIC X(4) .
05 FILLER PIC X(4).
05 COMM-ACTV-AMT PIC S9(7)V9(4) COMP .
05 COMM-MONTHLY-RATE PIC S9(7)V9(4) COMP .
05 COMM-TAX-AMT PIC S9(7)V9(4) COMP .
05 COMM-ADJUSTED-AMT PIC S9(7)V9(4) COMP .
05 COMM-PREV-ADJUSTED PIC S9(7)V9(4) COMP .
05 COMM-ORIG-NET-CHG-AMT PIC S9(7)V9(4) COMP .
05 COMM-DISCOUNTED-AMT PIC S9(7)V9(4) COMP .
05 COMM-ACT-MINRQ-USG-CHG PIC S9(7)V9(4) COMP .
05 COMM-MIN-REQ-USG-CHG PIC S9(7)V9(4) COMP .
05 NOT-ORIG-CHARGE PIC X(1) .
05 FILLER PIC X(7).

Only I have to find out who much space is taken by these variables.
I know know it's fix size for double values or not.
If not then it will be lot of problems.
 
I think you may have to watch the sign on the Pic s9(7)v9(4) COMP SYNC fields, and watch for the decimal place. The sign will be in evidence if negative but not if +tve. There will be no decimal point either. The S and the V are just there so it knows where to expect them if they exist.

[blue]Arguably the best cat skinner around ! [/blue]

Cheers
Scott
 
anything Pic X is a string of either x or whaterver number of x's there are.

Pic X = 1
Pic xx = 2
Pic xxx = 3
Pic X(4) = 4.

Filler = redundant space, but watch for redefinitions this could be like super classes.

[blue]Arguably the best cat skinner around ! [/blue]

Cheers
Scott
 
yes you are right. But give me a clue "s9(7)v9(4) COMP SYNC " will take how much bits.
 
Hi,

I already took the parser for cobol workbook.
It's giving me a xml file like



<fbfVerb length="4" level="5" mfname="FBF-VERB" pic="X(4)" position="1" />
<filler length="4" level="5" mfname="FILLER" pic="X(4)" />
<commActvAmt comp="0" isnumber="true" length="11" level="5" mfname="COMM-ACTV-AMT" pic="S9(7)V9(4)" scale="4" signed="true" usage="COMP" />


and any xml parser can read this file and store this information in Attribute class.

Only the thing, how much bits I have to read based on this
information. PIC X is easy. but problems are int and float.

Amar
 
Now you are testing my memory.

I think that it crams s(9)7V9(4) COMP SYNC occupies 4 bytes. I will check, I actually have a manwell at home.

COMP SYNC stands for computational synchronised btw.

[blue]Arguably the best cat skinner around ! [/blue]

Cheers
Scott
 
Hi,

What I saw in extract file.

if length >= 10 then 8 bit int
if lenght < 9 then 4 bit int
and so on.

not in java We have byte which is 8 bit.
How should read 4 bit and convert into int.
 
short ?

[blue]Arguably the best cat skinner around ! [/blue]

Cheers
Scott
 
short is 16 bit. I have to read 4 bit.
 
I don't remember any way in Java to read bits.

I think you should read it as bytes and the apply binarry masks to select the four bits you need.

Cheers,

Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top