Page 1 of 1

Parsing JCL to get right most value

PostPosted: Fri Mar 04, 2011 9:25 pm
by rjambu
Hi
I need to format a i/p file to a required format
here is the I/p file

I/p data:

1999¦910¦111114-9¦111114-9¦¦OH¦
1999¦910¦111115-9¦111115-9¦¦PA¦
1999¦S02¦000000000000600000¦000000000000600000¦¦NY¦
1999¦S02¦000000000000600000¦000000000000600000¦¦NJ¦
1999¦¦111116-9¦111116-9¦¦AZ¦

Req:
the o/p should be having

1st column not considered in the o/p value
2nd column 3 char
3rd column 6 char
4th column 1 char from right (Eg: 111111-2 o/p should be 2)
5th column 2 char if dat is not there blank space
6th column 2 char


Required o/p should be like this

9101111149  OH
9101111159  PA
S020000000  NY
S020000000  NJ
   1111169  AZ

My parser JCL is like

//SYSOUT   DD SYSOUT=*                                 
//SORTIN   DD  DSN=A.B.SRC,DISP=SHR         
//SORTOUT  DD  DSN=A.B.TGT,               
//             UNIT=DISK,SPACE=(TRK,(1,2),RLSE),       
//             DCB=(LRECL=18,BLKSIZE=0,RECFM=FB),     
//             DISP=(NEW,CATLG,DELETE)                 
//SYSSORT  DD SYSOUT=*                                 
//SYSUDUMP DD SYSOUT=*                                 
//*                                                     
//SYSIN    DD  *                                       
 SORT FIELDS=COPY                                       
 INREC PARSE=(%00=(ENDBEFR=X'6A',FIXLEN=04),           
              %01=(ENDBEFR=X'6A',FIXLEN=03),           
              %02=(ENDBEFR=X'6A',FIXLEN=06),           
              %03=(ENDBEFR=X'6A',FIXLEN=01),           
              %04=(ENDBEFR=X'6A',FIXLEN=02),     
              %05=(ENDBEFR=X'6A',FIXLEN=02)),     
BUILD=(%01,%02,%03,%04,%05)
/*
//



I struck with getting the 4th column right most data, if Just specify 1 it takes from left 1 char.
Can any one suggest the way to do it

Thanks
JRS

Re: Parsing JCL to get right most value

PostPosted: Sat Mar 05, 2011 12:00 am
by Frank Yaeger
You can use a DFSORT job like the following to do what I think you're asking for:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
1999¦910¦111114-9¦111114-9¦¦OH¦
1999¦910¦111115-9¦111115-9¦¦PA¦
1999¦S02¦000000000000600000¦000000000000600000¦¦NY¦
1999¦S02¦000000000000600000¦000000000000600000¦¦NJ¦
1999¦¦111116-9¦111116-9¦¦AZ¦
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  OPTION COPY
  INREC IFOUTLEN=80,
   IFTHEN=(WHEN=INIT,
    PARSE=(%=(ENDBEFR=X'6A'),
     %02=(ENDBEFR=X'6A',FIXLEN=3),
     %03=(ENDBEFR=X'6A',FIXLEN=6),
     %04=(ENDBEFR=X'6A',FIXLEN=20),
     %05=(ENDBEFR=X'6A',FIXLEN=2),
     %06=(ENDBEFR=X'6A',FIXLEN=2)),
    BUILD=(%02,%03,%04,JFY=(SHIFT=RIGHT),%05,%06)),
   IFTHEN=(WHEN=INIT,
     BUILD=(1,9,29,5))
/*

Re: Parsing JCL to get right most value

PostPosted: Sat Mar 05, 2011 2:47 am
by rjambu
Thanks Frank,

Here is another issue in adding 2 column data

//SORTOUT  DD  DSN=A.B.C,               
//             UNIT=DISK,SPACE=(TRK,(1,2),RLSE),     
//             DCB=(LRECL=500,BLKSIZE=0,RECFM=FB),   
//             DISP=(NEW,CATLG,DELETE)               
//SYSSORT  DD SYSOUT=*                               
//SYSUDUMP DD SYSOUT=*                               
//*                                                 
/SYSIN    DD  *                             
SORT FIELDS=COPY                           
INREC PARSE=(%00=(ENDBEFR=X'6A',FIXLEN=03),
             %01=(ENDBEFR=X'6A',FIXLEN=482),
             %04=(ENDBEFR=X'6A',FIXLEN=08),
             %05=(ENDBEFR=X'6A',FIXLEN=01)),
BUILD=(%00,%04,UFF,Lenght=6,%01,%04,%05)                 
/*
//

I/P

670¦Demo sales amt¦¦222222-5¦
905¦Sample Data¦¦123456-5¦
800¦order amt¦¦121212-5¦
120¦Item number descr¦¦121212-5¦

O/p

1st column 3 char from col1 and 6 from col 4
2nd column 30 char
3rd column 8 char of col 4
4th column 1 char from col 5


670222222Demo sales amt                222222
905123456Sample Data                   123456
800121212order amt                     121212
120121212Item number descr             121212



Thanks\
JRS

Re: Parsing JCL to get right most value

PostPosted: Sat Mar 05, 2011 5:07 am
by Frank Yaeger
What issue? I don't know what you're looking for here. I don't know if you're showing me the output you got that you didn't want, or the expected output.

Please start over and explain your requirement clearly with a good example of input and expected output, and the rules for getting from input to output.

Re: Parsing JCL to get right most value

PostPosted: Tue Mar 08, 2011 9:09 pm
by rjambu
Hi Frank,

Can you Explain what the below code is(1,9,29,5) in the Build function in your code.
BUILD=(1,9,29,5))

The code that you posted worked fine for first 3 columns,
for example
for input

1999¦910¦111114-9¦111114-9¦¦OH¦

i get output as

9101111149

but not the remining columns like State code OH ..
If you can explain the Build code in the example i can chage the code accordingly.
Thanks



Below is the code that you posted:
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
1999¦910¦111114-9¦111114-9¦¦OH¦
1999¦910¦111115-9¦111115-9¦¦PA¦
1999¦S02¦000000000000600000¦000000000000600000¦¦NY¦
1999¦S02¦000000000000600000¦000000000000600000¦¦NJ¦
1999¦¦111116-9¦111116-9¦¦AZ¦
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  OPTION COPY
  INREC IFOUTLEN=80,
   IFTHEN=(WHEN=INIT,
    PARSE=(%=(ENDBEFR=X'6A'),
     %02=(ENDBEFR=X'6A',FIXLEN=3),
     %03=(ENDBEFR=X'6A',FIXLEN=6),
     %04=(ENDBEFR=X'6A',FIXLEN=20),
     %05=(ENDBEFR=X'6A',FIXLEN=2),
     %06=(ENDBEFR=X'6A',FIXLEN=2)),
    BUILD=(%02,%03,%04,JFY=(SHIFT=RIGHT),%05,%06)),
   IFTHEN=(WHEN=INIT,
     BUILD=(1,9,29,5))
/*


Re: Parsing JCL to get right most value

PostPosted: Tue Mar 08, 2011 11:24 pm
by Frank Yaeger
The input you showed in your first post is:

1999¦910¦111114-9¦111114-9¦¦OH¦
1999¦910¦111115-9¦111115-9¦¦PA¦
1999¦S02¦000000000000600000¦000000000000600000¦¦NY¦
1999¦S02¦000000000000600000¦000000000000600000¦¦NJ¦
1999¦¦111116-9¦111116-9¦¦AZ¦


My first IFTHEN clause is:

   IFTHEN=(WHEN=INIT,                                 
    PARSE=(%=(ENDBEFR=X'6A'),                         
     %02=(ENDBEFR=X'6A',FIXLEN=3),                   
     %03=(ENDBEFR=X'6A',FIXLEN=6),                   
     %04=(ENDBEFR=X'6A',FIXLEN=20),                   
     %05=(ENDBEFR=X'6A',FIXLEN=2),                   
     %06=(ENDBEFR=X'6A',FIXLEN=2)),                   
    BUILD=(%02,%03,%04,JFY=(SHIFT=RIGHT),%05,%06)),   


For the input you showed in your original post, the output from the first IFTHEN clause would be:

910111114            111114-9  OH
910111115            111115-9  PA
S02000000  000000000000600000  NY
S02000000  000000000000600000  NJ
   111116            111116-9  AZ


My second IFTHEN clause is:

   IFTHEN=(WHEN=INIT,   
     BUILD=(1,9,29,5)) 


This second IFTHEN clause is used to extract the fields you want for the final output:

9101111149  OH   
9101111159  PA   
S020000000  NY   
S020000000  NJ   
   1111169  AZ   


If you are not getting that final output, then your input does not look the way you said it does, or you changed something in my job.