Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Fixed & Length block

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
anoop_mf

New User


Joined: 27 Sep 2005
Posts: 6

PostPosted: Thu Dec 22, 2005 11:00 pm    Post subject: Fixed & Length block
Reply with quote

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
View user's profile Send private message

DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Thu Dec 22, 2005 11:07 pm    Post subject: Re: Fixed & Length block
Reply with quote

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
View user's profile Send private message
anoop_mf

New User


Joined: 27 Sep 2005
Posts: 6

PostPosted: Thu Dec 22, 2005 11:09 pm    Post subject: YEAH I MEAN FIXED LENGTH & VARIABLE LENGTH RECORD
Reply with quote

YEAH I MEAN FIXED LENGTH & VARIABLE LENGTH RECORD--
IT'S URGENT
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Fri Dec 23, 2005 1:19 am    Post subject:
Reply with quote

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]
http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/igyl1101/CCONTENTS
[/url]
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Dec 25, 2005 4:46 am    Post subject:
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts SQZ pipe delimited file with 1 column... Rick Silvers DFSORT/ICETOOL 6 Sun Nov 06, 2016 8:11 pm
No new posts Joinkeys operation when key1 and key2... Susanta DFSORT/ICETOOL 5 Wed Nov 02, 2016 5:35 pm
No new posts SORT Block of records girishb2 DFSORT/ICETOOL 12 Thu Sep 15, 2016 8:58 am
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us