adding a field in ksds



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

adding a field in ksds

Postby white-shadow » Mon Jul 19, 2010 2:27 am

hi,
i have to load a ps file in ksds file. so, is it necessary to declare the FD section of both the file same. and if yes then how can we add an extra field in the same ksds.
white-shadow
 
Posts: 12
Joined: Sat Jul 17, 2010 11:39 am
Has thanked: 0 time
Been thanked: 0 time

Re: adding a field in ksds

 

Re: adding a field in ksds

Postby Robert Sample » Mon Jul 19, 2010 3:00 am

You do not have the declare the FD for the sequential and VSAM files the same. You can do variable-by-variable MOVE statements if the two layouts are not identical, or you can add extra variables to the end of the VSAM FD 01, do the group level MOVE, then MOVE data into the extra variables individually.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times

Re: adding a field in ksds

Postby white-shadow » Mon Jul 19, 2010 4:25 am

i got it but there is still a confusion.
suppose for ps-file
01 ps-rec.
   02 asd     pic x(10).
    02 filler  pic x(10).
   02 xyz     pic x(20).
   o2 filler   pic x(40).
 and for ksds file
 01 ks-rec.
  02 kasd     pic x(10).
  02 filler  pic x(10).
  02 kxyz     pic x(20).
  02 filler   pic  x(10).
  02 qwe    pic x(10).
  02 filler  pic  x(20).


now i have to move the psfile record to ksds file record and then add the qwe field at the end of each record.
will it work or not.
also if the length of ps and the ksds file is different.
thanx for the previous reply
white-shadow
 
Posts: 12
Joined: Sat Jul 17, 2010 11:39 am
Has thanked: 0 time
Been thanked: 0 time

Re: adding a field in ksds

Postby dick scherrer » Mon Jul 19, 2010 6:02 am

Hello,

You are running yourself around in circles. . .

then add the qwe field at the end of each record.
In the code posted, the qwe field is NOT at the end of the record - it is using some of the filler. . .

will it work or not.
It will if coded correctly.

also if the length of ps and the ksds file is different.
What has been posted is the same length. Again, if you change the definition(s), then the code might need to change, but it will still work if coded correctly.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: adding a field in ksds

Postby Robert Sample » Mon Jul 19, 2010 7:27 am

The key point is that if you code it correctly, the VSAM file record length can be anything up to the maximum (just short of 32K) while the sequential file can also have any length record up to the maximum. If you code it incorrectly, they could have the same length (as in the example you posted) and you'd still have problems. The issue is not one of file record lengths, the issue is one of code quality. Write good code and you won't have a problem no matter what you're attempting to do. Write bad code and even the simplest tasks become quite difficult.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post