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

Using if -else-outrec in SORT


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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 Developer


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

PostPosted: Tue Mar 06, 2007 12:38 am
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:

Use [URL] BBCode for External Links
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
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 Developer


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

PostPosted: Thu May 10, 2007 1:40 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top