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 

DFSORT Multiple IFTHEN=(WHEN

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


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Mon Jul 06, 2015 11:47 am    Post subject: DFSORT Multiple IFTHEN=(WHEN Reply with quote

Hi,

I am just trying to extract some information from SARLOG. Sarlog has multiple job log, I could restrict the information by provding following condition.

Code:

INCLUDE COND=((02,07,CH,EQ,C'* END *',AND,             
               64,07,CH,EQ,C'CA VIEW'),OR,             
              (02,16,CH,EQ,C'INSERT ROW COUNT'),OR,   
              (02,01,CH,EQ,C'H',AND,                   
               09,18,CH,EQ,C'RESTART DATA SAVED'))     


File1
Code:

 H1300- RESTART DATA SAVED/INSERTED=\ZZZ25SCP\ZZZ25S23\2015-07-03\N\YYY_QQQQ_IIII_SSS \0000000000
 INSERT ROW COUNT  = 000037824
 * END *************************************                   CA VIEW                    *******************************
 H1300- RESTART DATA SAVED/INSERTED=\ZZZ34QQ \ZZZ30S21\2015-07-03\N\YYY_WWWWWWW       \0000000000
 INSERT ROW COUNT  = 0072836
 * END *************************************                   CA VIEW                    *******************************
 H1300- RESTART DATA SAVED/INSERTED=\ZZZ35QQ \ZZZ30S22\2015-07-03\N\YYY_WWWWWWW_SSS   \0000000000
 INSERT ROW COUNT  = 0010018
 * END *************************************                   CA VIEW                    *******************************
 H1300- RESTART DATA SAVED/INSERTED=\ZZZ44QQ \ZZZ22S21\2015-07-03\N\UUU7X24           \0000000000
 INSERT ROW COUNT  =2488741
 INSERT ROW COUNT  =2511092
 INSERT ROW COUNT  =2522681
 INSERT ROW COUNT  =2644465
 INSERT ROW COUNT  =2723244
 INSERT ROW COUNT  =2858500
 INSERT ROW COUNT  =2875591
 INSERT ROW COUNT  =3154991
 INSERT ROW COUNT  = 3170564
 * END *************************************                   CA VIEW                    *******************************
 H1300- RESTART DATA SAVED/INSERTED=\ZZZ45QQ \ZZZ22S22\2015-07-03\N\UUU7X44_SSS       \0000000000
 INSERT ROW COUNT  =0218949
 INSERT ROW COUNT  = 0649236
 * END *************************************                   CA VIEW                    *******************************
 H1300- RESTART DATA SAVED/INSERTED=\PPP1AQQ3\RRR1AS1 \2015-07-03\N\YYY_PPPQA_MOD     \0000000000
 INSERT ROW COUNT  = 0166084
 * END *************************************                   CA VIEW                    *******************************
 H1300- RESTART DATA SAVED/INSERTED=\PPP1AQQ5\AAA1AS3 \2015-07-03\N\YYY_PPPQA_MOD_SSS \0000000000
 INSERT ROW COUNT  = 0023167
 * END *************************************                   CA VIEW                    *******************************


File2
Code:

ZZZ25SCP22:11:19
ZZZ34QQ 22:22:40
ZZZ35QQ 21:28:40
ZZZ44QQ 21:30:19
ZZZ45QQ 21:49:26
PPP1AQQ322:33:06
PPP1AQQ521:21:05



Expected output is as follows. If we notice, UUU7X24 has multiple insert count, But we need only last count of the job and Time which is available in File2

Code:

ZZZ25SCPYYY_QQQQ_IIII_SSS 000037824   ,22:11:19 
ZZZ34QQ YYY_WWWWWWW       0072836     ,22:22:40 
ZZZ35QQ YYY_WWWWWWW_SSS   0010018     ,21:28:40 
ZZZ44QQ UUU7X24           3170564     ,21:30:19 
ZZZ45QQ UUU7X44_SSS       0649236     ,21:49:26 


The code which i tried is follows.
Code:

//SYSIN DD *                                               
  JOINKEYS FILE=F1,FIELDS=(4,8,A),SORTED,NOSEQCK           
  JOINKEYS FILE=F2,FIELDS=(1,8,A),SORTED,NOSEQCK           
  REFORMAT FIELDS=(F1:1,45,F2:9,8)                         
  INCLUDE COND=(1,3,CH,EQ,C'IRC')                           
  SORT FIELDS=(4,26,CH,A,42,4,CH,D)                        $42,4 is a seqnum to find last insert count record         
  OUTREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(4,26),RECORDS=1,     
                 PUSH=(54:ID=1))                           $set values for last insert count of the job
  OUTFIL INCLUDE=(54,1,CH,NE,C' '),                        $remove other insert counts       
         BUILD=(4,26,30,12,SQZ=(SHIFT=LEFT,PREBLANK=C'='), 
                C',',46,08)                                $ remove "=" symbols
//JNF1CNTL DD *                                             
  OPTION COPY                                               
  INCLUDE COND=((02,07,CH,EQ,C'* END *',AND,               
                 64,07,CH,EQ,C'CA VIEW'),OR,               
                (02,16,CH,EQ,C'INSERT ROW COUNT'),OR,       
                (02,01,CH,EQ,C'H',AND,                     
                 09,18,CH,EQ,C'RESTART DATA SAVED'))       
                                                           
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(2,1,CH,EQ,C'H'),         
                           END=(2,7,CH,EQ,C'* END *'),     
                                                               
        IFTHEN=(WHEN=INIT,                                     
          BUILD=(2,1,9,1,13,1,122,8,130,18,20,12,SEQNUM,4,ZD, 
                          RESTART=(122,26)))                   
/*


Please advise, Is there any other best way to achive this.

Thanks
Magesh
Back to top
View user's profile Send private message
William Collins
Supermod


Joined: 03 Jun 2012
Posts: 437
Topics: 0

PostPosted: Mon Jul 06, 2015 4:26 pm    Post subject: Reply with quote

How about get rid of the SORT, and use OUTFIL with REMOVECC,NODETAIL and SECTIONS for your key and with TRAILER3 producing the record (it will do so with the last data record, which is the one you want.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Jul 06, 2015 5:21 pm    Post subject: Reply with quote

mageshv,

Assuming that your file1 has an lrecl of 133 bytes and has a recfm=fb, use the following JCL

Code:

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//INA      DD DISP=SHR,DSN=Your sarlog file with lrecl=133 and recfm=fb
//INB      DD *                                         
ZZZ25SCP22:11:19                                         
ZZZ34QQ 22:22:40                                         
ZZZ35QQ 21:28:40                                         
ZZZ44QQ 21:30:19                                         
ZZZ45QQ 21:49:26                                         
PPP1AQQ322:33:06                                         
PPP1AQQ521:21:05                                         
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                         
  OPTION COPY                                           
  JOINKEYS F1=INA,FIELDS=(134,5,A),SORTED,NOSEQCK       
  JOINKEYS F2=INB,FIELDS=(004,5,A),SORTED,NOSEQCK       
  REFORMAT FIELDS=(F2:1,8,F1:139,18,F1:22,09,F2:9,8)     
  OUTFIL REMOVECC,NODETAIL,BUILD=(47X),                 
  SECTIONS=(1,26,                                       
  TRAILER3=(1,35,3X,',',36,8))                           
//*                                                     
//JNF1CNTL DD *                                         
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(2,1,CH,EQ,C'H'),       
  END=(2,7,CH,EQ,C'* END *'),PUSH=(134:41,5,69,18)),     
  IFTHEN=(WHEN=(2,7,CH,EQ,C'* END *'),OVERLAY=(134:5X)) 
//*

_________________
Kolusu
www.linkedin.com/in/kolusu
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