SUBTRAC FROM YEAR SYSTEM DATE



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

SUBTRAC FROM YEAR SYSTEM DATE

Postby Eric » Tue Feb 16, 2010 3:47 am

Hi,

I used two steps to perform subtraction (minus 1) from the year taken from the system date. Could a one step process be used instead ?

//STEP1 EXEC PGM=SORT
//*
//SORTLIB DD DSN=SYS1.SORTLIB,DISP=SHR
//SORTIN DD DSN=DATA1…,DISP=SHR
//SORTOUT DD DSN=DATA2…,DISP=OLD
//SYSIN DD *
SORT FIELDS=(5,2,CH,A)
INCLUDE COND=(5,2,CH,EQ,C'H7')
OUTREC FIELDS=(C'1',YEAR,2,2)
//SYMNAMES DD *
YEAR,S'&YR4'
/*

DATA2
12010H7…
12010H7…
12010H7…
12010H5..

//STEP2 EXEC PGM=SORT
//*
//SORTLIB DD DSN=SYS1.SORTLIB,DISP=SHR
//SORTIN DD DSN=DATA2,…..DISP=OLD
//SORTOUT DD DSN=DATA3,….DISP=SHR
//SYSIN DD *
SORT FIELDS=COPY
OUTREC OVERLAY=(2:2,4,ZD,SUB,1,1,ZD,EDIT=(TTTT))
/*
//SYSOUT DD SYSOUT=*

DATA3
12009H7
12009H7
12009H7
:

Regards, Eric
Eric
 
Posts: 6
Joined: Fri Feb 12, 2010 1:40 am
Has thanked: 0 time
Been thanked: 0 time

Re: SUBTRAC FROM YEAR SYSTEM DATE

Postby Frank Yaeger » Tue Feb 16, 2010 6:00 am

Could a one step process be used instead ?


Yes. But it's not clear from your example what exactly you're trying to accomplish.

Please show an example of the records in your input file and what you expect for output. Explain the rules for getting from input to output. Give the RECFM and LRECL of the input file. Give the starting position, length and format of all relevant fields.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: SUBTRAC FROM YEAR SYSTEM DATE

Postby Eric » Tue Feb 16, 2010 9:53 pm

Hi,

In my example before, i made a mistake in first step : the SORT FIELDS and INCLUDE condition should begin respectively at position 8 and 6.

SORT FIELDS=(8,2,CH,A)
INCLUDE COND=(6,2,CH,EQ,C'H7')
OUTREC FIELDS=(C'1',YEAR,6,16)
//SYMNAMES DD *
YEAR,S'&YR4'
/*

RECFM= FB and LRECL=21

Here are the three files corrected :

Data 1 - step1
123456789012345678901
*****************************
H7FELIX
H7ROSEMARIE
H7WILLIAM
H5ANABEL
****************************
Data 2 - step1 i reuse the field in position on for make a substrac
123456789012345678901
*****************************
12010H7FELIX
12010H7ROSEMARIE
12010H7WILLIAM
******************************

Data 3 - step2 the final result I expect note .
123456789012345678901
*****************************
12009H7FELIX
12009H7ROSEMARIE
12009H7WILLIAM
*****************************
I reuse the field in position one for make a substrac.

Could a one step process be used instead ?

Thanks,
Eric B.
Eric
 
Posts: 6
Joined: Fri Feb 12, 2010 1:40 am
Has thanked: 0 time
Been thanked: 0 time

Re: SUBTRAC FROM YEAR SYSTEM DATE

Postby Eric » Tue Feb 16, 2010 10:17 pm

Sorry, the spaces in position 1 to 5 were not preserved upon transfer to the forum.

Data 1 - step1
*123456789012345678901
******************************
* H7FELIX
* H7ROSEMARIE
* H7WILLIAM
* H5ANABEL
*****************************
Eric
 
Posts: 6
Joined: Fri Feb 12, 2010 1:40 am
Has thanked: 0 time
Been thanked: 0 time

Re: SUBTRAC FROM YEAR SYSTEM DATE

Postby Frank Yaeger » Tue Feb 16, 2010 11:23 pm

Sigh. I asked what you wanted for output, not what you did in your job. I still don't know what your output is supposed to look like. Do you want the '1' in position 1? Do you want the year-1 in positions 2-5? Or what?

Assuming you want a blank in position 1 and the year-1 in positions 2-5, you can use a single pass DFSORT job like this:

//S1    EXEC  PGM=SORT                           
//SYSOUT    DD  SYSOUT=*                         
//SYMNAMES DD *                                 
YEAR,S'&YR4'                                     
//SORTIN DD *                                   
      H7FELIX                                   
      H7ROSEMARIE                               
      H7WILLIAM                                 
      H5ANABEL                                   
//SORTOUT DD SYSOUT=*                           
//SYSIN    DD    *                               
  OPTION COPY                                   
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(2:YEAR,       
        2:2,4,ZD,SUB,+1,TO=ZD,LENGTH=4))         
/*


Note that I used ubb code tags to show the correct spacing - you can use them too.

If that's not what you want for output, then do a better job of showing (and explaining) what you do want for input and output.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: SUBTRAC FROM YEAR SYSTEM DATE

Postby Eric » Wed Feb 17, 2010 1:20 am

That's what I wanted and I added the '1' in position 1.

SORT FIELDS=(8,2,CH,A)                           
 INCLUDE COND=(6,2,CH,EQ,C'H7')                   
   OPTION COPY                                   
   INREC IFTHEN=(WHEN=INIT,OVERLAY=(1:C'1',2:YEAR,
         2:2,4,ZD,SUB,+1,TO=ZD,LENGTH=4))         

----+----1----+----2-
*********************
12009H7FELIX         
12009H7ROSEMARIE     
12009H7WILLIAM       
*********************



Thanks and I will consider your suggestion to be more effective in my future issue.

Eric B.
Eric
 
Posts: 6
Joined: Fri Feb 12, 2010 1:40 am
Has thanked: 0 time
Been thanked: 0 time

Re: SUBTRAC FROM YEAR SYSTEM DATE

Postby Frank Yaeger » Wed Feb 17, 2010 2:24 am

That's what I wanted and I added the '1' in position 1.


Good.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post