For Programmers: Free Programming Magazines  


Home > Archive > Cobol > May 2006 > Variable length Records procesing on IBM Mainframes









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Variable length Records procesing on IBM Mainframes
hcmason@sbcglobal.net

2006-05-26, 6:55 pm

Hello:
Someone has given me some variable length records to process. No
copylib record layouts are available. Is there any way to tell how big
the record is that was just read?

ISPF says the input file has record length of 2075 (includes the 4
bytes size of record field)
Block size = 27998, recfm=VB.

My code in the data division:
001900 FD TEXT-VAR-FILE
002000 BLOCK CONTAINS 0 RECORDS
002100 * I THINK THE REAL LRECL IS 2075, BUT 4 BYTES USED FOR
002200 * RECORD LENGTH
002300 RECORD CONTAINS 80 TO 2071 CHARACTERS.
002400 01 TEXT-VAR-REC-80 PIC X(80).
002500 01 TEXT-VAR-RECORD PIC X(2071).

Actually, I'm not sure about the smallest record...

Is there a special register in cobol, or anythig to tell what the
length really was???

006200 Z0000-READ-INPUT.
006210 D DISPLAY 'Z0000-READ-INPUT'
006300 READ TEXT-VAR-FILE
006400 AT END
006500 MOVE 'Y' TO WS-EOF-SWITCH
006600 END-READ.

I'm planning on moving the entire record to a character array to pull
out the eye readable text...Unfortunately I'm not sure how long each
record will be, so I many end up getting bad results as I try to find
the last eye readable word, or terminate the parsing after the last
word/end of record....

Chris.

Michael Mattias

2006-05-26, 6:55 pm

<hcmason@sbcglobal.net> wrote in message
news:1148681398.865250.65430@j55g2000cwa.googlegroups.com...
> My code in the data division:
> 001900 FD TEXT-VAR-FILE
> 002000 BLOCK CONTAINS 0 RECORDS
> 002100 * I THINK THE REAL LRECL IS 2075, BUT 4 BYTES USED FOR
> 002200 * RECORD LENGTH
> 002300 RECORD CONTAINS 80 TO 2071 CHARACTERS.
> 002400 01 TEXT-VAR-REC-80 PIC X(80).
> 002500 01 TEXT-VAR-RECORD PIC X(2071).
>
> Actually, I'm not sure about the smallest record...
>
> Is there a special register in cobol, or anythig to tell what the
> length really was???


Re-readeth thy doc for the "RECORD CONTAINS" clause and I think ye shall
find what ye seth...

MCM







William M. Klein

2006-05-26, 6:55 pm

Assuming that you are using VS COBOL II, R3 (with NOCMPR2) *OR* later compiler,
then there is a solution. (With OS/VS COBOL there was also a "don't do this -
but it works" negative subscripting solution).

What you want to do is change

> 001900 FD TEXT-VAR-FILE
> 002000 BLOCK CONTAINS 0 RECORDS
> 002100 * I THINK THE REAL LRECL IS 2075, BUT 4 BYTES USED FOR
> 002200 * RECORD LENGTH
> 002300 RECORD CONTAINS 80 TO 2071 CHARACTERS.
> 002400 01 TEXT-VAR-REC-80 PIC X(80).
> 002500 01 TEXT-VAR-RECORD PIC X(2071).


to

> 001900 FD TEXT-VAR-FILE
> 002000 BLOCK CONTAINS 0 RECORDS
> 002100 * I THINK THE REAL LRECL IS 2075, BUT 4 BYTES USED FOR
> 002200 * RECORD LENGTH
> 002300 RECORD Varying in Size from 80 TO 2071

depending on Some-item-defined-in-WS.
> 002400 01 TEXT-VAR-REC-80 PIC X(80).
> 002500 01 TEXT-VAR-RECORD PIC X(2071).


Then in your working storage area define "some-item-defined-in-WS as an integer
numeric field. This field will include the actual record length (without the
"LLZZ" RDW field) after each read. For more information, check out:

http://publibz.boulder.ibm.com/cgi-...GY3LR30/5.2.5.3


--
Bill Klein
wmklein <at> ix.netcom.com
<hcmason@sbcglobal.net> wrote in message
news:1148681398.865250.65430@j55g2000cwa.googlegroups.com...
> Hello:
> Someone has given me some variable length records to process. No
> copylib record layouts are available. Is there any way to tell how big
> the record is that was just read?
>
> ISPF says the input file has record length of 2075 (includes the 4
> bytes size of record field)
> Block size = 27998, recfm=VB.
>
> My code in the data division:
> 001900 FD TEXT-VAR-FILE
> 002000 BLOCK CONTAINS 0 RECORDS
> 002100 * I THINK THE REAL LRECL IS 2075, BUT 4 BYTES USED FOR
> 002200 * RECORD LENGTH
> 002300 RECORD CONTAINS 80 TO 2071 CHARACTERS.
> 002400 01 TEXT-VAR-REC-80 PIC X(80).
> 002500 01 TEXT-VAR-RECORD PIC X(2071).
>
> Actually, I'm not sure about the smallest record...
>
> Is there a special register in cobol, or anythig to tell what the
> length really was???
>
> 006200 Z0000-READ-INPUT.
> 006210 D DISPLAY 'Z0000-READ-INPUT'
> 006300 READ TEXT-VAR-FILE
> 006400 AT END
> 006500 MOVE 'Y' TO WS-EOF-SWITCH
> 006600 END-READ.
>
> I'm planning on moving the entire record to a character array to pull
> out the eye readable text...Unfortunately I'm not sure how long each
> record will be, so I many end up getting bad results as I try to find
> the last eye readable word, or terminate the parsing after the last
> word/end of record....
>
> Chris.
>



Colin Campbell

2006-05-27, 3:55 am

I'd suggest defining the record as a set of characters - PIC X(01) -
that OCCURS 1 TO 2071 DEPENDING data-name. Call the 01 level something
like VAR-REC.

Then, after you have read the record (without an INTO clause), you can
use the LENGTH OF Special Register to find out how many bytes you read
for this record, and store that number in "data-name" (the object of the
OCCURS ... DEPENDING).

After that, you can MOVE the record from the FD to WORKING-STORAGE, and
it will get padded with spaces if it is shorter than the maximum record
size.
William M. Klein

2006-05-27, 6:55 pm

Colin,
Are you sure of this? I don't think that will work if you have RECORD
CONTAINS rather than RECORD VARYING IN SIZE.

--
Bill Klein
wmklein <at> ix.netcom.com
"Colin Campbell" <cmcampb@adelphia.net> wrote in message
news:gYadndj5FqgUTOrZnZ2dnUVZ_tGdnZ2d@ad
elphia.com...
> I'd suggest defining the record as a set of characters - PIC X(01) - that
> OCCURS 1 TO 2071 DEPENDING data-name. Call the 01 level something like
> VAR-REC.
>
> Then, after you have read the record (without an INTO clause), you can use the
> LENGTH OF Special Register to find out how many bytes you read for this
> record, and store that number in "data-name" (the object of the OCCURS ...
> DEPENDING).
>
> After that, you can MOVE the record from the FD to WORKING-STORAGE, and it
> will get padded with spaces if it is shorter than the maximum record size.



Pépé le Pew

2006-05-28, 6:55 pm


"William M. Klein" <wmklein@nospam.netcom.com> a écrit dans le message de
news: riLdg.68101$aA3.37762@fe06.news.easynews.com...
> Assuming that you are using VS COBOL II, R3 (with NOCMPR2) *OR* later
> compiler, then there is a solution. (With OS/VS COBOL there was also a
> "don't do this - but it works" negative subscripting solution).
>
> What you want to do is change
>
> depending on REC-LEN.


......
WORKING-STORAGE SECTION.

1 REC-LEN pic 9999.

PROCEDURE DIVISION.
......
READ TEXT-VAR-FILE AT END .....

EVALUATE REC-LEN
when 80 perform TEXT-VAR-80-ROUTINE
when 2071 perform TEXT-VAR-2071-ROUTINE
when other display "BAD LENGTH RECORD : " REC-LEN
END-EVALUATE



[color=darkred]
>
> Then in your working storage area define "some-item-defined-in-WS as an
> integer numeric field. This field will include the actual record length
> (without the "LLZZ" RDW field) after each read. For more information,
> check out:
>
> http://publibz.boulder.ibm.com/cgi-...GY3LR30/5.2.5.3
>
>
> --
> Bill Klein
> wmklein <at> ix.netcom.com
> <hcmason@sbcglobal.net> wrote in message
> news:1148681398.865250.65430@j55g2000cwa.googlegroups.com...
>
>


hcmason@sbcglobal.net

2006-05-28, 6:55 pm

Dear Bill:
Your suggestion worked. Awesome! You are Mr. COBOL.. My reading of
the manual was that you had to include the value in the record itself
before you write it out, and then when the record was read by another
program, that program would "know". However, your correct
interpretation works...Here is a snippet of the values displayed, the
paragraph names and the ws-size:
002000 FD TEXT-VAR-FILE
002100 BLOCK CONTAINS 0 RECORDS
002200 * I THINK THE REAL LRECL IS 2075, BUT 4 BYTES USED FOR
002300 * RECORD LENGTH
002400 RECORD VARYING IN SIZE DEPENDING ON WS-SIZE.
002600 01 TEXT-VAR-REC-80 PIC X(80).
002700 01 TEXT-VAR-RECORD PIC X(2071).
and the variable...
003500 01 WS-SIZE PIC 9(04) VALUE ZEROES.
A0000-MAIN
BEGIN PROGRAM L74HC
A1000-INIT
Z0000-READ-INPUT
WS-SIZE = 0400
FILE-STATUS IS 00
B0000-PROCESS
B1000-LOOP-THRU-DATA
DATA IS =
DOC5PD00020
Z0000-READ-INPUT
WS-SIZE = 0387
So now I have a way to know home much data to move into the array to be
parsed....
I tried the length of register, but it showed 2071 for everything...I
guess it takes the size of the max record
008110 DISPLAY 'LENGTH OF TEXT-VAR-RECORD = '
008200 LENGTH OF TEXT-VAR-RECORD.
Thanks Bill.
Chris Mason.

Howard Brazee

2006-05-30, 6:55 pm

You need a DEPENDING ON clause to do this.

It's interesting that as the decades go on, I've come across fewer and
fewer variable length records. At first they were replaced by
header and detail records, and later by databases.

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com