Page 1 of 1

Sort to copy data from first column from a file and paste it

Posted: Thu May 24, 2012 9:19 am
by archup20
Hi,

Can a sort card be wriiten to copy data from first column of a file and paste in the 16th column of the same file?

Please suggest me on this.

Posted: Thu May 24, 2012 11:17 am
by NicC
Please my I suggest you read some of the posts? This sort of thing seems to happen occasionally.

Posted: Thu May 24, 2012 1:30 pm
by William Collins
I wouldn't really call it copy/paste, but look at OVERLAY in the manual, or better explain what it is that you want.

Posted: Thu May 24, 2012 5:22 pm
by Anuj Dhawan
Can a sort card be wriiten to copy data from first column of a file and paste in the 16th column of the same file?
That's doable but why do you want to try such a suicidal effort – using same file as SORTIN and SORTOUT is not recommended.

Posted: Thu May 24, 2012 8:54 pm
by Frank Yaeger
archup20,

Well, you can use the same file for input and output if you do a SORT, but it's NOT really recommended since if something goes wrong you could lose your data set.

If you really want to do it, a DFSORT job like the following would work. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes:

Code: Select all

//S1 EXEC PGM=SORT                                
//SYSOUT DD SYSOUT=*                              
//SORTIN DD DISP=SHR,DSN=file         
//SORTOUT DD DISP=OLD,DSN=file
//SYSIN DD *                                      
  INREC OVERLAY=(16:1,1,81:SEQNUM,8,ZD)           
  SORT FIELDS=(81,8,ZD,A)                         
  OUTREC BUILD=(1,80)                             
If you are worried about losing the data set, a better approach would be to use two copy passes like this:

Code: Select all

//S1 EXEC PGM=ICETOOL                                            
//TOOLMSG DD SYSOUT=*                                            
//DFSMSG DD SYSOUT=*                                             
//IN DD DISP=OLD,DSN=file                   
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)       
//TOOLIN DD *                                                    
COPY FROM(IN) TO(T1) USING(CTL1)                                 
COPY FROM(T1) TO(IN)                                             
//CTL1CNTL DD *                                                  
  INREC OVERLAY=(16:1,1)