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

Print next line strings when a condition match


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
tgmuntor

New User


Joined: 20 May 2020
Posts: 2
Location: Brazil

PostPosted: Wed May 20, 2020 9:08 pm
Reply with quote

Hello Dev,

I am trying to use SYNCSORT or even ICETOOL to print out information that are placed in the next line considering that I have a INCLUDE CONDITION as described below:

Input:

Code:
002567                                                    OPINFORETRI.  ENDED A
002568                 CP   UPDT BY A091540  MCP RERUN               APPL: EZBA
002569  12/26 11.20.29 CP   UPDT BY A091540      OPER JOBNAME : EZBATCH       
002570                                           RESTART OF: EZBATCH     CONFIR


CONDINTION:

Code:
INCLUDE   COND=(39,03,CH,EQ,C'MCP')


Desired Information:

11/26 11.20.29 EZBATCH

The difficulties that I am having is to get the strings that are placed in the next line of the desired condition.
Back to top
View user's profile Send private message
Joerg.Findeisen

Active User


Joined: 15 Aug 2015
Posts: 385
Location: Bamberg, Germany

PostPosted: Wed May 20, 2020 9:24 pm
Reply with quote

You should first be aware what SORT product you are using. SYNCSORT or DFSORT. icon_rolleyes.gif

Use INREC to start a GROUP beginning WHEN it starts with your condintion (WHEN=GROUP,BEGIN..PUSH=(..,SEQ=8)). On OUTFIL you filter for SEQ=<n>/String "RESTART OF:" and that's just it. Simple.
Back to top
View user's profile Send private message
tgmuntor

New User


Joined: 20 May 2020
Posts: 2
Location: Brazil

PostPosted: Wed May 20, 2020 10:32 pm
Reply with quote

I am using Z/OS DFSORT V2R4.
icon_biggrin.gif
Back to top
View user's profile Send private message
Joerg.Findeisen

Active User


Joined: 15 Aug 2015
Posts: 385
Location: Bamberg, Germany

PostPosted: Wed May 20, 2020 10:35 pm
Reply with quote

tgmuntor wrote:
I am using Z/OS DFSORT V2R4.
icon_biggrin.gif

Now you just need to code it in a good way.
Back to top
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 924
Location: Maryland

PostPosted: Wed May 20, 2020 11:30 pm
Reply with quote

Joerg.Findeisen wrote:
You should first be aware what SORT product you are using. SYNCSORT or DFSORT. icon_rolleyes.gif

For this particular issue there is no difference between those two.
Back to top
View user's profile Send private message
Joerg.Findeisen

Active User


Joined: 15 Aug 2015
Posts: 385
Location: Bamberg, Germany

PostPosted: Wed May 20, 2020 11:34 pm
Reply with quote

sergeyken wrote:
For this particular issue there is no difference between those two.

Posting in the right section of the forum perhaps? icon_wink.gif
Back to top
View user's profile Send private message
Joerg.Findeisen

Active User


Joined: 15 Aug 2015
Posts: 385
Location: Bamberg, Germany

PostPosted: Thu May 21, 2020 6:55 am
Reply with quote

For your given sample, this should work:
Code:
//DUMMY    EXEC PGM=ICEMAN
//SORTIN   DD *                                                         
                                                   OPINFORETRI.  ENDED A
                CP   UPDT BY A091540  MCP RERUN               APPL: EZBA
 12/26 11.20.29 CP   UPDT BY A091540      OPER JOBNAME : EZBATCH       
                                          RESTART OF: EZBATCH     CONFIR
/*                                                                     
//SYSOUT  DD SYSOUT=*                                                   
//SORTOUT DD SYSOUT=*                                                   
//SYSIN   DD *                                                         
  OPTION COPY                                                           
  INREC IFTHEN=(WHEN=GROUP,                                             
    BEGIN=(39,3,CH,EQ,C'MCP'),END=(2,2,CSF,EQ,NUM,AND,5,2,CSF,EQ,NUM), 
    PUSH=(134:SEQ=8))                                       
  OUTFIL FNAMES=(SORTOUT),                                             
    INCLUDE=(134,8,CSF,EQ,NUM),                                         
    REMOVECC,NODETAIL,                                                 
    TRAILER1=(2,14,X,58,8)                                             
  END                                                                   
/*

Output:
Code:
12/26 11.20.29 EZBATCH
Back to top
View user's profile Send private message
Joerg.Findeisen

Active User


Joined: 15 Aug 2015
Posts: 385
Location: Bamberg, Germany

PostPosted: Thu May 21, 2020 9:46 am
Reply with quote

If you have multiple instances, this should work better:

Code:
//SYSIN   DD *                                                         
  OPTION COPY                                                         
  INREC IFTHEN=(WHEN=GROUP,                                           
    BEGIN=(39,3,CH,EQ,C'MCP'),END=(2,2,CSF,EQ,NUM,AND,5,2,CSF,EQ,NUM),
      PUSH=(134:39,3))                                               
  OUTFIL FNAMES=(SORTOUT),                                             
    INCLUDE=(134,3,CH,EQ,C'MCP',AND,2,2,CSF,EQ,NUM,AND,5,2,CSF,EQ,NUM),                       
    REMOVECC,                                                         
    BUILD=(2,14,X,58,8)                                               
  END                                                                 
/*

Output:
Code:
12/26 11.20.29 EZBATCH
12/26 11.20.29 EZBATCH
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2567
Location: NYC,USA

PostPosted: Fri May 22, 2020 3:44 am
Reply with quote

Code:
//S1        EXEC  PGM=ICETOOL                                           
//TOOLMSG   DD SYSOUT=*                                                 
//DFSMSG    DD SYSOUT=*                                                 
//IN        DD *                                                       
                                              OPINFORETRI.  ENDED A     
                 CP   UPDT BY A091540  MCP RERUN               APPL: EZB
12/26 11.20.29 CP   UPDT BY A091540      OPER JOBNAME : EZBATCH         
                                      RESTART OF: EZBATCH     CONFIR   
//OUT       DD SYSOUT=*                                                 
//TOOLIN    DD *                                                       
SELECT FROM(IN) TO(OUT) ON(81,8,CH) LASTDUP USING(CTL1)                 
//CTL1CNTL DD *                                                         
  SORT FIELDS=COPY                                                     
  INREC IFTHEN=(WHEN=INIT,                                             
       OVERLAY=(81:SEQNUM,8,ZD)),                                       
        IFTHEN=(WHEN=(40,3,CH,EQ,C'MCP'),                               
       OVERLAY=(81:+1,ADD,81,8,ZD,M11,LENGTH=8))                       
  OUTFIL FNAMES=OUT,BUILD=(1,14,X,57,7)                                 
//*                                                                     

Output-
Code:
12/26 11.20.29 EZBATCH
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2567
Location: NYC,USA

PostPosted: Fri May 22, 2020 7:41 pm
Reply with quote

Joerg.Findeisen wrote:
If you have multiple instances, this should work better:

Code:
//SYSIN   DD *                                                         
  OPTION COPY                                                         
  INREC IFTHEN=(WHEN=GROUP,                                           
    BEGIN=(39,3,CH,EQ,C'MCP'),END=(2,2,CSF,EQ,NUM,AND,5,2,CSF,EQ,NUM),
      PUSH=(134:39,3))                                               
  OUTFIL FNAMES=(SORTOUT),                                             
    INCLUDE=(134,3,CH,EQ,C'MCP',AND,2,2,CSF,EQ,NUM,AND,5,2,CSF,EQ,NUM),                       
    REMOVECC,                                                         
    BUILD=(2,14,X,58,8)                                               
  END                                                                 
/*

Output:
Code:
12/26 11.20.29 EZBATCH
12/26 11.20.29 EZBATCH

The first match for the END will stop PUSH 'MCP' and it will consider that ends the Group.

Twisted your solution- This will work for multiple instances assuming no record format changes or has many different variable to code for

Code:
//SORTIN    DD *                                                       
                                              OPINFORETRI.  ENDED A     
                 CP   UPDT BY A091540  MCP RERUN               APPL: EZB
12/26 11.20.29 CP   UPDT BY A091540      OPER JOBNAME : EZBATCH         
12/26 11.20.29 CP   UPDT BY A091540      OPER JOBNAME : EZBATCH         
                                      RESTART OF: EZBATCH     CONFIR   
                                              OPINFORETRI.  ENDED A     
                 CP   UPDT BY A091540  MCP RERUN               APPL: EZB
12/26 11.21.29 CP   UPDT BY A091540      OPER JOBNAME : EZBATCH         
12/26 11.21.29 CP   UPDT BY A091540      OPER JOBNAME : EZBATCH         
                                      RESTART OF: EZBATCH     CONFIR   
//SORTOUT   DD SYSOUT=*                                                 
//SYSOUT    DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  OPTION COPY                                                           
  INREC IFTHEN=(WHEN=GROUP,                                             
    BEGIN=(40,3,CH,EQ,C'MCP'),                                         
    END=(1,1,CH,EQ,C' ',AND,40,3,CH,NE,C'MCP'),                         
      PUSH=(134:40,3))                                                 
  OUTFIL FNAMES=(SORTOUT),                                             
  INCLUDE=(134,3,CH,EQ,C'MCP',AND,1,1,CSF,EQ,NUM),
  REMOVECC,                                       
  BUILD=(1,14,X,57,7)                             
END


Output-
Code:
12/26 11.20.29 EZBATCH
12/26 11.20.29 EZBATCH
12/26 11.21.29 EZBATCH
12/26 11.21.29 EZBATCH
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 Command line placement in DB2I panels TSO/ISPF 2
No new posts REMOVE DUPLICATE RECORDS BASED ON A S... DFSORT/ICETOOL 4
No new posts File-aid batch how to repeat a line... Compuware & Other Tools 2
No new posts Next line in SQL DB2 4
No new posts JOINKEYS to match two input files on ... DFSORT/ICETOOL 3
Search our Forums:

Back to Top