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 

move one file if search is successfull

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


Joined: 12 Aug 2005
Posts: 102
Topics: 19

PostPosted: Mon Oct 09, 2006 3:29 am    Post subject: move one file if search is successfull Reply with quote

My requirement is to search for a particular field in a FILE A.
If my search is successfull then I need to move FILEB to the output file else FILEC to the output file.

1.Search 3 character field('LEA or FBA or VAB) from postion 50 to 52 in FILEA
2.If present move file B to output file
3.Search ('EDA' or DEA') in FILE A.
4.If present move file c to the output file.

How do i do this with sort.
can anyone help me as earlier.
Back to top
View user's profile Send private message
radkrish
Beginner


Joined: 12 Aug 2005
Posts: 102
Topics: 19

PostPosted: Mon Oct 09, 2006 3:52 am    Post subject: Reply with quote

I thought of using IDCAMS.First search the field 'LEA or FBA or VAB' and copy it to a file.Using IDCAMS I check for the presence of file content in it.Then based on the condition code I will use either FILE B OR FILE C.

But Iam looking for the solution which does all these things in a single step.
Back to top
View user's profile Send private message
radkrish
Beginner


Joined: 12 Aug 2005
Posts: 102
Topics: 19

PostPosted: Mon Oct 09, 2006 4:49 am    Post subject: Reply with quote

Some more on my side.
I tried the below one.

Code:
//************************************************************
//STEP02   EXEC PGM=ICETOOL,                                 
//            COND=(0,NE)                                     
//*                                                           
//INPUT1       DD  DSN=ABC.LNM.T30B,                   
//            DISP=SHR                                       
//*                                                           
//OUT1         DD  DSN=ABC.LNM.T30B1,DISP=SHR         
//OUT2         DD  DSN=ABC.LNM.T30B2,DISP=SHR         
//*                                                           
//OUT3         DD  DSN=ABC.SVN.T30OUT.OCTC,           
//            DISP=(OLD,CATLG,DELETE),                       
//            UNIT=SYSDA,SPACE=(CYL,(250,100),RLSE)           
//*                                                           
//DFSMSG       DD  SYSOUT=*                                   
//TOOLMSG      DD  SYSOUT=*                                   
//*                                                           
//TOOLIN       DD  * *** CONSTANT CONTROL CARDS ***           
COPY FROM(OUT1) TO(OUT3) USING(CTL1)                         
COPY FROM(OUT2) TO(OUT3) USING(CTL2)                         
//*                                                       
//CTL1CNTL     DD  * *** CONSTANT CONTROL CARDS ***       
  SORT FIELDS=COPY                                       
  INCLUDE COND=(50,3,SS,EQ,C'CDE,FDR,RT')               
//CTL2CNTL     DD  * *** CONSTANT CONTROL CARDS ***       
  SORT FIELDS=COPY                                       
  INCLUDE COND=(50,3,SS,EQ,C'MKK,MOV,GFV')               
/*    END OF INPUT                                       
//*


The above one is true only if CTL2 is true.

Either CTL1 or CTL2 will be true in this case.Hence only one output file is possible here.If CTL1 is true then I have to stop CTL2 processing or the vice-versa.

Hope Iam clear with my query.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Mon Oct 09, 2006 8:31 am    Post subject: Reply with quote

radkrish,

Try this job . Step0100 will set a return code of 4 when include condition results in an empty file. And it excuetes the step0200. If step0100 was succesful , ie. if it finds the included records , step0200 will be skipped for the condition codes check. Also pay attention to the Disp parameters.


Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*   
//SORTIN   DD DSN=ABC.LNM.T30B,
//            DISP=SHR
//SORTOUT  DD DSN=ABC.SVN.T30OUT.OCTC, 
//            DISP=(NEW,CATLG,DELETE),     
//            UNIT=SYSDA,                   
//            SPACE=(CYL,(250,100),RLSE)       
//SYSIN    DD *                             
  SORT FIELDS=COPY                         
  INCLUDE COND=(50,3,SS,EQ,C'CDE,FDR,RT')
  OPTION NULLOUT=RC4                       
/*
//STEP0200 EXEC PGM=SORT,COND=(0,EQ,STEP0100) 
//SYSOUT   DD SYSOUT=*   
//SORTIN   DD DSN=ABC.LNM.T30B,
//            DISP=SHR
//SORTOUT  DD DSN=ABC.SVN.T30OUT.OCTC, 
//            DISP=(MOD,CATLG,DELETE),         
//            UNIT=SYSDA,                       
//            SPACE=(CYL,(250,100),RLSE)           
//SYSIN    DD *                                 
  INCLUDE COND=(50,3,SS,EQ,C'MKK,MOV,GFV')
  SORT FIELDS=COPY                             
/*



Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
radkrish
Beginner


Joined: 12 Aug 2005
Posts: 102
Topics: 19

PostPosted: Mon Oct 09, 2006 9:17 am    Post subject: Reply with quote

Thanks for the reply.
But I shall explain the query again.

1.Consider 3 input files FILEA,FILEB,FILEC and one output file FILED.
1.Search field from postion 50 to 52 in FILEA.
2.If it is found then we need to move/copy FILEB(not FILEA) to the outfile FILED.
3.Similarly,If it is not found,then move/copy FILEC(not FILEA) to the outfile FILED.

In my code,INPUT1 is searched,either OUT1or OUT2 is moved to OUT3 based on the search criteria.

I ran it thru ICETOOL,
Code:
CE200I 0 IDENTIFIER FROM CALLING PROGRAM IS 0001                             
CE143I 0 BLOCKSET     COPY  TECHNIQUE SELECTED                               
CE000I 0 - CONTROL STATEMENTS FOR 5740-SM1, DFSORT REL 14.0 - 10:06 ON MON OCT
           SORT FIELDS=COPY                                                   
           INCLUDE COND=(50,3,SS,NE,C'GES,OV,SDC')                           
           OPTION NULLOUT=RC4                                                 
                  $                                                           
CE095A 0 INVALID OPTION STATEMENT OPERAND                                     
CE146I 0 END OF STATEMENTS FROM CTL1CNTL - PARAMETER LIST STATEMENTS FOLLOW   
         DEBUG NOABEND,ESTAE


Hope Iam clear with my query.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Mon Oct 09, 2006 9:31 am    Post subject: Reply with quote

Quote:

I ran it thru ICETOOL,

radkrish,

hmm where did you see ICETOOL in my post? I specifically gave a sort step. The sort step will not work with ICETOOL.

try this sort step.


Code:

//STEP0100 EXEC PGM=SORT       
//SYSOUT   DD SYSOUT=*         
//SORTIN   DD DSN=YOUR INPUT FILE A,
//            DISP=SHR
//SORTOUT  DD DUMMY                         
//SYSIN    DD *                       
  INCLUDE COND=(50,3,SS,EQ,C'CDE,FDR,RT')
  OPTION NULLOUT=RC4                       
  SORT FIELDS=COPY                         
/*                                         
//STEP0200 EXEC PGM=SORT,COND=(4,EQ,STEP0100)
//SYSOUT   DD SYSOUT=*                       
//SORTIN   DD DSN=YOUR INPUT FILE B,
//            DISP=SHR                       
//SORTOUT  DD DSN=YOUR OUTPUT FILE D,
//            DISP=(MOD,CATLG,DELETE),       
//            UNIT=SYSDA,                     
//            SPACE=(CYL,(1,1),RLSE)         
//SYSIN    DD *                               
  SORT FIELDS=COPY                           
/*                                           
//STEP0300 EXEC PGM=SORT,COND=(0,EQ,STEP0100)
//SYSOUT   DD SYSOUT=*                       
//SORTIN   DD DSN=YOUR INPUT FILE C,
//            DISP=SHR                       
//SORTOUT  DD DSN=YOUR OUTPUT FILE D,
//            DISP=(MOD,CATLG,DELETE),       
//            UNIT=SYSDA,                     
//            SPACE=(CYL,(1,1),RLSE)         
//SYSIN    DD *                               
  SORT FIELDS=COPY                           
/*                                   


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
radkrish
Beginner


Joined: 12 Aug 2005
Posts: 102
Topics: 19

PostPosted: Mon Oct 09, 2006 9:56 am    Post subject: Reply with quote

well! thatz fine.
As your valuable reply moved away from the expected result,I tried the option NULLOUT using ICETOOL.Only then I come to know that it should be specifically used with SORT alone.As I need the result in minimal number of steps(thought of finishing it in one single step),I tried different options.Using IDCAMS,it takes 4 steps.These 3 steps is minimal comparably.Thanks for all your replies.

It would be even better if it is possible to be done with one or 2 steps which would avoid me to write a program(that satisfies the reqmt in one single step in JCL).

Hope I would get it!
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: Mon Oct 09, 2006 10:54 am    Post subject: Reply with quote

radkrish,

FYI, you got the error message for NULLOUT because it is only supported by z/OS DFSORT V1R5 and above, but you're using DFSORT R14.
_________________
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
radkrish
Beginner


Joined: 12 Aug 2005
Posts: 102
Topics: 19

PostPosted: Mon Oct 09, 2006 11:01 am    Post subject: Reply with quote

Thanks Frank.You are rt.Iam using DFSORT REL 14.0.

Frank,Do we have any similar keyword in ICETOOL...
Is it possible to have the above need accomplished in one or two steps...?
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: Mon Oct 09, 2006 11:10 am    Post subject: Reply with quote

radkrish,

Here's a DFSORT/ICETOOL job that will do what you asked for in one step:

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//FILEA DD DSN=...  input fileA
//FILEB DD DSN=...  input fileB
//FILEC DD DSN=...  input fileC
//OUT DD DISP=MOD,DSN=...  output file (MOD)
//TOOLIN   DD *
  COUNT FROM(FILEA) EMPTY USING(CTL1)
  COPY FROM(FILEB) TO(OUT)
  MODE CONTINUE
  MODE STOP
  COUNT FROM(FILEA) EMPTY USING(CTL2)
  COPY FROM(FILEC) TO(OUT)
/*
//CTL1CNTL DD *
  INCLUDE COND=(50,3,SS,EQ,C'CDE,FDR,RT ')
/*
//CTL2CNTL DD *
  INCLUDE COND=(50,3,SS,EQ,C'MKK,MOV,GFV')
/*

_________________
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
radkrish
Beginner


Joined: 12 Aug 2005
Posts: 102
Topics: 19

PostPosted: Mon Oct 09, 2006 11:48 pm    Post subject: Reply with quote

Thanks Frank.

Am sure that this function is available for R14.But I got RC=12.

Code:
ICE630I 0 MODE IN EFFECT:  STOP                                               
                                                                               
            COUNT FROM(FILEA) EMPTY USING(CTL1)                               
ICE606I 0 DFSORT CALL 0001 FOR COPY FROM FILEA    TO E35 EXIT USING CTL1CNTL COMPLETED 
ICE646A 0 RECORD COUNT MEETS CRITERIA - RC=12 SET                             
ICE602I 0 OPERATION RETURN CODE:  12                                           
                                                                               
ICE630I 2 MODE IN EFFECT:  SCAN


Not sure why is it giving 12.
May be my shop is very downlevel in DFSORT service.
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: Tue Oct 10, 2006 10:28 am    Post subject: Reply with quote

Getting RC=0 or RC=12 for the COUNT operator with EMPTY is what makes this job work. MODE checks the RC to determine what to do next. (The use of EMPTY to get RC=0 or RC=12 for my job is similar to the use of NULLOUT=RC4 to get RC=0 or RC=4 for Kolusu's job).

If you get a match in FILEA for CDE, FDR or RT, but not MKK, MOV or GFV, OUT will have the records from FILEB and you'll get RC=12 for the job.

If you get a match in FILEA for MKK, MOV or GFV, but not for CDE, FDR or RT, OUT will have the records from FILEC and you'll get RC=12 for the job.

If you get a match in FILEA for CDE, FDR or RT, and for MKK, MOV or GFV, OUT will have the records from FILEB and FILEC you'll get RC=0 for the job.

If you don't get a match in FILEA for CDE, FDR, MKK, MOV or GFV, OUT will not have any records and you'll get RC=12 for the job.
_________________
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