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
 

 

Using if -else-outrec in SORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Deepti Bhopatkar

New User


Joined: 11 Apr 2006
Posts: 8
Location: Pune

PostPosted: Mon Mar 05, 2007 11:06 pm    Post subject: Using if -else-outrec in SORT
Reply with quote

Hi ,

I have a file in which i have two record types viz 1 and 2. Record types 1 are the header records and record type 2 are the detail records. There can be n number of detail records for one header record. In the copybook for this file rec type 2 is a redefines of rec type 1. I have to convert all the fields into display format. However the layout of rec type 1 and rec type 2 is different. so actually i need to check if rec type =1 , then outrec fields in some format and if rec type =2 , outrec fields in the format specified for rec type 2.
Can i accomplish this using sort/ice tool? ( I can not split the files according to record types and download seperately . It does not serve the pupose as i have to merge them manually later which is quite tedious. ) To put it in a nutshell can i use outrec conditionally?


Thanks and Regards,
Deepti
Back to top
View user's profile Send private message

dineshness

New User


Joined: 25 Dec 2006
Posts: 63
Location: Perambalur

PostPosted: Tue Mar 06, 2007 12:36 am    Post subject: Re: Using if -else-outrec in sort
Reply with quote

You can use make use of the IFTHEN clause of the OUTREC.
I assumed the first byte serves as a flag for finding out whether the record type is 1 or 2.
You can change it accordingly to your need.
Below is an example..,

Code:

  OPTION COPY
  OUTREC IFTHEN=((WHEN=(1,1,CH,EQ,'1'),
             BUILD = (1:1,6,PD,TO=ZD,LENGTH=6,
                            10:7,74)),
            IFTHEN=(WHEN=(1,1,CH,EQ,'2'),
             BUILD = (1,6,10:7,10,PD,TO=ZD,LENGTH=10,
                            17:17,64))


Dinesh.
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: Tue Mar 06, 2007 12:38 am    Post subject:
Reply with quote

Deepti,

Yes, you can use DFSORT'S IFTHEN function to do this kind of thing. Conceptually, for your example:

Code:

   OPTION COPY
   INREC IFTHEN=(WHEN=(p,1,CH,EQ,C'1'),BUILD=(type 1 reformatting)),
         IFTHEN=(WHEN=(p,1,CH,EQ,C'2'),BUILD=(type 2 reformatting))


For complete details on DFSORT's IFTHEN function, see:

www.ibm.com/servers/storage/support/software/sort/mvs/pdug/
Back to top
View user's profile Send private message
kaleelahamed

New User


Joined: 08 Jun 2006
Posts: 45
Location: Trumbull, CT

PostPosted: Thu May 10, 2007 1:19 am    Post subject: Can we remove duplicates in this option specified?
Reply with quote

Hi,

In the above example, can we use the Conditon like
for record type 1
SORT FIELDS=(1,3,CH,A,5,9,CH,A) AND remove duplicates
for record type 2
SORT FIELDS=(1,3,CH,A,23,10,CH,A) AND remove duplicates

Can this be done?
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: Thu May 10, 2007 1:40 am    Post subject:
Reply with quote

You can only sort the records one way per pass. You would need two different passes over the input records to use those two different SORT statements. For example, you could use two DFSORT steps or a DFSORT/ICETOOL step with two SORT operators (or two SELECT operators).
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 SORT to unpack a feild shr_amar DFSORT/ICETOOL 7 Fri Jul 07, 2017 4:32 am
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Optimize sort inrec parse vishwakotin DFSORT/ICETOOL 6 Mon Jun 26, 2017 11:15 pm
No new posts Reduce CPU Times for Join Sort santoshn SYNCSORT 12 Sat Jun 10, 2017 1:40 pm
No new posts Db2 load job abending in SORT mistah kurtz DB2 4 Mon Jun 05, 2017 3:58 pm


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