Page 1 of 1

Increment numbers using SORT

PostPosted: Wed Nov 04, 2009 6:32 pm
by ANAND.GADRE
I have a control card used in a job which has some run numbers, and I would like to know whether I can increment them through a SORT step. It looks like this --

//SETVAR01 SET WEEK='516'
//SETVAR02 SET ABCGDG='G0365V00'
//SETVAR03 SET XYZGDG='G0367V00'

I want to add a step in my job which will increment all these numbers by 1. Can I do it through SORT?

Re: Increment numbers using SORT

PostPosted: Wed Nov 04, 2009 9:41 pm
by skolusu
ANAND.GADRE,

use the following DFSORT JCL which will give you the desired results. This job also automatically resets the counter to 1 when the counts exceeds 999 and 9999.

//STEP0100 EXEC PGM=SORT                               
//SYSOUT   DD SYSOUT=*                                 
//SORTIN   DD DATA,DLM=$$                               
//SETVAR01 SET WEEK='516'                               
//SETVAR02 SET ABCGDG='G0365V00'                       
//SETVAR03 SET XYZGDG='G0367V00'                       
$$                                                     
//SORTOUT  DD SYSOUT=*                                 
//SYSIN    DD *                                         
  SORT FIELDS=COPY                                     
  INREC IFTHEN=(WHEN=(9,2,ZD,EQ,1),                     
  OVERLAY=(22:+1,ADD,22,3,ZD,EDIT=(TTT))),             
  IFTHEN=(WHEN=(9,2,ZD,GT,1),                           
  OVERLAY=(25:+1,ADD,25,4,ZD,EDIT=(TTTT)))             
                                                       
  OUTREC IFTHEN=(WHEN=(22,3,ZD,EQ,0),OVERLAY=(24:C'1')),
         IFTHEN=(WHEN=(25,4,ZD,EQ,0),OVERLAY=(28:C'1'))
//*

Re: Increment numbers using SORT

PostPosted: Thu Nov 05, 2009 11:33 am
by ANAND.GADRE
Thank you..this does work !