Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 BUT RETAIN HIGHEST VALUE ON NON-... leondan22 DFSORT/ICETOOL 2 Thu Dec 14, 2017 8:13 pm
No new posts Extract record for change in combinat... Trinadh DFSORT/ICETOOL 6 Thu Nov 23, 2017 3:32 pm
No new posts OUTREC with ALter Command scorp_rahul23 DFSORT/ICETOOL 1 Wed Nov 22, 2017 3:10 pm
No new posts JOINKEYS Paired and Unpaired Sort on ... MFwhiz DFSORT/ICETOOL 7 Tue Nov 07, 2017 2:46 am
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us