IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Write output based on a condition


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Sat Dec 03, 2011 10:43 pm
Reply with quote

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
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10903
Location: italy

PostPosted: Sat Dec 03, 2011 11:03 pm
Reply with quote

what happened when You searched the forums,
the issue is not so complicated that You could not find the solution Yourself!
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Sun Dec 04, 2011 7:00 am
Reply with quote

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
Back to top
View user's profile Send private message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Mon Dec 05, 2011 1:12 pm
Reply with quote

Thanks a lot Frank
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts FileAid move data from two files to o... Compuware & Other Tools 5
No new posts Identify and write records containing... SYNCSORT 11
No new posts Filter records where condition is in ... SYNCSORT 6
No new posts Extract records for a specific condit... DFSORT/ICETOOL 25
No new posts Write record twice based on condition... SYNCSORT 7
Search our Forums:


Back to Top