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

Reading VB file and loading into table


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue Oct 06, 2009 4:58 pm
Reply with quote

we are trying to read a VB file to load the data into a VARCHAR field in a table programmatically but the read command is reading more data than expected i.e when i display after read i am able to see second record is also getting appended to first and says file status 04
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: Tue Oct 06, 2009 5:06 pm
Reply with quote

What does the FD look like? What does the READ statement look like? Psychic day was yesterday, so you've got to give us more information about what you are doing.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue Oct 06, 2009 5:15 pm
Reply with quote

FD looks like

Code:


FD  TEST-FILE                                                   
    RECORDING MODE IS V                                         
    BLOCK CONTAINS 0 RECORDS                                     
    RECORD CONTAINS 22   TO 1510 CHARACTERS.                     
    RECORD IS VARYING IN SIZE FROM 22 TO 1510 CHARACTERS         
    DEPENDING ON DATALEN.                                       
    DATA RECORD IS TEST1-RECORD.                                 



Copybooks

Code:


 01  TEST1-RECORD.                 
*    05 FILLER PIC  X(4).         
     05 DELETE-BYTE PIC X(1).     
     05 ACT-NO PIC X(11).         
     05 RCD-TYP PIC X(2).         
     05 USR-ID  PIC X(8).         
     05 FILLER PIC X(1492).       

01  TEST2-RECORD.               
    05 FILLER   PIC X(4).       
    05 VAR-DATA PIC  X(1510).   



Read para

Code:


INITIALIZE TEST1-RECORD TEST2-RECORD.

READ TEST-FILE                         
 AT END MOVE 'Y' TO WS-EOF             
END-READ.                               


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: Tue Oct 06, 2009 5:24 pm
Reply with quote

Why INITIALIZE? This is not needed.

Your TEST2-RECORD is 1514 bytes long -- why, when you declare 1510 bytes is the maximum?

Unless you use reference modification based on DATALEN, any processing you do of TEST1-RECORD or TEST2-RECORD will use 1514 bytes -- if your record is 22 bytes long, then you retrieve 1492 bytes of the next record (or two records, or 68 records) from the buffer and probably reprocess a number of the records since the second read will return the second record from the buffer.

If you want variable length records, you need to have different length 01 records in your FD, or an OCCURS DEPENDING on in the FD 01 record, or use reference modification to only take the bytes associated with the current record from the FD 01 since the buffer is returned which will be a physical block, not necessarily a single record.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue Oct 06, 2009 7:16 pm
Reply with quote

Hi Robert,

Code:

 01  MTGKACT1-RECORD.               
*    05 FILLER PIC  X(4).           
     05 DELETE-BYTE PIC X(1).       
     05 ACT-NO PIC X(11).           
     05 RCD-TYP PIC X(2).           
     05 USR-ID  PIC X(8).           




Code:

01  MTGKACT2-RECORD.                                   
*    05 FILLER   PIC X(4).                             
     05 VAR-DATA PIC  X(1510).                         



I tried with this copybook still it reads more data.

Thanks
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: Tue Oct 06, 2009 7:41 pm
Reply with quote

Quote:
I tried with this copybook still it reads more data.
I don't know what this means. COBOL reads a single record each time. However, with variable length files that are blocked, it is very easy to access more than just the current record.

In your FD, add this:
Code:
01  TEST3-RECORD.
    05  TEST3-BYTES                OCCURS 22 TO 1510
                                   DEPENDING ON DATALEN.
and use TEST3-RECORD in your program instead of TEST1-RECORD or TEST2-RECORD.
Back to top
View user's profile Send private message
ashutosh.pr

New User


Joined: 13 Apr 2007
Posts: 36
Location: Pune

PostPosted: Tue Oct 06, 2009 9:26 pm
Reply with quote

Hi Prem,
I was facing a similar issue. You can try changing the record description in the file section to a variable length field as suggested by Robert.
i.e Do not read a VB file into a fixed record structure. The size of the variable field should be similar to the the VB file record structure ( varying FROM and TO should be the same.
You can refer to this thread:
ibmmainframes.com/viewtopic.php?t=43940&highlight=

Please let us know if this works for you because it worked for me.

Thanks,
Ashutosh
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu Oct 08, 2009 4:11 am
Reply with quote

Hi Prem,

Your FD s/b:
Code:
FD  TEST-FILE                                                   
    RECORDING MODE IS V                                         
    RECORD IS VARYING IN SIZE FROM 22 TO 1510 CHARACTERS         
    DEPENDING ON DATALEN.

You need at least 1 rec description that's large enough to contain the largest rec (i.e. 1510).

To get an idea of what's going on, run a read test of a few recs and display DATALEN after each READ.

You don't have to supply a variable data length 01 in the FD. As an example, you can rewrite a variable rec, after you've updated the fixed portion of the rec, by using the same DEPENDING ON clause that you used on the I/P. Each rec will vary with the value of DATALEN, in spite of the fact that the FD 01 is defined as PIC X(1510).

A lot of what you can and can't do depends on what you're trying to accomplish.

BTW, you only define the rec len as 1514 in the JCL LRECL, use 1510 for the pgm.
Back to top
View user's profile Send private message
ajit167413

New User


Joined: 30 Sep 2009
Posts: 1
Location: Chennai

PostPosted: Thu Nov 05, 2009 1:36 pm
Reply with quote

Can you please reply like how did you solve this issue...
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Thu Nov 05, 2009 10:24 pm
Reply with quote

Good luck there, Ajit. Too many posters here simply take the information and run. icon_sad.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Nov 05, 2009 11:01 pm
Reply with quote

or simply run from the information.
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top