View previous topic :: View next topic
|
Author |
Message |
surya anem
New User
Joined: 20 Dec 2007 Posts: 54 Location: Hyderabad
|
|
|
|
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
How do you know the length of var-c |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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 |
|
|
surya anem
New User
Joined: 20 Dec 2007 Posts: 54 Location: Hyderabad
|
|
|
|
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
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 |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
"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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
var-c is a varchar field. |
Show the code in the cobol program that defines this. . . |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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 |
|
|
bhairon singh rathore
New User
Joined: 19 Jun 2008 Posts: 91 Location: banglore
|
|
|
|
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 |
|
|
belchoff
New User
Joined: 21 Oct 2009 Posts: 4 Location: UK
|
|
|
|
Seems to me a riddle with the information given! |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
And more than 24 hours later, no info provided. . .
d |
|
Back to top |
|
|
|