Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
techslam

New User

Joined: 03 Dec 2010
Posts: 87
Location: India

Posted: Sat Dec 03, 2011 10:43 pm    Post subject: Write output based on a condition

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

enrico-sorichetti

Global Moderator

Joined: 14 Mar 2007
Posts: 10439
Location: italy

 Posted: Sat Dec 03, 2011 11:03 pm    Post subject: Reply to: Write output based on a condition what happened when You searched the forums, the issue is not so complicated that You could not find the solution Yourself!
Frank Yaeger

DFSORT Moderator

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

Posted: Sun Dec 04, 2011 7:00 am    Post subject:

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
techslam

New User

Joined: 03 Dec 2010
Posts: 87
Location: India

 Posted: Mon Dec 05, 2011 1:12 pm    Post subject: Thanks a lot Frank
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Query to compare 2 values of 1 column... Poha Eater DB2 13 Fri Mar 09, 2018 10:45 am Copy set of records based on condition krish.deepu SYNCSORT 2 Thu Mar 08, 2018 11:39 am write multiple lines in PS file in cobol Balu5491 COBOL Programming 7 Wed Mar 07, 2018 10:27 am WRITE to VSAM giving duplicate RC picus_mf CICS 1 Fri Feb 23, 2018 2:52 pm how to add the amount for duplicate r... SRUTHI DRAVIDAMANI COBOL Programming 6 Wed Feb 21, 2018 7:21 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us