How to sort an input file with a space

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

Moderators: Frank Yaeger, Moderator Group

Post Reply
deepu
Member
Posts: 15
Joined: Fri Apr 24, 2009 10:40 am

How to sort an input file with a space

Post by deepu » Tue Jun 16, 2009 3:40 pm

Hi,

My input is having 3 records say..
12345
1425
56478
.
.
.
.
so on..

Now the requirement is..

i will be checking for the 5th character in my input file..

If it is not a space than it should be written to the output as it is in the same order

If it is a space than the 3rd character in my output should be space and should write to the output file in the same order..

i am expecting the output as..

12345
14 25
56478
.
.
.
Can some one help me on the above scenarion using DFSORT/ICETOOL...

Thanks in Advance.
deepu.

nachi
Member
Posts: 22
Joined: Wed Mar 25, 2009 5:16 pm

Post by nachi » Tue Jun 16, 2009 9:06 pm

Here is the Sort JCL which may satisfy your requirement.

Code: Select all

//STEP010N EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//IN1      DD *
12345
1425
56478
//OUT      DD SYSOUT=*
//TOOLIN   DD *
  COPY FROM(IN1) TO(OUT) USING(CTL1)
/*
//CTL1CNTL DD *
 OUTREC IFOUTLEN=05,
 IFTHEN=(WHEN=(5,1,CH,EQ,C' '),
   BUILD=(1:1,2,3:C' ',4:3,2)),
 IFTHEN=(WHEN=NONE,
   BUILD=(1,5))
Assumption: LRECL = 5

- Nachi

skolusu
Member
Posts: 43
Joined: Sat Jul 26, 2008 12:38 am

Post by skolusu » Wed Jun 17, 2009 6:22 am

deepu,

The following DFSORT JCL will give you the desired results

Code: Select all

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD *                                            
12345                                                      
1425                                                       
56478                                                      
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                            
  SORT FIELDS=COPY                                         
  INREC IFTHEN=(WHEN=(5,1,CH,EQ,C' '),OVERLAY=(4:3,2,3:X)) 
//*
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

deepu
Member
Posts: 15
Joined: Fri Apr 24, 2009 10:40 am

Post by deepu » Wed Jun 17, 2009 4:13 pm

Thanks a bunch guys..it's working fine.... :wink:

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