View previous topic :: View next topic
|
Author |
Message |
anoop_mf
New User
Joined: 27 Sep 2005 Posts: 6
|
|
|
|
Hi friends
I want to know the thereotical and practical differences between Fixed & lenth records.
How they are read write update and deleted.
Wt is the differences in both techniques.
Thanks & Regards
anoop_mf |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Clarification,
Do you mean the difference in a fixed length, and a variable length record?
Please come back, or do I missunderstand? |
|
Back to top |
|
|
anoop_mf
New User
Joined: 27 Sep 2005 Posts: 6
|
|
|
|
YEAH I MEAN FIXED LENGTH & VARIABLE LENGTH RECORD--
IT'S URGENT |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Hi,
You understand the concept of a fixed length record; all records in a file are of the same length and probable the same description.
In a variable length record the file can contain records of mixed lengths, and mixed descriptions. This can be because of many reasons. Maybe your looking at an unload of an IMS database. The file may contain the same results as if you were to progress through the database with a ?get next?. You would get an i.e. parent segment (lrecl 100), a child-1 segment (lrecl 75), a child-2 segment (lrecl 300), and so on until you get the next parent segment again.
Or say you have a record description something like this for every property in the state of California (all 200 million of them)
Code: |
01 PRORERTY_DESCRIPTION.
05 OWNERS_NAME PIC X(40).
05 ADDRESS PIC X(30).
05 CITY PIC X(30).
05 STATE PIC X(2).
05 ZIP-CODE PIC X(9).
05 LEGAL_PROPERTY_DESCRIPION PIC X(5000).
|
This could be a fixed length record, using 5111 bytes each, or, because the average LPD is only 125 characters you could make the dataset size MUCH smaller by making the record a variable length record, containing only the LPD required.
Now how do you read this in COBOL? There are a multitude of variations you can use, but the two I have used are:
Case 1:
Code: |
FD INPUT-IMS-UNLOAD
01 PARENT-RECORD.
05 SEGMENT-TYPE PIC X(2).
05 Record-description PIC X(98).
01 CHILD-RECORD-1.
05 SEGMENT-TYPE PIC X(2).
05 Record-description PIC x(73).
01 CHILD-RECORD-2.
05 SEGMENT-TYPE PIC X(2).
05 Record-description PIC X(298).
|
In a case like this, you need in each segment a SEGMENT-TYPE that describes the identity of the segment so you know what record-description to use.
Case 2:
Code: |
FD
:
RECORD IS VARYING IN SIZE
FROM 111 TO 5111 CHARACTERS
DEPENDING ON RECORD-LENGTH
01 PRORERTY_DESCRIPTION.
05 OWNERS_NAME PIC X(40).
05 ADDRESS PIC X(30).
05 CITY PIC X(30).
05 STATE PIC X(2).
05 ZIP-CODE PIC X(9).
05 LEGAL_PROPERTY_DESCRIPION PIC X(5000).
WORKING STORAGE SECTION.
01 RECORD-LENGTH PIC S9(8) COMP.
|
When you read the V record, RECORD-LENGTH will be populated with the number of bytes what were read. From this you can calculate the number of characters in the LPD.
Disclaimer: I don?t use variable length records very much and usually have to play with the code a little before I remember exactly what the correct syntax is. But in general this is what V records are.
If you browse a variable length file, you will see an additional 4 bytes preceding each record. This is a 4 byte binary length of the block, and needs to be taken into consideration when sizing the block size for a new file. In COBOL this is taken care of and you don?t see it.
If this isn't what you are looking for, please come back.
Hears the link to the IBM COBOL Ref.
[url]
publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/igyl1101/CCONTENTS
[/url] |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Two points to add to David's excellent description:
The DEPENDING ON subject, RECORD-LENGTH is also used when writing VB recs. You put the length of the OP rec there before the rec is written. You can calculate it or use the value of the read rec.
In some cases you may have a variety of recs with differing lengths in the IP file. In this case you don't need the DEPENDING ON phrase. You can provide a different 01 level in the FD for each type rec in the IP. Usually each rec type should contain a field that that uniquely identifies the rec type to the pgm. You use that field to identify what rec type you just read.
To WRITE the rec use the 01 level variable name for that type in the WRITE stmt, e.g. WRITE REC-TYPE1. |
|
Back to top |
|
|
|