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

How to read variable length files.


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 8797
Location: Welsh Wales

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

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

Superior Member


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

PostPosted: Thu Dec 10, 2009 3:14 pm
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
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: 8797
Location: Welsh Wales

PostPosted: Thu Dec 10, 2009 4:42 pm
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Dec 10, 2009 6:10 pm
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

Moderator Emeritus


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

PostPosted: Thu Dec 10, 2009 9:06 pm
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

Superior Member


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

PostPosted: Fri Dec 11, 2009 2:59 pm
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
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
Reply with quote

Seems to me a riddle with the information given!
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: Fri Dec 11, 2009 8:00 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Write line by line from two files DFSORT/ICETOOL 7
Search our Forums:

Back to Top