Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
IFTHEN : Is there a better way?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
kushkush

New User


Joined: 30 Jun 2005
Posts: 33
Location: Germany

PostPosted: Fri Jul 31, 2020 1:32 pm    Post subject: IFTHEN : Is there a better way?
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

Active User


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

PostPosted: Fri Jul 31, 2020 2:45 pm    Post subject:
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: 33
Location: Germany

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

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

Senior Member


Joined: 21 Sep 2010
Posts: 2443
Location: NY,USA

PostPosted: Fri Jul 31, 2020 8:56 pm    Post subject:
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

Active User


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

PostPosted: Fri Jul 31, 2020 9:26 pm    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 2443
Location: NY,USA

PostPosted: Fri Jul 31, 2020 11:00 pm    Post subject:
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

Active User


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

PostPosted: Sat Aug 01, 2020 11:32 am    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 2443
Location: NY,USA

PostPosted: Sat Aug 01, 2020 9:35 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Outrec IFTHEN builds data in wrong po... saikarthik94 DFSORT/ICETOOL 6 Sun Mar 01, 2020 2:14 pm
No new posts IFTHEN HIT=NEXT BUILR should create m... speermb DFSORT/ICETOOL 5 Fri Jan 10, 2020 10:49 pm
No new posts DO we have alternate syntax for IFTHEN? useit Compuware & Other Tools 8 Wed May 29, 2019 3:50 pm
No new posts INREC IFTHEN question knobi SYNCSORT 2 Mon Apr 15, 2019 11:55 pm
No new posts OUTREC w. several IFTHEN variants Auryn DFSORT/ICETOOL 2 Thu Jul 19, 2018 8:11 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us