Page 1 of 1

Packed decimal field in INCLUDE

PostPosted: Thu Oct 11, 2012 1:32 am
by bitbybit
I have account# defined as 9(15) comp-3, starting at position 51 in my input file. Acct# is always a 14 digit number and I need to split input file into 2 o/p files. One file having all records with last 2 digits of account# equal to 00 and the 2nd having other than 00. How do I write my INCLUDE or OMIT statement in sysin?
Any help is greatly appreciated.
Thnak you.

Re: referencing some bytes of a packed decimal field in INCL

PostPosted: Thu Oct 11, 2012 1:50 am
by skolusu
bitbybit,

9(15) comp-3 is an 8 byte PD field. You can use the PD0 format to select the desired records. PD0 ignores the first digit and trailing sign during processing. In your case the X'00' looks for X'h00h' in the last two bytes.(57-58)

Use the following DFSORT JCL which will give you the desired results. I assumed that it your input RECFM=FB . If your input is VB then you need add 4 bytes to the start position as the first 4 bytes has the RDW

//STEP0100 EXEC PGM=SORT                         
//SYSOUT   DD SYSOUT=*                           
//SORTIN   DD DSN=Your Input FB file,DISP=SHR                 
//OUT1     DD SYSOUT=*                           
//OUT2     DD SYSOUT=*                           
//SYSIN    DD *                                 
  SORT FIELDS=COPY                               
  OUTFIL FNAMES=OUT1,INCLUDE=(57,2,PD0,EQ,X'00')
  OUTFIL FNAMES=OUT2,SAVE                       
//*

Re: referencing some bytes of a packed decimal field in INCL

PostPosted: Thu Oct 11, 2012 2:17 am
by bitbybit
Thank you, that worked.
If I have to sort on the acct#, do I code
SORT FIELDS=(51,8,PD,D)
Or
SORT FIELDS=(51,14,PD,D)

Re: referencing some bytes of a packed decimal field in INCL

PostPosted: Thu Oct 11, 2012 2:29 am
by skolusu
bitbybit wrote:Thank you, that worked.
If I have to sort on the acct#, do I code
SORT FIELDS=(51,8,PD,D)
Or
SORT FIELDS=(51,14,PD,D)



Since your field is defined as 9(15) comp-3 , it will be a 8 byte PD field. You need to code
SORT FIELDS=(51,8,PD,D)