Add months but the parameter is from the data JCL

370 views Asked by At

I have data like this

----+----1----+----2----+----3----+-- 
000000002320110328087YY01200000020124

I want to add the months from column 11-18, with the value from 24-26

I am thinking about the outrec field is like this

11,8,Y4T,ADDMONS,24,3,TOGREG=Y4T(-)

But when I try it , it give rc=0016, because of the operand error ,

I am thinking about store the value of 24,3 to a variable then i put it to variable , but i dont know if JCL can provide that .. anyone can help?

Notes : i use dfsort , not icetool

and i dont want to hardcode it because i already try 11,8,Y4T,ADDMONS,+12,TOGREG=Y4T(-), and it works but if can , iwant to replace the "+12" with the value from column 24-26

3

There are 3 answers

0
apo On

I'm not aware of a way to do this with plain DFSORT.

For instance PARSE would not work, because it would fail to resolve %2:

INREC PARSE=(%1=(ABSPOS=11,FIXLEN=8),
             %2=(ABSPOS=24,FIXLEN=3)),
      BUILD=(%1,Y4T,ADDMONS,+%2,TOGREG=Y4T(-))

You might want to look at sort exits if you'd like to go with DFSORT.

3
Q.Reindeerson On

You get a bad return code because DFSORT doesn't know how to interpret the three bytes you gave it with 24,3.

You should use : 11,8,Y4T,ADDMONS,24,3,ZD,TOGREG=Y4T(-)

The ZD that I have inserted means : Zoned Decimal. It corresponds to a PIC 9 USAGE DISPLAY in Cobol.

You can interpret COMP-3 with PD and COMP-5 or BINARY with BI.

0
phunsoft On

The syntax diagram for ADDMONS for your case is shown as:

p,m,Y4T,ADDMONS,p,m,f,TOGREG=Y4T(-)

You're missing the f subparameter. Since the number of months to add is a series of digits, the format would be UFF. I ran this sort job:

//SORT#010 EXEC     PGM=ICEMAN                                     
//SYSOUT   DD       SYSOUT=*                                       
//SYSPRINT DD       SYSOUT=*                                       
//SORTIN   DD       *                                              
000000002320110328087YY01200000020124                              
/*                                                                 
//SORTOUT  DD       SYSOUT=*                                       
//SYSIN    DD       *                                              
           SORT     FIELDS=COPY                                    
           OUTREC FIELDS=(11,8,Y4T,ADDMONS,24,3,UFF,TOGREG=Y4T(-)) 
/*                                                                 

The result in SORTOUT is:

2012-03-28 

Is this what you wanted?