MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need to concatenate a file based on condition in input file

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
Jaya
Beginner


Joined: 02 Sep 2005
Posts: 77
Topics: 10
Location: Cincinnati

PostPosted: Wed Sep 20, 2006 1:19 pm    Post subject: Need to concatenate a file based on condition in input file Reply with quote

Hi

I have 3 input files

File1:
Code:
X1
X2
X3
X4
X5
X6
X7
X8
X9
SUZERO


File2:
Code:
SM
T2
T3
T4


File 3:
Code:
T5
T6


In file1, there is a record which satisfies a condition
Code:
 1,2,CH,EQ,C'SU',AND,3.4.CH,EQ,C'ZERO'


The required outputfile should be the concatenation of files in the order of
file2,file3,file1
Code:
SM
T2
T3
T4
T5
T6
X1
X2
X3
X4
X5
X6
X7
X8
X9
SUZERO



In file1, if there is a NO record which satisfies a condition
Code:
 1,2,CH,EQ,C'SU',AND,3.4.CH,EQ,C'ZERO'


The required outputfile should be the concatenation of files in the order of
file2,file1 i.e file3 records should not be included.
Code:
SM
T2
T3
T4
X1
X2
X3
X4
X5
X6
X7
X8
X9
SUZERO


Please advise if this can be done through a single step in icetool

Thanks,
Jaya.
_________________
"Great spirits have always encountered violent opposition from mediocre minds."
-Albert Einstein
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Sep 20, 2006 3:02 pm    Post subject: Reply with quote

Here's a DFSORT/ICETOOL job that will do what you want. It's a bit tricky, but it does work. If a record with the condition is not present, it generates an OMIT COND=ALL statement for CTL2CNTL. If a record with the condition is present, it generates INCLUDE COND=ALL and OMIT COND=ALL statements for CTL2CNTL and the OMIT statement is ignored as a duplicate.

Code:

//S1 EXEC PGM=ICETOOL                                           
//TOOLMSG DD SYSOUT=*                                           
//DFSMSG DD SYSOUT=*                                             
//IN1 DD DSN=&&I1,DISP=(OLD,PASS)                               
//IN2 DD DSN=&&I2,DISP=(OLD,PASS)                               
//IN3 DD DSN=&&I3,DISP=(OLD,PASS)                               
//OUT DD DSN=&&O1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)   
//TOOLIN DD *                                                   
COPY FROM(IN2) TO(OUT)                                           
COPY FROM(IN1) USING(CTL1)                                       
COPY FROM(IN3) TO(OUT) USING(CTL2)                               
COPY FROM(IN1) TO(OUT)                                           
//CTL1CNTL DD *                                                 
  INCLUDE COND=(1,2,CH,EQ,C'SU',AND,3,4,CH,EQ,C'ZERO')           
  OPTION STOPAFT=1                                               
  OUTFIL FNAMES=CTL2CNTL,REMOVECC,                               
    OUTREC=(C'  INCLUDE COND=ALL',80:X),                         
    TRAILER1=('  OMIT COND=ALL')                                 
//CTL2CNTL DD DSN=&&C2,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Jaya
Beginner


Joined: 02 Sep 2005
Posts: 77
Topics: 10
Location: Cincinnati

PostPosted: Wed Sep 20, 2006 3:43 pm    Post subject: Reply with quote

Thanks you very much FRANK!! This is a very nice trick and it works great! Also it is a very good learning that if we use two COND statement in sysin , the second statement would get ignored..

Thanks again,
Jaya.
_________________
"Great spirits have always encountered violent opposition from mediocre minds."
-Albert Einstein
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Sep 20, 2006 5:07 pm    Post subject: Reply with quote

Quote:
Thanks you very much FRANK!! This is a very nice trick and it works great!


Yeah, it is a cute trick. Glad I could help.

Quote:
if we use two COND statement in sysin , the second statement would get ignored..


Actually, it's an INCLUDE statement and an OMIT statement in this case. COND is just the parameter. An INCLUDE statement and an OMIT statement are mutually exclusive so DFSORT will accept the first and ignore the second (third, ...) in any combination (INCLUDE and INCLUDE, OMIT and OMIT, INCLUDE and OMIT, OMIT and INCLUDE). Since you get a RC=0, it doesn't hurt anything in this case to have the duplicate statement.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group