View previous topic :: View next topic
|
Author |
Message |
Akash Sharma
New User
Joined: 13 Jan 2009 Posts: 36 Location: India
|
|
|
|
Hi all,
I have a requirement to sweep 8 db records and write them into a VB PS file.
I currently have file definition as:
Code: |
FD EXTRACT-FILE
RECORDING MODE V
BLOCK CONTAINS 0 RECORDS
LABEL RECORDS ARE STANDARD.
01 EXTFILE-REC PIC X(351).
|
The problem im facing is, that not all records are having 351 bytes of data. Some have 28, some 100, some 200. when i write the record which has data of 28 bytes, rest bytes are spaces which consumes larger space. Is there a way by which the EXTFILE-REC takes space equal to the length of the record?? Please help. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Explain to me how you know that there are spaces at the end of each shorter record. |
|
Back to top |
|
|
Akash Sharma
New User
Joined: 13 Jan 2009 Posts: 36 Location: India
|
|
|
|
expat wrote: |
Explain to me how you know that there are spaces at the end of each shorter record. |
In the PS, after doing HEX ON, at the end of the record, i can see the following....
Code: |
MU002LNK...±
DEFFFDDD032844444444444444444444444444444
44002352210F00000000000000000000000000000
|
4 depicts its spaces.
0 |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Are you in EDIT or BROWSE ? |
|
Back to top |
|
|
Akash Sharma
New User
Joined: 13 Jan 2009 Posts: 36 Location: India
|
|
|
|
expat wrote: |
Are you in EDIT or BROWSE ? |
The file size is very large hence opens in BROWSE MODE only. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
make your output a variable length file. COBOL manual as well as umteen threads about variable length records. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Is it all records, or only the ones with a length of 28 ? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Use the RECORD VARYING clause in your COBOL FD for the file. |
|
Back to top |
|
|
Akash Sharma
New User
Joined: 13 Jan 2009 Posts: 36 Location: India
|
|
|
|
expat wrote: |
Is it all records, or only the ones with a length of 28 ? |
It is for all records which are lesser than 351 bytes. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Then I believe that Robert has given you a good place to start |
|
Back to top |
|
|
Akash Sharma
New User
Joined: 13 Jan 2009 Posts: 36 Location: India
|
|
|
|
Thank u all for looking into this...
Could you please give me a link where i can find some information on "RECORD IS VARYING clause". I looked into some manuals but could not find it.
The help is much appreciated. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
COBOL Language Reference in the manuals link at the top of the page. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Some have 28, some 100, some 200. |
Is there a known number of record formats or could the length be "anything" up to 351?
How does the code know the actual length of the data? |
|
Back to top |
|
|
Akash Sharma
New User
Joined: 13 Jan 2009 Posts: 36 Location: India
|
|
|
|
dick scherrer wrote: |
Hello,
Quote: |
Some have 28, some 100, some 200. |
Is there a known number of record formats or could the length be "anything" up to 351?
How does the code know the actual length of the data? |
Hi,
I have 8 records with record length as:
111
111
73
351
77
185
115
115 |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Code: |
FD EXTRACT-FILE
RECORDING MODE V
BLOCK CONTAINS 0 RECORDS
LABEL RECORDS ARE STANDARD.
01 EXTFILE-REC PIC X(351).
01 VARIABLE-REC.
03 FILLER PIC X OCCURS 1 TO 351 TIMES DEPENDING ON WS-LENGTH.
77 WS-LENGTH PIC S9(3) COMP-3.
MOVE INPUT-LENGTH TO WS-LENGTH.
MOVE INPUT-REC TO either EXTFILE-REC or VARIABLE-REC.
WRITE VARIABLE-REC.
|
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
I have 8 records with record length as:
111
111
73
351
77
185
115
115
|
If there can only be these 8 record layouts (6 lengths actually), i'd suggest creating 8 level-01s in the FD and writing to the appropriate length level-01. Does each record have an identifier so that the code that uses the file will know which format has been read? |
|
Back to top |
|
|
|