techslam
New User
Joined: 03 Dec 2010 Posts: 87 Location: India
|
|
|
|
Hi
I have an input file(LRECL=10) as below:
Code: |
ABC 11
XYZ 22
UVW 33
LMN 44
|
Now I want an output file based on the conditions , that is,
If the value of field-1 is ABC, then the value of field-2 must be hard-coded to 10
If the value of field-1 is XYZ, then the value of field-2 must be hard-coded to 20
If the value of field-1 is UVW, then the value of field-2 must be hard-coded to 30
If the value of field-1 is LMN, then the value of field-2 must be hard-coded to 40
Output file(LRECL=10) will look like this :-
Code: |
ABC 10
XYZ 20
UVW 30
LMN 40
|
I assume we can get this done using the IFTHEN. can someone please help me with this requirement.
All help is highly appreciated. thanks |
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Aslam,
Here are two ways to do what you asked for with DFSORT:
Method 1 - IFTHEN
Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
ABC 11
XYZ 22
UVW 33
LMN 44
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=(1,3,CH,EQ,C'ABC'),OVERLAY=(5:C'10')),
IFTHEN=(WHEN=(1,3,CH,EQ,C'XYZ'),OVERLAY=(5:C'20')),
IFTHEN=(WHEN=(1,3,CH,EQ,C'UVW'),OVERLAY=(5:C'30')),
IFTHEN=(WHEN=(1,3,CH,EQ,C'LMN'),OVERLAY=(5:C'40'))
|
Method 2 - CHANGE
Code: |
//S2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
ABC 11
XYZ 22
UVW 33
LMN 44
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC OVERLAY=(5:1,3,
CHANGE=(2,C'ABC',C'10',C'XYZ',C'20',
C'UVW',C'30',C'LMN',C'40'),
NOMATCH=(5,2))
|
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:
www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000080 |
|