MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

split Variable Length File

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
nadh
Intermediate


Joined: 08 Oct 2004
Posts: 192
Topics: 89

PostPosted: Tue May 17, 2005 8:54 am    Post subject: split Variable Length File Reply with quote

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.

Pls. help me out.

Thanks in advance
nadh
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Tue May 17, 2005 9:20 am    Post subject: Reply with quote

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. 
                       
01  VBREC              PIC X(300).

WORKING-STORAGE SECTION.               
01  WS-INPUT-LENGTH    PIC 9(09) COMP.
01  WS-RECORD          PIC X(300).
01  S-INPUT-FILE-EOF   PIC X(01) VALUE 'N'.

MOVE SPACES TO WS-RECORD                       
                                               
READ VBFILE  INTO WS-RECORD                   
   AT END                                     
       MOVE 'Y'           TO S-INPUT-FILE-EOF 
END-READ                                       
.                                             


You can actually do this using sort itself. you don't need a program to split the dataset.

Code:

//STEP0100 EXEC PGM=SORT                           
//SYSOUT   DD SYSOUT=*                             
//SORTIN   DD DSN=YOUR VB FILE,
//            DISP=SHR                             
//LREC100  DD SYSOUT=*
//LREC200  DD SYSOUT=*
//LREC300  DD SYSOUT=*
//SYSIN    DD *                                   
  SORT FIELDS=COPY                                 
  OUTFIL FNAMES=LREC100,INCLUDE=(1,2,BI,EQ,100)
  OUTFIL FNAMES=LREC200,INCLUDE=(1,2,BI,EQ,200)
  OUTFIL FNAMES=LREC300,INCLUDE=(1,2,BI,EQ,300)
/*                                                 


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nadh
Intermediate


Joined: 08 Oct 2004
Posts: 192
Topics: 89

PostPosted: Wed May 18, 2005 1:10 am    Post subject: Reply with quote

Thank you kolusu,

Though it solved my problem. I have a doubt. Pls. clarify.

How does the length will be moved to ws-input-length. what is RDW?

Nadh
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Wed May 18, 2005 5:21 am    Post subject: Reply with quote

Quote:

How does the length will be moved to ws-input-length. what is RDW?

nadh,

Check this link which explains in detail about variable length format

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3PG10/1.9.1.1.3?SHELF=&DT=20020923143836&CASE=

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group