SORTCARD help

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

Moderators: Frank Yaeger, Moderator Group

Post Reply
ratheshmkumar
Member
Posts: 4
Joined: Fri Jul 06, 2012 9:02 pm

SORTCARD help

Post by ratheshmkumar » Fri Jul 06, 2012 9:17 pm

Input VB file.
01YYYYYYYYYY
20AAAAAAAAAA
40BBBBBBBBBB404,404,404
40CCCCCCCCCC505,505,505
40DDDDDDDDDD404505404

Output FB file
404404404
505505505
404505404

I want the ','s removed from the record (13th character to 27) whose starting position is '40'

I want to know if this can be done in a single step. I have written the sortcard but it is done in 3 steps.

My sort cards below

1) Select the required data from the input file
SORT FIELDS=(17,15,CH,A)
INCLUDE COND=(5,2,CH,EQ,C'40')
OUTREC FIELDS=(17,15),CONVERT

2) Replace the commas
OPTION COPY
INREC FINDREP=(INOUT=(C',',C''))

3) Remove the duplicates
SORT FIELDS=(1,15,CH,A)
SUM FIELDS=NONE

Thanks

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Fri Jul 06, 2012 10:41 pm

Input VB file.

Code: Select all

5---10---15---20---25---30---35---40
01YYYYYYYYYY
20AAAAAAAAAA
40BBBBBBBBBB404,404,404
40CCCCCCCCCC505,505,505
40DDDDDDDDDD404505404
Output FB file

Code: Select all

0---5---10---15---20---25---30---35---40
404404404
505505505
404505404
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

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

Post by William Collins » Sat Jul 07, 2012 12:29 am

Use IFTHEN to identify those you want to change. Use FINDREP on the IFTHEN. Use STARTPOS/ENDPOS on the FINDREP.

Else explain better please.

ratheshmkumar
Member
Posts: 4
Joined: Fri Jul 06, 2012 9:02 pm

Post by ratheshmkumar » Sat Jul 07, 2012 2:08 am

@ Williams.
I want to remove the commas present in the record whose first 2 bytes is '40' and i want those records (17th to 27th byte) to the output file. I want to know if the 3 steps can be combined into 1.

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

Post by William Collins » Sat Jul 07, 2012 5:23 am

Use INCLUDE/OMIT for the 40s
Use INREC IFTHEN=(WHEN=INIT to BUILD the 15 bytes, followed by another IFTHEN=(WHEN=INIT for the FINDREP (as you only want those 15, don't bother with the "pos" bits I mentioned before).
SORT on 1,15
SUM FIELDS=NONE

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

Post by skolusu » Tue Jul 10, 2012 12:36 am

Use the following DFSORT JCL which will give you the desired results in a single pass of data

Code: Select all

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD DSN=Your Input VB File,DISP=SHR                            
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                            
  INCLUDE COND=(5,2,CH,EQ,C'40')                           
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,17,15)),              
  IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=5,INOUT=(C',',C''))),
  IFTHEN=(WHEN=(1,2,BI,LE,19),OVERLAY=(19:X))              
  SORT FIELDS=(5,15,CH,A)                                  
  SUM FIELDS=NONE                                          
  OUTFIL VTOF,BUILD=(5,15)                                 
//*
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

ratheshmkumar
Member
Posts: 4
Joined: Fri Jul 06, 2012 9:02 pm

Post by ratheshmkumar » Tue Jul 10, 2012 11:16 pm

Thanks it worked

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