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

IFTHEN : Is there a better way?


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

New User


Joined: 30 Jun 2005
Posts: 37
Location: Germany

PostPosted: Fri Jul 31, 2020 1:32 pm
Reply with quote

I need to extract data starting from 07:24 at position 1 to next 07:24 at position 1.
This job is working:
Code:

//S1 EXEC PGM=SORT   
//SYSOUT DD SYSOUT=* 
//SORTIN DD *         
07:09                 
07:14                 
07:19                 
07:24                 
09:44                 
10:49                 
07:09                 
07:14                 
07:24                 
08:09                 
08:14                 
//SORTOUT DD SYSOUT=*
//SYSIN DD *                       
  OPTION COPY                       
  INREC IFTHEN=(WHEN=GROUP,         
  BEGIN=(1,5,CH,EQ,C'07:24'),       
        PUSH=(81:ID=3),HIT=NEXT,   
  END=(1,5,CH,EQ,C'07:24'))         
  OUTREC IFTHEN=(WHEN=GROUP,       
  BEGIN=(81,3,CH,EQ,C'001'),       
        PUSH=(85:ID=1),             
  END=(81,3,CH,EQ,C'002'))         
  OUTFIL FNAMES=(SORTOUT),         
        INCLUDE=(85,1,CH,EQ,C'1'), 
        BUILD=(1,80)               
  END                               
/*                                 

Result:
Code:

07:24
09:44
10:49
07:09
07:14
07:24

Is there a better way?
Thanks
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Fri Jul 31, 2020 2:45 pm
Reply with quote

Code:
  OPTION COPY                                                   
  INREC IFTHEN=(WHEN=GROUP,                                     
    BEGIN=(1,5,CH,EQ,C'07:24'),END=(1,5,CH,EQ,C'07:24'),         
    PUSH=(81:ID=3)),                                             
    IFTHEN=(WHEN=GROUP,BEGIN=(81,3,ZD,EQ,+1),END=(81,3,ZD,EQ,+2),
      PUSH=(81:81,3))                                           
  OUTFIL FNAMES=(SORTOUT),                                       
    INCLUDE=(81,3,ZD,EQ,+1),                                     
    REMOVECC,                                                   
    BUILD=(1,80)                                                 
  END
Back to top
View user's profile Send private message
kushkush

New User


Joined: 30 Jun 2005
Posts: 37
Location: Germany

PostPosted: Fri Jul 31, 2020 5:01 pm
Reply with quote

Thank you.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Fri Jul 31, 2020 8:56 pm
Reply with quote

May not be elegant but get you what you needed in one Group.
Code:
//S1        EXEC  PGM=SORT                                             
//SORTLIST  DD SYSOUT=*                                                 
//SORTIN    DD *                                                       
07:09                                                                   
07:14                                                                   
07:19                                                                   
07:24                                                                   
09:44                                                                   
10:49                                                                   
07:09                                                                   
07:14                                                                   
07:24                                                                   
08:09                                                                   
08:14                                                                   
//SORTOUT   DD SYSOUT=*                                                 
//SYSOUT    DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  OPTION COPY                                                           
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'07:24'),PUSH=(81:ID=1))   
  OUTFIL OUTREC=(1,80),INCLUDE=(81,1,ZD,EQ,1),TRAILER1=(C'07:24')                         

Output:

Code:
********************************* TOP OF DATA **********************************
07:24                                                                           
09:44                                                                           
10:49                                                                           
07:09                                                                           
07:14                                                                           
07:24                                                                           
******************************** BOTTOM OF DATA ********************************
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Fri Jul 31, 2020 9:26 pm
Reply with quote

Rohit Umarjikar wrote:
May not be elegant but get you what you needed in one Group.

Looks good to me. icon_wink.gif
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Fri Jul 31, 2020 11:00 pm
Reply with quote

Joerg.Findeisen wrote:
Rohit Umarjikar wrote:
May not be elegant but get you what you needed in one Group.

Looks good to me. icon_wink.gif
Thanks Joerg.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Sat Aug 01, 2020 11:32 am
Reply with quote

Depending on the presence of the Eyecatcher as end of a section, additional data may be added. IMHO a more general approach would make sense to use, also when not only one section is to be captured.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Sat Aug 01, 2020 9:35 pm
Reply with quote

That’s just for one selection specially the first one as asked. If anything changes then a more generic solution is certainly required.
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 Problem with IFTHEN=(WHEN=GROUP,BEGIN... DFSORT/ICETOOL 5
No new posts Cant find hex value using IFTHEN=(WHEN DFSORT/ICETOOL 12
No new posts Outrec IFTHEN builds data in wrong po... DFSORT/ICETOOL 6
No new posts IFTHEN HIT=NEXT BUILR should create m... DFSORT/ICETOOL 5
No new posts DO we have alternate syntax for IFTHEN? Compuware & Other Tools 8
Search our Forums:

Back to Top