Page 1 of 1

put sort key in the end of input record during sorting

PostPosted: Wed Feb 03, 2010 5:47 am
by helen2000
Hi All,

I first put one sort key in the end of the input record using INREC, and then
sorting, I got the error message:"control fields beyond record"
my input file: VB, LRECL=2000

this is my jcl:
//SORTSTEP EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//IN DD DSN=MP.IMP0CMO9(0), DISP=SHR
//OUT DD DSN=MP.SORT.DATA,
//       DISP=(NEW,CATLG,CATLG),
//       UNIT SYSDA,
//       SPACE=(TRK,(20,50),RLSE)
//TOOLIN DD *
DATASORT FROM(IN) TO(OUT) HEADER TRAILER USING(CTL1)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=(13,2,BI,EQ,X'3068'),
                BUILD=(1,2004,X'00000000')),
        IFTHEN==(WHEN=(13,2,BI,EQ,X'3069'),
                 OVERLAY=(2005:537,4,BI)),
        IFTHEN==(WHEN=(13,2,BI,EQ,X'306A'),
                 OVERLAY=(2005:537,4,BI))
  SORT FIELDS=(91,10,CH,A,
               2005,4,BI,A,
               616,10,CH,A,
               614,2,BI,A)
/*
//*
I know the reason is 2005 > 2000+4, but I have to put the key to the end of the input record, anybody can
help me? thanks,
helen

Re: put sort key in the end of input record during sorting

PostPosted: Wed Feb 03, 2010 11:35 pm
by skolusu
helen2000,

I am not sure those are even valid control cards. By adding an additional fields at the end of of a VB file you are actually nullifying the concept of having VB file in the first place. For VB files you can add the constants right after the RDW and then remove them while writing out. Use the following

//SORTSTEP EXEC PGM=ICETOOL                             
//TOOLMSG  DD SYSOUT=*                                 
//DFSMSG   DD SYSOUT=*                                 
//IN       DD DSN=MP.IMP0CMO9(0),DISP=SHR               
//OUT      DD DSN=MP.SORT.DATA,                         
//            DISP=(NEW,CATLG,CATLG),                   
//            UNIT=SYSDA,                               
//            SPACE=(TRK,(20,50),RLSE)                 
//TOOLIN   DD *                                           
DATASORT FROM(IN) TO(OUT) HEADER TRAILER USING(CTL1)   
//*                                                     
//CTL1CNTL DD *
  OPTION VLSHRT                                       
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,4X,5)),           
        IFTHEN=(WHEN=(17,2,BI,EQ,X'3068'),             
             OVERLAY=(5:X'00000000')),                 
        IFTHEN=(WHEN=(17,2,BI,EQ,X'3069'),             
             OVERLAY=(5:541,4)),                       
        IFTHEN=(WHEN=(17,2,BI,EQ,X'306A'),             
             OVERLAY=(5:541,4))                         
                                                       
  SORT FIELDS=(095,10,CH,A,                             
               005,04,BI,A,                             
               620,10,CH,A,                             
               618,02,BI,A)                             
                                                       
  OUTFIL FNAMES=OUT,BUILD=(1,4,9)                       
//*                                                     

Re: put sort key in the end of input record during sorting

PostPosted: Thu Feb 04, 2010 3:48 am
by helen2000
thank you very much, Skolusu, I will try your idea today.
just now I use another idea and sorting is well. the jcl is as following:
  INREC IFTHEN=(WHEN=(13,2,BI,EQ,X'3068'),                   
                OVERLAY=(2005:537,4,BI,537:X'00000000'))     
  SORT FIELDS=(91,10,CH,A,                                   
               537,4,BI,A,                                   
               616,10,CH,A,                                   
               614,2,BI,A)                                   
  OUTREC IFTHEN=(WHEN=(13,2,BI,EQ,X'3068'),                   
                 OVERLAY=(537:2005,4,BI))                     


but I have a little bit confuse, the data in offset 537 is totally different between In and out record. the logical is I first put the data in offset 537 to offset 2005 before sorting,and then, I put back the data in offset 2005 to offset 537 after sorting. when I comment out the OUTREC in JCL, I can see the data
in offset 2005 is the same with the data in offset 537. why it will change after sorting.
could you give me a correct answer? thank you very much!

Re: put sort key in the end of input record during sorting

PostPosted: Thu Feb 04, 2010 10:56 pm
by skolusu
but I have a little bit confuse, the data in offset 537 is totally different between In and out record. the logical is I first put the data in offset 537 to offset 2005 before sorting,and then, I put back the data in offset 2005 to offset 537 after sorting. when I comment out the OUTREC in JCL, I can see the data in offset 2005 is the same with the data in offset 537. why it will change after sorting.


Helen,

when you 537,4,BI it is treated as an edited numeric input field to appear in the reformatted OUTFIL output record. So BI field is actually expanded to readable format. If you want to retain the original value , just code 537,4. You don't need to specify the format.

And as I mentioned earlier , remember that adding the fields at the end is a bad idea for VB files

Re: put sort key in the end of input record during sorting

PostPosted: Fri Feb 05, 2010 7:53 am
by helen2000
thanks for your help, Mr. Skolusu. It works very well using your code.
would you mind answer one more question for me?
I need shorten the length of out record to 1800, how to do that?
thanks again,Helen

Re: put sort key in the end of input record during sorting

PostPosted: Sat Feb 06, 2010 12:45 am
by Frank Yaeger
I need shorten the length of out record to 1800, how to do that?


It's not clear what you want to do. Do you want all of the VB records to be 1800 bytes long (not the best use of a VB file)? Or do you want the maximum LRECL of the output file to be 1800 with the records up to 1800 bytes long? Or do you want something else (what exactly)?

I don't really see how the length of 1800 relates to Kolusu's job.

Re: put sort key in the end of input record during sorting

PostPosted: Sun Feb 07, 2010 3:37 am
by helen2000
Hi, Frank, I want the maximum LRECL of the output file to be 1800, as well as I will cut the size which beyond 1800 for the output record. can I code like the following for the above skolusu's jcl:

OUTFIL FNAMES=OUT,BUILD=(1,4,9:9,1800)

thanks,

Helen

Re: put sort key in the end of input record during sorting

PostPosted: Mon Feb 08, 2010 11:01 pm
by skolusu
helen,

If all of the records in the input file have a length of 1800 then you are fine , but if you have short records then you will encounter ICE218A error. Also an 1800 LRECL for a VB file means that the actual data record is only 1796 bytes. So change your OUTFIL statement as follows

   OUTFIL FNAMES=OUT,BUILD=(1,4,9,1796)