Assigning values to fields using SORT

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

Moderators: Frank Yaeger, Moderator Group

Post Reply
Posts: 2
Joined: Wed Sep 15, 2010 6:53 pm

Assigning values to fields using SORT

Post by rcgmf » Fri Jul 29, 2011 10:53 am


I have a requirement to assign certain values to a field in the output file depending on the values in another field in the input file in JCL. Here is an example:
Input fields: InField1, InField2, InField3
Output fields: OutField1, OutField2, OutField3
Condition is: If InField1='0', OutField2='A'. If InField1='1', OutField2='B'

I want to achieve this using a SORT program. Is there any way to do this?
Please help.


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

Post by Frank Yaeger » Fri Jul 29, 2011 9:58 pm

There are several ways to do this with DFSORT.

One way is with DFSORT IFTHEN clauses. For example, if infield1/outfield1 is in position 1 and infield2/outfield2 11 is in position 11, you could use these DFSORT control statements:

Code: Select all

   INREC IFTHEN=(WHEN=(1,1,CH,EQ,C'0'),OVERLAY=(11:C'A')),
If you need more specific help, give more details about what you're trying to do.

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from: ... g3T7000080
Frank Yaeger - DFSORT Development Team (IBM) -
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at

Posts: 2
Joined: Wed Sep 15, 2010 6:53 pm

Post by rcgmf » Tue Aug 02, 2011 9:24 am

Thanks Frank. That was exactly what I was looking for.

Post Reply


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.
Mainframe Interview questions

Other References
Mainframe Tools and others