Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Write output based on a condition

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Write output based on a condition
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10211
Location: italy

PostPosted: Sat Dec 03, 2011 11:03 pm    Post subject: Reply to: Write output based on a condition
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 Moderator


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

PostPosted: Sun Dec 04, 2011 7:00 am    Post subject:
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:

http://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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Incorrect output when trying to add n... monica1 PL/I & Assembler 10 Fri Jan 13, 2017 5:02 pm
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts Syncsort - Hard coded Value in output PORYES SYNCSORT 1 Thu Nov 03, 2016 9:23 am
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us