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

Write VSAM - Varible length


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

New User


Joined: 19 Mar 2008
Posts: 12
Location: India

PostPosted: Tue Jun 29, 2010 6:31 pm
Reply with quote

Hi all,
Im Trying to write a VSAM file with Variable record length is that possible. If possible i tried various scenarios which was not working and its erroring with status=44.

In my program i have to read a PS file and Write a VSAM of variable record length. -> we wil using this as a DB so inorder to save space we are writing in the VB format.

In code:-
Code:
FD  VSAM-FILE                                             
    RECORD IS VARYING IN SIZE                             
    FROM 1 TO 2760 CHARACTERS DEPENDING ON VALUE-LEN     
    DATA RECORD IS VSAM-RECORD.                           
01  VSAM-RECORD.                                         
    03  VSAM-REC-KEY       PIC X(60).                     
    03  VSAM-DATA          PIC X(2700).                   

 01 WW-INP-REC.                                   
    03  WW-INP-KEY                   PIC X(15).   
    03  WW-INP-DATA                  PIC X(65).   

READ-FILE SECTION.   
READ INPUT-IFILE INTO WW-INP-REC AT END                   
    MOVE 'Y' TO WS-END-OF-INP-FILE                         
END-READ                                                                                                                                                                   
COMPUTE VALUE-LEN1 = FUNCTION LENGTH(WW-INP-KEY)           
INSPECT FUNCTION REVERSE(WW-INP-DATA)                     
TALLYING VALUE-LEN2 FOR LEADING SPACES                     

COMPUTE VALUE-LEN2 = LENGTH OF WW-INP-DATA - VALUE-LEN2   

COMPUTE VALUE-LEN =  VALUE-LEN1 + VALUE-LEN2               

WRITE-VSAM-RECORD.
    MOVE WW-INP-KEY                 TO VSAM-REC-KEY             
    MOVE WW-INP-DATA(1:VALUE-LEN)   TO VSAM-DATA                 
                                                                 
    WRITE VSAM-RECORD END-WRITE                                 
                                                                 
    IF  WL-VSAM-STATUS = '00'                                   
        DISPLAY 'WRITTEN - 'VSAM-REC-KEY                         
    ELSE                                                         
      DISPLAY 'WRITE-ERROR '                                     

VSAM format:-
Dataset type ===> KSDS
Key length ===> 60
Key position ===> 0
Average Recordsize ===> 2764
Maximum Recordsize ===> 2764


when i run this code im getting VSAM Status 44. Please advise me.

Firstly im not sure if VSAM can be written in VB format. If Yes what might be the reason for my error.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Jun 29, 2010 6:43 pm
Reply with quote

VSAM Demystified
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Jun 29, 2010 6:50 pm
Reply with quote

Following up on Dicks most helpfull link - you really should make the time to read that document - You need to look at the VSAM definition.
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 Jun 29, 2010 7:28 pm
Reply with quote

Quote:
Firstly im not sure if VSAM can be written in VB format. If Yes what might be the reason for my error.
Be sure -- there is absolutely no problem in COBOL, if the code is written correctly, with writing variable length VSAM records. Be aware that variable length VSAM files, unlike variable length sequential files, do not have a 4-byte record descriptor word at the beginning of each record.

Would it really be so hard to add VALUE-LEN to your display of the file status code? That would tell you what length record you are attempting to write, which could tell much.

Also, from what you have posted it does not appear that you have defined the VSAM file as having variable length records.
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(F1 & F2) and writ... JCL & VSAM 8
No new posts Store the data for fixed length COBOL Programming 1
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Write line by line from two files DFSORT/ICETOOL 7
Search our Forums:

Back to Top