View previous topic :: View next topic |
Author |
Message |
nbdtrjk1 Beginner
Joined: 12 Apr 2007 Posts: 76 Topics: 41
|
Posted: Tue Jun 26, 2007 3:07 am Post subject: How to read RDW Values |
|
|
Hi All,
I have VB file length of 32000 bytes which has 100 records, 1st and 2nd record length is 100 bytes. 3rd and 7threcord length is 3000 bytes.
My requirement is...How to identify the length of the each Record in that VB file. Is it possible to read through COBOL and get the record length? or give me some alternate solution.
Or using RDW do something? |
|
Back to top |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Tue Jun 26, 2007 4:41 am Post subject: a COBOL solution |
|
|
Not exactly profi stuff, but:
Compile with the NOSSRANGE option.
Define INPUT-FILE FD with record length 1 to 32000.
define RECORD as
Code: |
01 INPUT-RECORD.
05 INPUT-ITEM PIC X OCCURS 32000 TIMES INDEXED BY IDX-1.
|
in WORKING-STORAGE define
Code: |
01 WORK-AREA.
05 WORK-LENGTH-BINARY PIC 9999 BINARY.
05 WORK-CHARS
REDEFINES
WORK-LENGTH-BINARY
10 CHAR-AT-POS-NEG-2 PIC X.
10 CHAR-AT-POS-NEG-1 PIC X.
05 WORK-LENGTH-DISPLAY PIC ZZZ,ZZZ-.
05 INPUT-FILE-STATUS PIC XX.
88 INPUT-OK VALUE '00'.
05 RECORD-COUNTER-DISPLAY PIC 99 VALUE 0.
|
In PROCEDURE DIVISION code
Code: |
READ-AND-PRINT.
OPEN INPUT-FILE
IF INPUT-OK
THEN
CONTINUE
ELSE
DISPLAY 'ERROR ON OPEN, FILE STATUS: ' INPUT-FILE-STATUS
GOBACK
END-IF
PERFORM 100 TIMES
READ INPUT-FILE
AT END PERFORM CLOSE-AND-GO
END-READ
ADD 1 TO RECORD-COUNTER-DISPLAY
SET IDX-1 TO 1
SET IDX-1 DOWN BY 1
MOVE INPUT-ITEM(IDX-1) TO CHAR-AT-POS-NEG-1
SET IDX-1 DOWN BY 1
MOVE INPUT-ITEM(IDX-1) TO CHAR-AT-POS-NEG-2
MOVE WORK-LENGTH-BINARY TO WORK-LENGTH-DISPLAY
DISPLAY 'RECORD NUM: '
WORK-LENGTH-DISPLAY
' RECORD LENGTH: '
WORK-LENGTH-DISPLAY
END-PERFORM
PERFORM CLOSE-AND-GO
.
READ-AND-PRINT-EXIT.
EXIT.
CLOSE-AND-GO.
CLOSE INPUT-FILE
GOBACK
.
CLOSE-AND-GO-EXIT.
EXIT.
|
_________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Tue Jun 26, 2007 4:45 am Post subject: |
|
|
or using SORT
[code:1:061caa2a4b]
INREC FIELDS=(1,4, unedited RDW
1,2,BI,TO=ZD,LENGTH=5, display RDW length in decimal
C _________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
 |
jajularamesh Beginner
Joined: 14 Apr 2006 Posts: 87 Topics: 33
|
Posted: Tue Jun 26, 2007 7:50 am Post subject: |
|
|
You can read the record and get the information
Declare the FD section as given below
FD ACCOUNT-IN
DATA RECORD IS ACCOUNT-IN-RECORD
RECORDING MODE IS V
RECORD IS VARYING IN SIZE FROM 1 TO 1939 CHARACTERS
DEPENDING ON ACCT-RECORD-SIZE.
Each time you read the record the length of the record is captured in ACCT-RECORD-SIZE
Please let me know if you want further details
Regards,
Ramesh |
|
Back to top |
|
 |
jajularamesh Beginner
Joined: 14 Apr 2006 Posts: 87 Topics: 33
|
Posted: Tue Jun 26, 2007 7:56 am Post subject: |
|
|
dbzTHEdinosauer,
Compile with the NOSSRANGE option.
I couldn't understand what you are trying to do convey from this and i guess this is no way related to the question asked.
Correct me if my question is wrong
Regards,
Ramesh |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Tue Jun 26, 2007 8:06 am Post subject: |
|
|
Quote: |
Compile with the NOSSRANGE option.
I couldn't understand what you are trying to do convey from this and i guess this is no way related to the question asked.
Correct me if my question is wrong
|
jajularamesh,
The compiler option SSRANGE is used to generate code that checks if subscripts (including ALL subscripts) or indexes try to reference an area outside the region of the table. Each subscript or index is not individually checked for validity; rather, the effective address is checked to ensure that it does not cause a reference outside the region of the table. Variable-length items will also be checked to ensure that the reference is within their maximum defined length.
In the above code DBZ is using an index and he does not want to abend if his index goes out of bounds
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Tue Jun 26, 2007 8:14 am Post subject: |
|
|
jajularamesh,
your solution is much better, mine was a 'stone wheels & knives' approach.
as kolusu said, I wanted to avoid an abend as I strolled backwards from the start of the record. _________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
 |
jajularamesh Beginner
Joined: 14 Apr 2006 Posts: 87 Topics: 33
|
Posted: Tue Jun 26, 2007 8:14 am Post subject: |
|
|
Kolusu,
Actually nbdtrjk1 wants to capture the length of each record.
For this if i am not wrong we have to define the FD section in this way
RECORD IS VARYING IN SIZE FROM 1 TO 1939 CHARACTERS
DEPENDING ON ACCT-RECORD-SIZE.
where after each read length of the record is captured in ACCT-RECORD-SIZE
so this can be directly achieved right
Regards,
Ramesh |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Tue Jun 26, 2007 8:16 am Post subject: |
|
|
jajularamesh,
If you read DBz's solution it also gives you the length of each record from the VB File but a different process. Your solution also works. OP can choose whichever solution he is comfortable with
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
jajularamesh Beginner
Joined: 14 Apr 2006 Posts: 87 Topics: 33
|
Posted: Tue Jun 26, 2007 8:19 am Post subject: |
|
|
dbzTHEdinosauer,
Actually i am trying to understand what you gave there.
i have been working with VB files most frequently these days so i thought we can directly aceive this.
Sorry, don't take me wrong
Regards,
Venkata Apparao Jajula |
|
Back to top |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Tue Jun 26, 2007 8:38 am Post subject: |
|
|
jajularamesh,
the record description entry in the FD section actually is an area that 'floats' within the file buffer. If you look at a compiler listing, the 01 level is on a register. After each READ or WRITE, the ops-sys increments the register and the next record area in the buffer is made available.
For variable length records the VLI is the two characters in front of each record addressed in the FD record area. But, COBOL does not make that area definable, though you can access it by using an index and addressing the -2 and -1 offset to the Record Area.
I have not messed with QSAM (or VSAM) for about 20 years and did not bother to keep up with the FD DEPENDING ON clause, which you very eloquently provided as a solution.
I imagine COBOL will eventually not allow addressing the buffer directly. This is one of the reasons for the work-area option on I/O's. keeping COBOL programmers out of the buffer
as I said earlier, a 'stone wheels & knives' solution. But what do you expect from a dinosaur? _________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
 |
|
|