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
 

 

Defining the data record of a variable file
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
amrita.chatterjee

New User


Joined: 27 Apr 2006
Posts: 48
Location: Bangalore, India

PostPosted: Mon May 28, 2007 10:20 am    Post subject: Defining the data record of a variable file
Reply with quote

HI,
For a cobol module, the output file is VB file only. So in the File Section I have defined the file as below.
FD OUT-MAST-FILE
BLOCK CONTAINS 0 RECORDS
LABEL RECORDS ARE STANDARD
RECORDING MODE IS V,
RECORD IS VARYING IN SIZE FROM 1 TO 18000 CHARACTERS
DATA RECORD IS MAST-REC.
Now I have give data record description also.
So I have defined as below.
01 MAST-REC PIC X(18000) VARYING IN SIZE.
But in the compilation time it is giving Error.
The Error msg is given below.
"VARYING" was invalid. Scanning was resumed at the next area "A" item, level-number, or the start of the next clause.

Can somebody help me in this Error.
Back to top
View user's profile Send private message

William Thompson

Global Moderator


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

PostPosted: Mon May 28, 2007 12:26 pm    Post subject:
Reply with quote

Quote:
01 MAST-REC PIC X(18000) VARYING IN SIZE.
is invalid, you need to use OCCURS DEPENDONG ON instead.
Back to top
View user's profile Send private message
pingte

Active User


Joined: 03 Dec 2005
Posts: 120
Location: india

PostPosted: Mon May 28, 2007 2:51 pm    Post subject:
Reply with quote

[/code]
01 MAST-REC.
05 WS-X OCCURS 1 TO 999 TIMES DEPENDING ON WS-LENGTH.

[/code]

hope this structure will be suitable for variable length file.
Move the record length to WS-LENGTH variable b4 writing to file.
(length can be counted using INSPECT)
Back to top
View user's profile Send private message
amrita.chatterjee

New User


Joined: 27 Apr 2006
Posts: 48
Location: Bangalore, India

PostPosted: Mon May 28, 2007 2:55 pm    Post subject: Re: Defining the data record of a variable file.
Reply with quote

Thanks for the reply..I'll Try this..
Back to top
View user's profile Send private message
amrita.chatterjee

New User


Joined: 27 Apr 2006
Posts: 48
Location: Bangalore, India

PostPosted: Mon May 28, 2007 4:26 pm    Post subject: Re: Defining the data record of a variable file.
Reply with quote

FD OUT-MAST-FILE
BLOCK CONTAINS 0 RECORDS
LABEL RECORDS ARE STANDARD
RECORDING MODE IS V,
RECORD IS VARYING IN SIZE FROM 1 TO 27990 CHARACTERS
DATA RECORD IS MAST-REC.

01 MAST-REC.
05 WS-X OCCURS 1 TO 18000 TIMES DEPENDING ON WS-STRT
.

but this is also giving error.
Please find the error msg.
A "PICTURE" clause was not found for elementary item "WS-X". "PICTURE X(1)" was assumed.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


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

PostPosted: Mon May 28, 2007 5:07 pm    Post subject:
Reply with quote

Then put the PICTURE X(1) after the WS-X and before the OCCURS.
Back to top
View user's profile Send private message
amrita.chatterjee

New User


Joined: 27 Apr 2006
Posts: 48
Location: Bangalore, India

PostPosted: Mon May 28, 2007 5:16 pm    Post subject: Re: Defining the data record of a variable file.
Reply with quote

But WS-X is not X(1). That MAST-REC is varying from 1 thru 18000. So I Think, I should not mention X(1) as a picture clause of WS-X.
Please Suggest..
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: Mon May 28, 2007 5:18 pm    Post subject:
Reply with quote

Hello,

Where did you get the info that says your file is from 1 to 18000?

What field in the record determines how long the record is?

How do you know the file is variable length?

I believe your information is either incomplete or just incorrect.
Back to top
View user's profile Send private message
amrita.chatterjee

New User


Joined: 27 Apr 2006
Posts: 48
Location: Bangalore, India

PostPosted: Mon May 28, 2007 5:26 pm    Post subject: Re: Defining the data record of a variable file.
Reply with quote

In my first post only I have mention that the output file is a variable length file. The Record can vary from 1 thru 18000. I think u have not read my first post.
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: Mon May 28, 2007 5:37 pm    Post subject:
Reply with quote

Hello,

Yes, i have read you post - and yes you "mentioned" that this is a variable length file - and yes, your info is either incomplete or wrong.

I repeat, what direction were you given that tells you to create a variable length file? You have not posted that info. If you try to use a WS field for the number of occurs, how will another program that reads the file know how long each particular record is?

If you post the directions you were given that describe the file content, we will be able to help with the COBOL definition.
Back to top
View user's profile Send private message
amrita.chatterjee

New User


Joined: 27 Apr 2006
Posts: 48
Location: Bangalore, India

PostPosted: Mon May 28, 2007 5:48 pm    Post subject: Re: Defining the data record of a variable file.
Reply with quote

Please don't get confuse..
1. I have to create a output file
2. No program will read this file.

I'm writing one module in which this output file will be generating.

In the File Control Section I have defined the file as below.

FD OUT-MAST-FILE
BLOCK CONTAINS 0 RECORDS
LABEL RECORDS ARE STANDARD
RECORDING MODE IS V,
RECORD IS VARYING IN SIZE FROM 1 TO 18000 CHARACTERS
DATA RECORD IS MAST-REC.


Now i have to define the data record MAST-REC.

I want to define the data record also as variable length means 18000 varying.

For that reason only, I have asked how i can define the data record with varying clause.

Now i hope, my requirement is clear to you.
Back to top
View user's profile Send private message
somnath

New User


Joined: 21 Mar 2005
Posts: 18
Location: India

PostPosted: Mon May 28, 2007 5:57 pm    Post subject: Re: Defining the data record of a variable file.
Reply with quote

Try this.

FD OUT-MAST-FILE
RECORDING MODE IS V
LABEL RECORDS ARE STANDARD
BLOCK CONTAINS 0 RECORDS.
01 DATA-RECORD.
05 DATA-RECORD-AREA.
10 DATA-RECORD-CHAR
OCCURS 0 TO 18000 TIMES
DEPENDING ON DATA-RECORD-LENGTH
PIC X(01).

Define DATA-RECORD-LENGTH as
01 DATA-RECORD-LENGTH PIC S9(04) COMP.
Back to top
View user's profile Send private message
amrita.chatterjee

New User


Joined: 27 Apr 2006
Posts: 48
Location: Bangalore, India

PostPosted: Mon May 28, 2007 6:14 pm    Post subject: Re: Defining the data record of a variable file.
Reply with quote

Hi Somnath,

This is working fine. Thanks a lott.
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: Mon May 28, 2007 9:25 pm    Post subject:
Reply with quote

Hello,

I am curious about creating a file that no other program will read?

What kind of data will be put into this file and if nothing is going to read it, why create it?

If something later does need to read the file, how would it know how long each record is with the depending-on field not in the record?

Strange requirement. . . icon_confused.gif
Back to top
View user's profile Send private message
pingte

Active User


Joined: 03 Dec 2005
Posts: 120
Location: india

PostPosted: Tue May 29, 2007 11:26 am    Post subject:
Reply with quote

FYI...
Usually a variable length file will be created, so that you can provide it as an i/p to downsteam application. The length will be stored in RDW of the file which is first 4 bytes. This can be read by the next application.

RDW:-
For a mainframe file with variable length records each record is preceded by a four byte Record Descriptor Word (RDW) and a possible four byte Block Descriptor Word (BDW). The first two bytes of the RDW (and possible BDW) contains a binary value that is the length of the record (or possible block). The second two bytes of the RDW (and possible BDW) usually contain binary zeroes (or x'00').
Back to top
View user's profile Send private message
SREELAKSHMINARAYANAN

New User


Joined: 27 Jul 2006
Posts: 7

PostPosted: Tue May 29, 2007 11:41 am    Post subject: Re: Defining the data record of a variable file.
Reply with quote

How to get that four byte Record Descriptor Word (RDW) in Cobol PGM
Back to top
View user's profile Send private message
pingte

Active User


Joined: 03 Dec 2005
Posts: 120
Location: india

PostPosted: Tue May 29, 2007 12:31 pm    Post subject:
Reply with quote

suppose i/p file name is IN-FILE
Code:

FILE SECTION.
FD IN-FILE
RECORD IS VARYING DEPENDING ON REC-LENGTH.

WORKING STORAGE SECTION.
01 REC-LENGTH PIC 9(5) COMP.
** 200 IS CONSIDERED AS MAX LENGTH OF FILE**
01 SAVED-RECORD PIC X(200).

PROCEDURE DIVISION.
*** USE RECORD LENGTH TO ACCESS RIGHT LENGTH TO DATA***
READ IN-FILE
MOVE IN-FILE (1:REC-LENGTH) TO SAVED-RECORD

hope this helps.
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: Tue May 29, 2007 7:58 pm    Post subject:
Reply with quote

Hello,

Quote:
Usually a variable length file will be created, so that you can provide it as an i/p to downsteam application. The length will be stored in RDW of the file which is first 4 bytes. This can be read by the next application.


A rather big no!

Files should be defined as vb when there will actually be records of different lengths. Also, when a normal COBOL program reads a variable length file, it does not use the RDW.
Back to top
View user's profile Send private message
pingte

Active User


Joined: 03 Dec 2005
Posts: 120
Location: india

PostPosted: Wed May 30, 2007 7:53 am    Post subject: Re: Defining the data record of a variable file.
Reply with quote

in our application we do provide VB files as i/p to downstream application. And when i mean VB file.. it is implied that records will be of variable length, else a Fixed length file could have been used.

i hope this point is pretty clear.

N how does a normal cobol program knows the length of record while reading a VB file?
Mr moderator can u plz Xplain.
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: Wed May 30, 2007 8:33 am    Post subject:
Reply with quote

Hello,

A "normal cobol program" usually does not know or use the byte-count of the length (RDW). The i/o routine "knows" about the file and handles it outside of the COBOL code.

Typically, a VB file is defined with either multiple record layouts of different lengths (usually identified by a "record type") or a record definition that contains an ODO (occurs dependiong on) whose length is known by the "occurs depending on" field-name. Actually, some complex VB files contain both multiple record layouts as well as one or more ODO arrays.

In none of these cases is there a need for the RDW to be used in the COBOL code.

If you want to use certain utilities (like sort) you must allow for the RDW, but not in your COBOL code.

If you don't understand, we will try to help.
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
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm


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