IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

cobol program to handle files having different LRECL


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ABaluchamy

New User


Joined: 29 Dec 2006
Posts: 34
Location: INDIA

PostPosted: Thu Feb 15, 2007 6:04 pm
Reply with quote

Hi,

Can any 1 help me regarding this.. i want to write a cobol program to handle files having different LRECL...

Here is a scenario..
thr r 3 input files of LRECL(80,120,400)
If any one is given to input, the program should process thru fine..

Thanks in advance..

Anand B
Back to top
View user's profile Send private message
acevedo

Active User


Joined: 11 May 2005
Posts: 344
Location: Spain

PostPosted: Thu Feb 15, 2007 6:11 pm
Reply with quote

Search for
RECORD CONTAINS 0 CHARACTERS...

P.S.: please don't use SMS style... take your time to write and expose your problem...
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Feb 15, 2007 6:16 pm
Reply with quote

OK, we have the LRECL, what is the RECFM and BLKSIZE of each?
Back to top
View user's profile Send private message
Bitneuker

CICS Moderator


Joined: 07 Nov 2005
Posts: 1104
Location: The Netherlands at Hole 19

PostPosted: Thu Feb 15, 2007 7:15 pm
Reply with quote

Why not treat them as one file (concatenate) with the largest lrecl defined in the fd. Make sure the largest bklsize is the first in the concatenation.
Back to top
View user's profile Send private message
prav_06
Warnings : 1

Active User


Joined: 13 Dec 2005
Posts: 154
Location: The Netherlands

PostPosted: Fri Feb 16, 2007 10:40 am
Reply with quote

ABaluchamy,

Have u ever heard of muliple record length lay out files, the requirement of your's is pertaining to that, but by this process u can only give input as one file with the maximum record length (400 in your case), u can write the records which has lrecl as 80 an 120 in the same file but in different record structures, but u should be having a common key field which is common for all the three files, say for example

Code:
01   1-rec.
       02    key-1 pic x(10).
       02    rec1   pic x(70).
* For lrecl 80
 01   2-rec.
       02    key-2 pic x(10).
       02    rec2   pic x(110).
* For lrecl 120
 01   1-rec.
       02    key-3 pic x(10).
       02    rec1   pic x(100).
       02    rec3   pic x(100).
       02    rec4   pic x(100).
       02    rec4   pic x(90).
* for lrecl 400


All these three record structures shloul pertain to the same file , but can identified individually by the unique record name and accesed, for better understanding pleae refer to file handling concepts for VB files in any COBOL manual.


Cheer's,

Thamilzan.
Back to top
View user's profile Send private message
ABaluchamy

New User


Joined: 29 Dec 2006
Posts: 34
Location: INDIA

PostPosted: Fri Feb 16, 2007 5:33 pm
Reply with quote

If you test the 'file status' field you can control if the program should abend. I have many programs that read different LRECL files from one DD by doing an open and then testing for a file status of 39. if I get a 39, I close that FD and open it under another FD in the program and so on.(I know that I could possibly read up to X different LRECL files fo I code an FD for each.) used to be a time when you could do a nagative subscribt on the record (start of record minus 4) and get the record length in COBOL.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Feb 16, 2007 6:24 pm
Reply with quote

ABaluchamy wrote:
used to be a time when you could do a nagative subscribt on the record (start of record minus 4) and get the record length in COBOL.
Try a "set address" and decrement the pointer.
William Thompson wrote:
OK, we have the LRECL, what is the RECFM and BLKSIZE of each?
Back to top
View user's profile Send private message
prav_06
Warnings : 1

Active User


Joined: 13 Dec 2005
Posts: 154
Location: The Netherlands

PostPosted: Fri Feb 16, 2007 8:41 pm
Reply with quote

BaluChamy,
Kindly create the file in the JCL with a lrecl of 404 if ya having 400 bytes of data, I guess the abend would have been S0C4, try these parameters,

dcb=(lrecl=404,blksize=4040,recfm=vb,dsorg=ps)

FS 39 would be for the mismatch lrecl b/w the logical file and the physical file, and that x-tra 4 bytes allocation is for the system to store the length of each and every record.

Thamilzan.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Feb 17, 2007 1:42 am
Reply with quote

Hello,

If the files already exist and are of fixed length you cannot just specify VB and hope it will work when you try to read them.

Please look at your 3 files and post the actual dcb attributes for each.

How large are these files? If they are not very large, i can offer a workaround.

When you are reading the data, how do you know if the data is from an 80, 120, or 400 byte record. Given that they are of different lengths, the code will have to know which is being processed.

All of the conversation about "file status" will not help you process the file(s) - it may help you know if you had an error.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 0
No new posts WER247A SORTOUT HAS INCOMPATIBLE LRECL SYNCSORT 6
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Using API Gateway from CICS program CICS 0
Search our Forums:

Back to Top