Re: I need help!!
- From: "Pete Dashwood" <dashwood@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 16 Jun 2007 12:22:49 +1200
<Starkey2600@xxxxxxxxx> wrote in message
news:1181933898.182569.271260@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hey everyone, I'm having issues trying to pull data from a fixed
length binary file from a COBOL program that was written a long, long
time ago. I have the source file, I have the data file, I found which
actual "program" writes to the binary file, I opened the source for
that program and found what appears to be copybook data. I've been
trying to use the java based record editor program on sourceforge to
extract the data, but as of now I'm so lost. Could someone please
help me out?
Here is a piece of the source file containing what I think is copybook
info.
000010 IDENTIFICATION DIVISION.
000040 PROGRAM-ID. PRD009SR.
000070*
000100* THIS PROGRAM
000130* PRINTS ITEMS IN INVENTORY WITH NO HISTORY
000160* FINISH GOODS INVENTORY
000190 AUTHOR. BPS COMPUTER SERVICE.
000220 DATE-WRITTEN. 840618.
000250 ENVIRONMENT DIVISION.
000280 CONFIGURATION SECTION.
000310 SOURCE-COMPUTER. RMC.
000340 OBJECT-COMPUTER. RMC.
000370 INPUT-OUTPUT SECTION.
000400 FILE-CONTROL.
000430 SELECT MASTER ASSIGN TO RANDOM,
000460 "/usr/jlw/datafiles/FGINVMST"
000490 ORGANIZATION IS INDEXED,
000520 ACCESS IS DYNAMIC,
000550 RECORD KEY IS MAST-KEY1,
000580 FILE STATUS IS FS.
000760 SELECT PRINTFL ASSIGN TO PRINT, "PRINTER".
000790 DATA DIVISION.
000820 FILE SECTION.
000850 FD MASTER,
000880 RECORD CONTAINS 256 CHARACTERS,
000910 BLOCK CONTAINS 004 RECORDS,
000940 LABEL RECORDS ARE STANDARD,
000970*
001000 DATA RECORD IS MAST-RECD.
001030 01 MAST-RECD.
001060* PART NUMBER
001090 05 FIELD-01 PIC 9(008).
001120 05 FIELD-1A PIC 99.
001150* SUB-PART
001180 05 FIELD-02 PIC X(015).
001210* DESCRIPTION
001240 05 FIELD-03 PIC X(020).
001270* LABOR PRICE
001300 05 FIELD-04 PIC S9(007)V99, COMP-3.
001330* LAB-MAT-PRICE
001360 05 FIELD-05 PIC S9(007)V99, COMP-3.
001390* DRAWING NUMBER
001420 05 FIELD-06 PIC X(008).
001450* DRAWER NUMBER
001480 05 FIELD-07 PIC X(003).
001510* HISTORY QUANYITY
001540 05 FIELD-08 PIC S9(007), COMP-3.
001570* WORK IN PROCESS
001600 05 FIELD-09 PIC S9(007), COMP-3.
001630* SOLD
001660 05 FIELD-10 PIC S9(007), COMP-3.
001690* QUANTITY ON HAND
001720 05 FIELD-11 PIC S9(007), COMP-3.
001750* MINIMUM QUANTITY
001780 05 FIELD-12 PIC S9(007), COMP-3.
001810* VOLUME
001840 05 FIELD-13 PIC S9(03) COMP-3.
001841 05 FIELD-13A PIC S9(03)V99 COMP-3.
001842 05 FIELD-13B PIC S9(03) COMP-3.
001843 05 FIELD-13C PIC S9(03)V99 COMP-3.
001844 05 FIELD-13D PIC S9(03) COMP-3.
001845 05 FIELD-13E PIC S9(03)V99 COMP-3.
001846 05 LAB-ONLY PIC X.
001870* FILLER-3
001900 05 MATCOST PIC S9(7)V99 COMP-3.
001930 05 LABCOST PIC S9(7)V99 COMP-3.
001940 05 FIELD-14A PIC S9(3) COMP-3.
001940 05 FIELD-14B PIC S9(3)V99 COMP-3.
001940 05 FIELD-14C PIC S9(3) COMP-3.
001940 05 FIELD-14D PIC S9(3)V99 COMP-3.
001940 05 FIELD-14E PIC S9(3) COMP-3.
001940 05 FIELD-14F PIC S9(3)V99 COMP-3.
001940 05 FILLER PIC X(129).
002020 01 KEY-FIELD1.
002050 05 MAST-KEY1 PIC X(010).
002080 05 REDF-KEY1 REDEFINES MAST-KEY1 PIC X(010).
002110 05 FILLER PIC X(246).
002560 FD PRINTFL LABEL RECORDS ARE OMITTED.
002590 01 FULL-PRINT PIC X(132).
002620 01 PRINT1.
002650 05 FILLER PIC X(001).
002680 05 PRTFLD01 PIC X(008).
002681 05 FILLERX PIC XX.
002710 05 PRTFLD1A PIC X(003).
002740 05 PRTFLD02 PIC X(015).
002770 05 FILLER PIC X(002).
002800 05 PRTFLD03 PIC X(020).
002830 05 FILLER PIC X(009).
002860 05 PRTFLD04 PIC X(011).
002890 05 FILLER PIC X(002).
002920 05 PRTFLD05 PIC X(011).
002950 05 FILLER PIC X(004).
002980 05 PRTFLD09 PIC X(008).
003010 05 FILLER PIC X(003).
003040 05 PRTFLD10 PIC X(008).
003070 05 FILLER PIC X(002).
003100 05 PRTFLD11 PIC X(008).
003130 05 FILLER PIC X(015).
003160 01 PRINT2.
003190 05 FILLER PIC X(031).
003220 05 PRTFLD06 PIC X(008).
003250 05 FILLER PIC X(002).
003280 05 PRTFLD07 PIC X(003).
003310 05 FILLER PIC X(003).
003340 05 PRTFLD08 PIC X(008).
003370 05 FILLER PIC X(004).
003400 05 PRTFLD12 PIC X(008).
003430 05 FILLER PIC X(003).
003460 05 PRTFLD13 PIC X(005).
003490 05 FILLER PIC X(002).
003490 05 PRTFLD13A PIC X(008).
003491 05 FILLER PIC X(002).
003492 05 PRTFLD13B PIC X(005).
003493 05 FILLER PIC X(002).
003494 05 PRTFLD13C PIC X(008).
003495 05 FILLER PIC X(002).
003496 05 PRTFLD13D PIC X(005).
003497 05 FILLER PIC X(002).
003498 05 PRTFLD13E PIC X(008).
003499 05 FILLER PIC X(003).
003500 05 PRT-COST PIC ZZZ,ZZZ.99.
003550 WORKING-STORAGE SECTION.
003580 77 FS PIC XX VALUE ZEROS.
003610 77 ACTION PIC 9 VALUE ZEROS.
003640 77 T-ANWS PIC X VALUE SPACE.
003642 77 QTY-ANSW PIC X VALUE SPACE.
003640 77 PR-ANWR PIC X VALUE SPACE.
003670 77 PAUSE PIC X.
003700 77 NINES PIC X(20) VALUE "99999999999999999999".
003730 77 HEAD-SW PIC X VALUE ZEROS.
003760 77 LINECNT PIC 999 VALUE ZEROS.
003790 77 CURSOR-MESG PIC 99999 VALUE 20001.
003820 77 ERROR-SW PIC X VALUE ZEROS.
003850 77 LOOP-CTR PIC 9999 VALUE ZEROS.
003880 77 WORK-LINE PIC 99 VALUE ZEROS.
003910 77 SPACE-LINE PIC X(77) VALUE SPACES.
003940 77 ASTER PIC X VALUE "*".
003970 77 CHAR PIC X VALUE SPACES.
004000 77 INSPCT PIC X(40) VALUE SPACES.
004030 77 DISPF PIC X(10) VALUE SPACES.
004060 77 NINE PIC X VALUE "9".
004090 77 ANSWER PIC X VALUE ZEROS.
004120 77 RUN-TYPE PIC X(10) VALUE ZEROS.
004180 77 SCREEN-SPACING PIC 9(001) VALUE 1.
004210 77 SCREEN-TYPE PIC X(001) VALUE " ".
004240 77 CLR-LINE PIC X(80) VALUE ALL " ".
004241 77 EDIT-TOT PIC ZZZ,ZZZ.99-.
004242 77 PRTFLD PIC X VALUE SPACE.
004243 77 STK-ANSW PIC X VALUE SPACES.
004242 01 MAST-KEY-END PIC X(010) VALUE ZEROS.
004242 01 MAST-END REDEFINES MAST-KEY-END.
004242 05 END-ITEM PIC 9(08).
004242 05 END-SUFFIX PIC 9(02).
004270 01 MASTER-HEAD.
004300 02 FILLER PIC X.
004330 02 FILLER PIC X(23) VALUE "FILE MAINTENANCE FOR -
".
004360 02 MAST-HED2 PIC X(30) VALUE "FINISH GOODS INVENTOY".
004390 01 HD-ASTER PIC X(132) VALUE ALL "*".
004420 01 HEADING-DATA.
004450 05 HEADF-01 PIC X(011), VALUE "PART NUMBER".
004480 05 ABVHED01 PIC X(010), VALUE "PART NUMBR".
004510 05 HEADF-02 PIC X(015), VALUE " SUB-PART
".
004540 05 ABVHED02 PIC X(015), VALUE " SUB-PART #".
004570 05 HEADF-03 PIC X(020), VALUE
004600 " DESCRIPTION ".
004630 05 ABVHED03 PIC X(020), VALUE
004660 " DESCRIPTION ".
004690 05 HEADF-04 PIC X(010), VALUE "LABR PRICE".
004720 05 ABVHED04 PIC X(010), VALUE "LABR PRICE".
004750 05 HEADF-05 PIC X(014), VALUE "LAB-MATR-PRICE".
004780 05 ABVHED05 PIC X(011), VALUE "L-MT-PRICE".
004810 05 HEADF-06 PIC X(009), VALUE "DRAWING #".
004840 05 ABVHED06 PIC X(005), VALUE "DRG-#".
004870 05 HEADF-07 PIC X(006), VALUE "DRAWER".
004900 05 ABVHED07 PIC X(005), VALUE "DRWER".
004930 05 HEADF-08 PIC X(007), VALUE "HISTORY".
004960 05 ABVHED08 PIC X(008), VALUE "HISTORY".
004990 05 HEADF-09 PIC X(016), VALUE "WORK IN PROGRESS".
005020 05 ABVHED09 PIC X(008), VALUE "WORK IN".
005050 05 HEADF-10 PIC X(007), VALUE "SOLD ".
005080 05 ABVHED10 PIC X(005), VALUE "SOLD ".
005110 05 HEADF-11 PIC X(007), VALUE "QTY-HND".
005140 05 ABVHED11 PIC X(008), VALUE "QTY-HND".
005170 05 HEADF-12 PIC X(007), VALUE "MINIMUM".
005200 05 ABVHED12 PIC X(008), VALUE "MIN-QTY".
005230 05 HEADF-13 PIC X(016), VALUE "QTY-1 ".
005260 05 ABVHED13 PIC X(005), VALUE "QTY-1".
005290 05 HEADF-14 PIC X(014), VALUE " FILLER-3 ".
005320 05 ABVHED13A PIC X(008), VALUE "PRICE-1".
005321 05 ABVHED13B PIC X(005), VALUE "QTY-2".
005322 05 ABVHED13C PIC X(008), VALUE "PRICE-2".
005323 05 ABVHED13D PIC X(005), VALUE "QTY-3".
005324 05 ABVHED13E PIC X(008), VALUE "PRICE-3".
005890 01 CURSOR01 PIC 9(005), VALUE 04002.
005920* PART NUMBER
005950 01 INPUT-01 PIC 9(008).
005980 01 OUTPUT01 REDEFINES INPUT-01 PIC Z(008).
006010 01 TESTTP01 REDEFINES INPUT-01 PIC X(008).
006040 01 CURSOR1A PIC 9(005), VALUE 04010.
006070 01 INPUT-1A PIC 9(002).
006100 01 OUTPUT1A REDEFINES INPUT-1A PIC XX.
006130 01 TESTP1A REDEFINES INPUT-1A PIC XX.
006160 01 CURSOR02 PIC 9(005), VALUE 04015.
006190* SUB-PART
006220 01 INPUT-02 PIC X(015).
006250 01 OUTPUT02 REDEFINES INPUT-02 PIC X(015).
006280 01 TESTTP02 REDEFINES INPUT-02 PIC X(015).
006310 01 CURSOR03 PIC 9(005), VALUE 04034.
006340* DESCRIPTION
006370 01 INPUT-03 PIC X(020).
006400 01 OUTPUT03 REDEFINES INPUT-03 PIC X(020).
006430 01 TESTTP03 REDEFINES INPUT-03 PIC X(020).
006460 01 CURSOR04 PIC 9(005), VALUE 08002.
006490* LABOR PRICE
006520 01 INPUT-04 PIC S9(008)V99.
006550 01 OUTPUT04 REDEFINES INPUT-04 PIC Z(007).99-.
006580 01 TESTTP04 REDEFINES INPUT-04 PIC X(011).
006610 01 CURSOR05 PIC 9(005), VALUE 08017.
006640* LAB-MATR-PRICE
006670 01 INPUT-05 PIC S9(008)V99.
006700 01 OUTPUT05 REDEFINES INPUT-05 PIC Z(007).99-.
006730 01 TESTTP05 REDEFINES INPUT-05 PIC X(011).
006760 01 CURSOR06 PIC 9(005), VALUE 08032.
006790* DRAWING NUMBER
006820 01 INPUT-06 PIC X(008).
006850 01 OUTPUT06 REDEFINES INPUT-06 PIC X(008).
006880 01 TESTTP06 REDEFINES INPUT-06 PIC X(008).
006910 01 CURSOR07 PIC 9(005), VALUE 08048.
006940* DRAWER NUMBER
006970 01 INPUT-07 PIC X(003).
007000 01 OUTPUT07 REDEFINES INPUT-07 PIC X(003).
007030 01 TESTTP07 REDEFINES INPUT-07 PIC X(003).
007060 01 CURSOR08 PIC 9(005), VALUE 08062.
007090* HISTORY QUANYITY
007120 01 INPUT-08 PIC S9(007).
007150 01 OUTPUT08 REDEFINES INPUT-08 PIC Z(007)-.
007180 01 TESTTP08 REDEFINES INPUT-08 PIC X(008).
007210 01 CURSOR09 PIC 9(005), VALUE 12002.
007240* WORK IN PROCESS
007270 01 INPUT-09 PIC S9(007).
007300 01 OUTPUT09 REDEFINES INPUT-09 PIC Z(007)-.
007330 01 TESTTP09 REDEFINES INPUT-09 PIC X(008).
007360 01 CURSOR10 PIC 9(005), VALUE 12019.
007390* SOLD
007420 01 INPUT-10 PIC S9(007).
007450 01 OUTPUT10 REDEFINES INPUT-10 PIC Z(007)-.
007480 01 TESTTP10 REDEFINES INPUT-10 PIC X(008).
007510 01 CURSOR11 PIC 9(005), VALUE 12031.
007540* QUANTITY ON HAND
007570 01 INPUT-11 PIC S9(007).
007600 01 OUTPUT11 REDEFINES INPUT-11 PIC Z(007)-.
007630 01 TESTTP11 REDEFINES INPUT-11 PIC X(008).
007660 01 CURSOR12 PIC 9(005), VALUE 16002.
007690* MINIMUM QUANTITY
007720 01 INPUT-12 PIC S9(007).
007750 01 OUTPUT12 REDEFINES INPUT-12 PIC Z(007)-.
007780 01 TESTTP12 REDEFINES INPUT-12 PIC X(008).
007810 01 CURSOR13 PIC 9(005), VALUE 16025.
007840* QUANTITY-1
007870 01 INPUT-13 PIC S9(003).
007900 01 OUTPUT13 REDEFINES INPUT-13 PIC Z(003)-.
007930 01 TESTTP13 REDEFINES INPUT-13 PIC X(004).
007960 01 CURSOR14 PIC 9(005), VALUE 16048.
007990* FILLER-3
008020 01 INPUT-14 PIC X(014).
008050 01 OUTPUT14 REDEFINES INPUT-14 PIC X(014).
008080 01 TESTTP14 REDEFINES INPUT-14 PIC X(014).
008081 01 OUTPUT13A PIC Z(3).99-.
008082 01 OUTPUT13B PIC Z(3)-.
008083 01 OUTPUT13C PIC Z(3).99-.
008084 01 OUTPUT13D PIC Z(3)-.
008085 01 OUTPUT13E PIC Z(3).99-.
008086 01 EDIT-FLD PIC S9(3)V99.
008110 01 CC-LC.
008140 05 CC-LINE PIC 99.
008170 05 CC-COL PIC 999.
008200 01 REDF-CCL REDEFINES CC-LC.
008230 02 L PIC 99.
008260 02 P PIC 999.
008290 01 PRINTER-HEAD.
008320 02 FILLER PIC X(06) VALUE " DATE".
008350 02 PRT-DATE PIC X(20) VALUE SPACES.
008380 02 FILLER PIC X(30) VALUE "RECORD PRINT NO
ACTIVITY".
008410 02 PRT-NAME PIC X(30) VALUE SPACES.
008440 02 FILLER PIC X(10) VALUE " PAGE ".
008470 02 PG-CTR PIC 999 VALUE ZEROS.
008500 01 CPU-DATE.
008530 02 CPU-YR PIC 99.
008560 02 CPU-MO PIC 99.
008590 02 CPU-DA PIC 99.
008620 01 REFORMATT-DATE.
008650 02 RFD-MO PIC 99.
008680 02 FILLER PIC X VALUE "/".
008710 02 RFD-DA PIC 99.
008740 02 FILLER PIC X VALUE "/".
008770 02 RFD-YR PIC 99.
008771 01 TOTALS.
008772 05 WK-AMT PIC S9(7)V99 VALUE ZEROS.
008773 05 TOT-LAB PIC S9(7)V99 VALUE ZEROS.
008774 05 TOT-L-M PIC S9(7)V99 VALUE ZEROS.
008775 05 TOT-INV PIC S9(7)V99 VALUE ZEROS.
008800 PROCEDURE DIVISION.
008830*
008860 STARTX.
You are trying to edit an indexed sequential file directly. Even WITHOUT
packed fields, this is not something you want to do for fun...
000310 SOURCE-COMPUTER. RMC.
000340 OBJECT-COMPUTER. RMC.
What is this, exactly? Is it a PC, mid-range, mainframe, can you give us the
make and model? Do you know what particalur Indexed Sequential software has
been used to create your file? (Is it PC ISAM, Mainframe VSAM/KSDS, what?)
Most COBOL environments have utilities available to create standard
sequential datasets from Indexed Sequential files. Do you have anything like
this?
Try and get the file into a more amenable format. The indexed file will
contain free space, space management fields, all kinds of stuff that just
muddies the water. Editing (even in "read only" mode) the actual dataset is
a last resort.
If you can get it into a simpler sequential format, you may have more
success editing it, but you will still have to deal with the packed fields.
(This can be done with Java or COBOL, see below.)
If you really can't convert it to a simpler format with a utility, do you
have a COBOL compiler available?
If you have:
1. Write a small COBOL program to convert all the packed fields to display.
It's very easy. Just copy the source you have at the moment, and add a
sequential dataset that is the same as the definition above, but with all
the COMP-3 clauses removed. In the procedure division, open the existing
file for input, and the new one for output, then read sequentially through
the Indexed file, moving each record read, FIELD BY FIELD to the output
record area and writing it. The end result will be a copy of your indexed
file that has all the packed fields converted to display.
2. Edit the new sequential "unpacked" version.
(Another possibility you could consider, if you have COBOL available, is to
amend the program which creates the Indexed file so that it simultaneously
creates an "unpacked" version which can be edited with normal tools.)
Really, it is time this system was converted to a database... The data can
then be easily passed and extracted by standard tools. Given it was written
in 1984, it should be a prime candidate for replacement. While it's all very
well saying "If it ain't broke, don't fix it..." the fact is that data from
it is required elsewhere, otherwise you wouldn't be undertaking this
exercise... to this extent, it IS broke...
If you DON'T have a COBOL compiler available you should still try and get
the file into a sequential version (with a Utility, as mentioned above). You
can then read it as a stream in Java and use one of the Java packages
available to deal with the packed fields. Have a look at:
http://benjaminjwhite.name/zdecimal/doc/name/benjaminjwhite/zdecimal/PackDec.html
BOTTOM LINE:
1. If you have a COBOL compiler that can compile the existing source, you
should create an unpacked version. I would also look at converting the
master file to RDB and converting the Indexed file access to SQL (even to
<shudder> embedded SQL in the COBOL...) I know that's easy for me to say, I
have tools to do it... (I'm happy to make them available to others, or do
the conversion for them, for a reasonable price...). The use of indexed
files is simply locking the data resource into COBOL and sooner or later the
bullet will have to be bitten. Conversion to RDB extends the useful life of
the existing system without requiring a rewrite or replacement, and keeping
the current logic. It simply opens up the data resource.
2. If you have to extract data from it in Java, you are in for a very hard
time. The cost of doing this now and in the future should be weighed against
the cost of replacing it with something more amenable.
(Personally, I would make a case to Management that they either obtain a
COBOL compiler for it, or replace the system, given that the data in it is
required elsewhere. Even if they go for replacement, the existing master
file is problematic. The data on it has to be extracted and converted to the
new system (hopefully) database.)
Frankly, if you don't have a COBOL compiler for this, you are pretty
screwed. Under those circumstances, I would be looking at a ONE TIME extract
from the master file, and I can't see people forming a line to do it...:-)
Pete.
.
- Follow-Ups:
- Re: I need help!!
- From: Benjamin White
- Re: I need help!!
- References:
- I need help!!
- From: Starkey2600@xxxxxxxxx
- I need help!!
- Prev by Date: Re: I need help!!
- Next by Date: Re: Clarification of LOCK clauses in 2002
- Previous by thread: Re: I need help!!
- Next by thread: Re: I need help!!
- Index(es):
Relevant Pages
|
|