Controlling Return Codes of SORT

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

Moderators: Frank Yaeger, Moderator Group

Post Reply
User avatar
Kalicharan
Moderator
Posts: 31
Joined: Wed Feb 08, 2006 1:51 pm

Controlling Return Codes of SORT

Post by Kalicharan » Tue Nov 07, 2006 4:36 pm

Hi,

Here is my requirement

File-A
1234512345

File-B
1234512344

Only one record (of length 10) is present in both File-A and File-B.

If Record(File-A) > Record(File-B) then SORT should return 4
otherwise 0.

So how to get this using any SORT.

Thanks
Kalicharan.

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

Post by Frank Yaeger » Tue Nov 07, 2006 11:29 pm

Here's a DFSORT/ICETOOL job that will do what you asked for.

Code: Select all

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//CON DD DSN=...  input file1 (FB/10)
//    DD DSN=...  input file2 (FB/10)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//TOOLIN DD *
* Get 1 record if field1>field2 or 0 records if field1<=field2.
SORT FROM&#40;CON&#41; USING&#40;CTL1&#41;
* If we have 1 record &#40;field1>field2&#41;, set RC=4.
* If we have 0 records &#40;field1<=field2&#41;, set RC=0.
COUNT FROM&#40;T1&#41; NOTEMPTY RC4
/*
//CTL1CNTL DD *
* Add 'A' in position 11 of both records so we can sort on it.
* Add seqnum in position 12 so we can identify record 2.
  INREC IFTHEN=&#40;WHEN=INIT,OVERLAY=&#40;11&#58;C'A',12&#58;SEQNUM,1,ZD&#41;&#41;,
* Change 10-byte value in file2 record to a negative value.
        IFTHEN=&#40;WHEN=&#40;12,1,CH,EQ,C'2'&#41;,
          OVERLAY=&#40;1&#58;1,10,ZD,MUL,-1,TO=ZD,LENGTH=10&#41;&#41;
* Sort on 'A' in 12 so we can use SUM to get field1-field2.
  SORT FIELDS=&#40;11,1,CH,A&#41;
  OPTION EQUALS
* Use SUM to get field1-field2.
  SUM FIELDS=&#40;1,10,ZD&#41;
* If field1>field2, keep record, otherwise omit it.
  OUTFIL FNAMES=T1,INCLUDE=&#40;1,10,ZD,GT,+0&#41;
/*
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