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

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
archup20
Member
Posts: 31
Joined: Thu Dec 09, 2010 9:53 am

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

Post by archup20 » Thu May 24, 2012 9:19 am

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.

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Thu May 24, 2012 11:17 am

Please my I suggest you read some of the posts? This sort of thing seems to happen occasionally.
Regards
Nic

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Thu May 24, 2012 1:30 pm

I wouldn't really call it copy/paste, but look at OVERLAY in the manual, or better explain what it is that you want.

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Thu May 24, 2012 5:22 pm

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.
Regards,
Anuj

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Thu May 24, 2012 8:54 pm

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)                                         
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others