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
 

 

Reading VB file and loading into table

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Pandora-Box

Moderator


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

PostPosted: Tue Oct 06, 2009 4:58 pm    Post subject: Reading VB file and loading into table
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: 7931
Location: Bellevue, IA

PostPosted: Tue Oct 06, 2009 5:06 pm    Post subject:
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

Moderator


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

PostPosted: Tue Oct 06, 2009 5:15 pm    Post subject:
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: 7931
Location: Bellevue, IA

PostPosted: Tue Oct 06, 2009 5:24 pm    Post subject:
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

Moderator


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

PostPosted: Tue Oct 06, 2009 7:16 pm    Post subject:
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: 7931
Location: Bellevue, IA

PostPosted: Tue Oct 06, 2009 7:41 pm    Post subject:
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    Post subject:
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:
http://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    Post subject:
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    Post subject: Reply to: Reading VB file and loading into table
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: 1239
Location: Richfield, MN, USA

PostPosted: Thu Nov 05, 2009 10:24 pm    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
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


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