prefix with quater and year



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

prefix with quater and year

Postby David2k8 » Mon Mar 30, 2015 3:11 pm

//Jobnaem JOB ,,REGION=0M,CLASS=A,MSGCLASS=Z,         
//             NOTIFY=&SYSUID                                     
//STEP1    EXEC PGM=SORT                                           
//SYMNAMES DD *                                                   
  YR4,S'&YR4'             -- Gives year 4 'YYYY'bytes                                                     
  MON,S'&MON'           -- Gives MONTH in number'01'  for JAN and so on
//SORTIN   DD *                                                   
[b]Q#YYYY_RECORD    [/b]                                                 
//SYSOUT   DD SYSOUT=*                                             
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                   
  OPTION COPY                                                     
  INREC OVERLAY=(3:YR4,16:MON)                                     
  OUTREC IFTHEN=(WHEN=(16,2,ZD,GE,1,&,16,2,ZD,LE,3),               
         OVERLAY=(2:C'1',16:2X)),                                 
         IFTHEN=(WHEN=(16,2,ZD,GE,4,&,16,2,ZD,LE,6),               
         OVERLAY=(2:C'2',16:2X)),                                 
         IFTHEN=(WHEN=(16,2,ZD,GE,7,&,16,2,ZD,LE,9),               
         OVERLAY=(2:C'3',16:2X)),                     
         IFTHEN=(WHEN=(16,2,ZD,GE,10,&,16,2,ZD,LE,12),
         OVERLAY=(2:C'4',16:2X))                       
/*   


Output : (run on march 2015)

Q12015_RECORD

Code'd
David2k8
 
Posts: 7
Joined: Mon Mar 23, 2015 10:32 am
Has thanked: 0 time
Been thanked: 2 times

Re: prefix with quater and year

Postby Terry Heinze » Mon Mar 30, 2015 7:02 pm

In the future, please use Code tags for readability.
.... Terry
Terry Heinze
 
Posts: 239
Joined: Wed Dec 04, 2013 11:08 pm
Location: Richfield, MN, USA
Has thanked: 12 times
Been thanked: 11 times

Re: prefix with quater and year

Postby BillyBoyo » Mon Mar 30, 2015 8:46 pm

You have coded a SYMNAMES DD, why not use it a bit more? Why no SYMNOUT DD. You've overcomplicated things with the IFTHENs. There is no need to "protect" against a previous hit on an IFTHEN=(WHEN=(logical-expression) because that first hit stops the processing for that record (to continue processing, you need to explicitly include HIT=NEXT).
//SYMNAMES DD *                                                   
  YR4,S'&YR4'             -- Gives year 4 'YYYY'bytes                                                     
  MON,S'&MON'           -- Gives MONTH in number'01'  for JAN and so on
  OVERLAID-YEAR,3,4,CH
  OVERLAID-QUARTER,2,1,CH
  APPENDED-MONTH,16,2,CH
  Q1,C'1'
  Q2,C'2'
  Q3,C'3'
  Q4,C'4'
  Q1-END,C'03'
  Q2-END,C'06'
  Q3-END,C'09'
  Q4-END,C'12'
//SYMNOUT  DD SYSOUT=*                                             
//SORTIN   DD *                                                   
Q#YYYY_RECORD                           
//SYSOUT   DD SYSOUT=*                                             
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                   
  OPTION COPY                                                     
  INREC IFOUTLEN=16,
         IFTHEN=(WHEN=INIT,
                  OVERLAY=(OVERLAID-YEAR:YR4,APPENDED-MONTH:MON)),
         IFTHEN=(WHEN=(APPENDED-MONTH,LE,Q1-END),               
                  OVERLAY=(OVERLAID-QUARTER:Q1)),                                 
         IFTHEN=(WHEN=(APPENDED-MONTH,LE,Q2-END),               
                  OVERLAY=(OVERLAID-QUARTER:Q2)),                                 
         IFTHEN=(WHEN=(APPENDED-MONTH,LE,Q3-END),               
                  OVERLAY=(OVERLAID-QUARTER:Q3)),
         IFTHEN=(WHEN=(NONE),               
                  OVERLAY=(OVERLAID-QUARTER:Q4))


Something like that for you to try (untested).

It's best if you wait around to answer specific questions, rather than dumping code which worked for you before but which was never exposed to critique.

A better way to do it than the IFTHEN= is with CHANGE, so have a go at that if you like.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post