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
 

 

How to read variable length files.

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

New User


Joined: 20 Dec 2007
Posts: 54
Location: Hyderabad

PostPosted: Thu Dec 10, 2009 3:04 pm    Post subject: How to read variable length files.
Reply with quote

Hi All,

I have a variable length file with the data in the below format.

var-a pic x(10)
var-b pic x(20)
var-c is a varchar field.
var-d pic x(10).

var-a,var-b and var-d have fixed length in the file.
I want to read the value of var-d into a variable.
Please let me know how to do this?

Thanks,
Surya
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Thu Dec 10, 2009 3:10 pm    Post subject:
Reply with quote

How do you know the length of var-c
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Thu Dec 10, 2009 3:14 pm    Post subject:
Reply with quote

Quote:
How to read variable length files.
How do you do that for FB files?

At the top of the page is a link to "IBM Manuals". The first set of material is COBOL. Pick the Language Reference for your version of cobol and search (the flashlight near the top left) for "recording mode".

If you find something that is not clear, post what you found and your doubt about it.

Someone will be able to clarify.
Back to top
View user's profile Send private message
surya anem

New User


Joined: 20 Dec 2007
Posts: 54
Location: Hyderabad

PostPosted: Thu Dec 10, 2009 4:29 pm    Post subject:
Reply with quote

I dont know the exact length of var-c since it is a varchar field.

But i want to know the value of var-d present in the file.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Thu Dec 10, 2009 4:42 pm    Post subject:
Reply with quote

Unless you know where var-d starts and ends, how can you accurately find the value it contains.

Should there not be a length indicator field to show how long var-c is, because if there isn't you could well be up the creek sans paddle with other fields following any mystery length field(s).

But, as I am not a programmer I may be talking a lot of rubbish, but do recall using variable length fields which do have length indicators, such as SMF data. I await the judgement of the real programmers icon_eek.gif
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7995
Location: Bellevue, IA

PostPosted: Thu Dec 10, 2009 6:10 pm    Post subject:
Reply with quote

"varchar" is a DB2 term that has absolutely no business being used in a COBOL context.

Variable length files can be read -- and written -- easily in COBOL. However, to access data after the variable data field, you must know the length of the variable field, otherwise you have no way to tell where the end of it is.
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Thu Dec 10, 2009 9:06 pm    Post subject:
Reply with quote

Hello,

Quote:
var-c is a varchar field.
Show the code in the cobol program that defines this. . .
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Fri Dec 11, 2009 2:59 pm    Post subject: Re: How to read variable length files.
Reply with quote

surya anem wrote:
I have a variable length file ..
or show us the Data Set Information for this file which you have.
Back to top
View user's profile Send private message
bhairon singh rathore

New User


Joined: 19 Jun 2008
Posts: 91
Location: banglore

PostPosted: Fri Dec 11, 2009 5:17 pm    Post subject:
Reply with quote

Is there any delimiter defined in file after each variable.....if so you can unstring it into working storage delimited by delimiter provided.
Back to top
View user's profile Send private message
belchoff

New User


Joined: 21 Oct 2009
Posts: 4
Location: UK

PostPosted: Fri Dec 11, 2009 5:44 pm    Post subject:
Reply with quote

Seems to me a riddle with the information given!
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Fri Dec 11, 2009 8:00 pm    Post subject: Reply to: How to read variable length files.
Reply with quote

And more than 24 hours later, no info provided. . .

icon_confused.gif

d
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 Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm
No new posts Append data from two files into a sin... Praveen04 DFSORT/ICETOOL 5 Thu Mar 16, 2017 7:29 pm
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 15 Thu Dec 01, 2016 8:28 pm


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