View previous topic :: View next topic
|
Author |
Message |
amrita.chatterjee
New User
Joined: 27 Apr 2006 Posts: 48 Location: Bangalore, India
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Quote: |
01 MAST-REC PIC X(18000) VARYING IN SIZE. |
is invalid, you need to use OCCURS DEPENDONG ON instead. |
|
Back to top |
|
|
pingte
Active User
Joined: 03 Dec 2005 Posts: 120 Location: india
|
|
|
|
[/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 |
|
|
amrita.chatterjee
New User
Joined: 27 Apr 2006 Posts: 48 Location: Bangalore, India
|
|
|
|
Thanks for the reply..I'll Try this.. |
|
Back to top |
|
|
amrita.chatterjee
New User
Joined: 27 Apr 2006 Posts: 48 Location: Bangalore, India
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Then put the PICTURE X(1) after the WS-X and before the OCCURS. |
|
Back to top |
|
|
amrita.chatterjee
New User
Joined: 27 Apr 2006 Posts: 48 Location: Bangalore, India
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
amrita.chatterjee
New User
Joined: 27 Apr 2006 Posts: 48 Location: Bangalore, India
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
amrita.chatterjee
New User
Joined: 27 Apr 2006 Posts: 48 Location: Bangalore, India
|
|
|
|
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 |
|
|
somnath
New User
Joined: 21 Mar 2005 Posts: 18 Location: India
|
|
|
|
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 |
|
|
amrita.chatterjee
New User
Joined: 27 Apr 2006 Posts: 48 Location: Bangalore, India
|
|
|
|
Hi Somnath,
This is working fine. Thanks a lott. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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. . . |
|
Back to top |
|
|
pingte
Active User
Joined: 03 Dec 2005 Posts: 120 Location: india
|
|
|
|
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 |
|
|
SREELAKSHMINARAYANAN
New User
Joined: 27 Jul 2006 Posts: 7
|
|
|
|
How to get that four byte Record Descriptor Word (RDW) in Cobol PGM |
|
Back to top |
|
|
pingte
Active User
Joined: 03 Dec 2005 Posts: 120 Location: india
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
pingte
Active User
Joined: 03 Dec 2005 Posts: 120 Location: india
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
pingte
Active User
Joined: 03 Dec 2005 Posts: 120 Location: india
|
|
|
|
Thanks got ur point..
i hope the code i have posted above is correct...
In sort when we convert a VB file to FB file, does the RDW come into play |
|
Back to top |
|
|
getpiyoosh
New User
Joined: 27 Mar 2006 Posts: 1 Location: pune
|
|
|
|
Hi,
could you please tell me , what will be the read clause ?
I would appreciate If I could get the exact syntax. |
|
Back to top |
|
|
|