Posted: Tue May 17, 2005 8:54 am Post subject: split Variable Length File
Hi,
I have a variable length file of lrecl=304. It is containing 3 records of lengths 100,200 and 300 respectively. I have to read the vb file and depending on the length of the record i have to write that record in the relavent length file. eg. 100 length record in one file and 200 length record in another file etc... After reading the vb file how to know the length of the record.
Is there any special declaration need to be done in FD section for the same.
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Tue May 17, 2005 9:20 am Post subject:
Nadh,
Define a variable WS-INPUT-LENGTH in your pgm and after every read the length of each record is populated in that field which includes the RDW also. So if you read a record whose length is 100, WS-INPUT-LENGTH will have 104 (Actual Lrecl of 100 + 4 bytes of RDW). Now split the file based on that field.
Code:
FILE-CONTROL.
SELECT VBFILE
ASSIGN TO VB
ORGANIZATION IS SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD VBFILE
RECORDING MODE IS V
RECORD IS VARYING IN SIZE FROM 1 TO 300 CHARACTERS
DEPENDING ON WS-INPUT-LENGTH.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum