Page 2 of 2

Re: How to include Year in Header1

PostPosted: Tue Sep 04, 2012 3:50 pm
by ankushgattani
we can do that using SYMNAMES:
Sortstep1: generate year and save the record into SYMVAR
Sortstep2: use the SYMVAR to write the year in the HEADER1.

But even this will need two steps.

Re: How to include Year in Header1

PostPosted: Tue Sep 04, 2012 5:06 pm
by bodatrinadh
Hi Ankush,

You can do it in single step...

//SYSPRINT DD SYSOUT=*                                             
//SYSOUT DD SYSOUT=*                                               
//SYMNAMES DD *                                                     
YEAR4,S'&LYR4'                                                     
//SORTIN  DD *                                                     
3NADH.TXT                                                           
CD AAAAAA                                                           
CD BBBBBB                                                           
CD CCCCCCC                                                         
CD DDDDDDD                                                         
LOCSITE PRI=5 CY SEC=1 CY U=TESTDA REC=FB LR=1402 BLOCKSI=0         
GET                                                       +         
USER.NONX.USER9999.SAMPLE(+1)'                                     
QUIT                                                               
//SORTOUT DD SYSOUT=*                                               
//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                 
  OUTFIL HEADER1=(YEAR4)                                           


And your Output will be :-

2012   ==> Current Year
3NADH.TXT                                         
CD AAAAAA
CD BBBBBB
CD CCCCCCC
CD DDDDDDD
LOCSITE PRI=5 CY SEC=1 CY U=TESTDA REC=FB LR=1402 BLOCKSI=0
GET                                                       +
USER.NONX.USER9999.SAMPLE(+1)'
QUIT

Re: How to include Year in Header1

PostPosted: Tue Sep 11, 2012 3:51 pm
by ankushgattani
Thanks Bodatrinadh

That worked fine.
But there is one issue, the output year comes in Character format. I need it in decimal format (ZD), as i have to subtract 1 from it and copy it to new file.
i tried this in OUTFILE HEADER1, didn't work, gave me syntax error
YEAR4,TO=ZD


--> Writing another sort card to generate CURRENTYEAR - 1 (2012 - 1 = 2011) is also fine by me.
I tried to do using the following SYMNAMES, but couldnt get the desired result.

YEAR4,S'&LYR4'-1
This job abended
and
YEAR4,S'&LYR4-1'
This job printed "2012-1".

Re: How to include Year in Header1

PostPosted: Wed Sep 12, 2012 11:30 am
by ankushgattani
I got the Answer:

I can subtract one from 2012 (in character format) using the following code:
Input data is:
xx2012xx

The overlay for output record can be defined as
Overlay=(1,2,(3,4,ZD,SUB,+1),M7,LENGTH=4,7,2)

Re: How to include Year in Header1

PostPosted: Wed Sep 12, 2012 12:26 pm
by BillyBoyo
You are defining it as ZD, not character (CH).

You don't need an EDIT mask if you just want simple digits.The parenthesis/brackets are not a bad idea, but I'd include the LENGTH= inside.

Re: How to include Year in Header1

PostPosted: Thu Sep 13, 2012 11:29 am
by ankushgattani
I tried
Overlay=(1,2,(3,4,ZD,SUB,+1),7,2)


But it gave me SPACES in place of "Year-1"
xx    xx


expected output was
xx2011xx

Re: How to include Year in Header1

PostPosted: Thu Sep 13, 2012 11:32 am
by ankushgattani
this is my input reord with HEX ON

XX2012XX
EEFFFFEE444444444444444444444444444444444444444444444444444444444444444
77201277000000000000000000000000000000000000000000000000000000000000000

Re: How to include Year in Header1

PostPosted: Thu Sep 13, 2012 11:43 am
by BillyBoyo
OVERLAY=(1,2,(3,4,ZD,SUB,+1,LENGTH=4),7,2)

Re: How to include Year in Header1

PostPosted: Thu Sep 13, 2012 12:28 pm
by ankushgattani
when i use
  OVERLAY=(1,2,(3,4,ZD,SUB,+1,LENGTH=4),7,2)

i get the following error
SYSIN :                                     
  OPTION COPY                               
  INREC IFTHEN=(WHEN=(1,1,CH,EQ,C'x'),       
  OVERLAY=(1:C'1',X,(3,4,ZD,SUB,+1,LENGTH=4),7,2)
                                  *         
  OUTFILE REMOVECC                           
WER268A  INREC STATEMENT   : SYNTAX ERROR   
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000


Without Parenthesis, The job runs fine, but it doesnt give the required output:
  OVERLAY=(1,2,3,4,ZD,SUB,+1,LENGTH=4,7,2)

the output is
xx011 xx

Re: How to include Year in Header1

PostPosted: Thu Sep 13, 2012 1:18 pm
by BillyBoyo
You had it working.

I thought the brackets were a nice idea, I've never used them like that.
I would do 3,4,ZD,SUB,+1,TO=ZD,LENGTH=4


I could "guess" (no Syncsort manual) that

(3,4,ZD,SUB,+1),TO=ZD,LENGTH=4


Would be as far as the brackets can get.