Parsing JCL to get right most value



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Parsing JCL to get right most value

Postby rjambu » Fri Mar 04, 2011 9:25 pm

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
rjambu
 
Posts: 27
Joined: Tue Feb 08, 2011 7:59 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Parsing JCL to get right most value

Postby Frank Yaeger » Sat Mar 05, 2011 12:00 am

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))
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: Parsing JCL to get right most value

Postby rjambu » Sat Mar 05, 2011 2:47 am

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
rjambu
 
Posts: 27
Joined: Tue Feb 08, 2011 7:59 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Parsing JCL to get right most value

Postby Frank Yaeger » Sat Mar 05, 2011 5:07 am

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.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: Parsing JCL to get right most value

Postby rjambu » Tue Mar 08, 2011 9:09 pm

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))
/*

rjambu
 
Posts: 27
Joined: Tue Feb 08, 2011 7:59 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Parsing JCL to get right most value

Postby Frank Yaeger » Tue Mar 08, 2011 11:24 pm

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.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post