How Parse file with more than 100 column



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

How Parse file with more than 100 column

Postby rjambu » Wed Mar 30, 2011 9:51 pm

Hi I need to parse a CSV file that has 188 columns.

JCL Syntax i used is below giving PARSED FIELD DEFINITION ERROR. ( since the column number crossed 100.)

How to process that file that has More than 100 columns,( in this case it is 188 columns.)

Can anyone help me in this regard.

Thanks
JRS



//SORTOUT  DD  DSN=A.B.C,               
//             UNIT=DISK,SPACE=(TRK,(1,2),RLSE),       
//             DCB=(LRECL=2310,BLKSIZE=0,RECFM=FB),     
//             DISP=(NEW,CATLG,DELETE)                 
//SYSSORT  DD SYSOUT=*                                 
//SYSUDUMP DD SYSOUT=*                                 
//*                                                     
//SYSIN    DD  *                           
 SORT FIELDS=COPY                         
 INREC PARSE=(%00=(ENDBEFR=C'|',FIXLEN=30),
              %01=(ENDBEFR=C'|',FIXLEN=10),
              %02=(ENDBEFR=C'|',FIXLEN=12),
              %03=(ENDBEFR=C'|',FIXLEN=12),
              .
              .
              .
              %99=(ENDBEFR=C'|',FIXLEN=10),                             
              %100=(ENDBEFR=C'|',FIXLEN=04),                           
              %101=(ENDBEFR=C'|',FIXLEN=02),                           
              .
              .
              .
              %185=(ENDBEFR=C'|',FIXLEN=02),                           
              %186=(ENDBEFR=C'|',FIXLEN=08),                           
              %187=(ENDBEFR=C'|',FIXLEN=08)),                           
 BUILD=(%00,%01,%02,%03,...                                            X
           %99,%100,%101,..                                            X
            %185,%186,%187)
/*
//
rjambu
 
Posts: 27
Joined: Tue Feb 08, 2011 7:59 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How Parse file with more than 100 column

 

Re: How Parse file with more than 100 column

Postby Frank Yaeger » Wed Mar 30, 2011 10:13 pm

You can only use %00-%99 in one pass for PARSE. So the solution would be to use two passes, either by having two DFSORT steps or one ICETOOL step with two COPY operators.
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: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times

Re: How Parse file with more than 100 column

Postby rjambu » Wed Mar 30, 2011 11:45 pm

Hi Frank, Can you provide me skeleton code for this process.
Thanks
rjambu
 
Posts: 27
Joined: Tue Feb 08, 2011 7:59 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How Parse file with more than 100 column

Postby Frank Yaeger » Thu Mar 31, 2011 2:18 am

I'll demonstrate the technique with a few fields. Say we had this as input:

ABC|DEFGHI|JKL|MNOPQ|RSTU|VW|XYZAB|CDE|     
AB|CDEFGH|IJKLMN|OPQRSTUV|W|XYZ|AB|CDEFG|   


To handle this in two parts, we would PARSE the first group with %nn variables individually and the remaining bytes with one %nn variable.
Then we would PARSE the next group starting with the remaining bytes. For example:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD *
ABC|DEFGHI|JKL|MNOPQ|RSTU|VW|XYZAB|CDE|
AB|CDEFGH|IJKLMN|OPQRSTUV|W|XYZ|AB|CDEFG|
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN) TO(T1) USING(CTL1)
COPY FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
  INREC PARSE=(%00=(ENDBEFR=C'|',FIXLEN=5),
              %01=(ENDBEFR=C'|',FIXLEN=10),
              %02=(ENDBEFR=C'|',FIXLEN=12),
              %03=(ENDBEFR=C'|',FIXLEN=12),
              %99=(FIXLEN=188)),
   BUILD=(%00,%01,%02,%03,%99)
/*
//CTL2CNTL DD *
  INREC PARSE=(%00=(ABSPOS=40,ENDBEFR=C'|',FIXLEN=9),
              %01=(ENDBEFR=C'|',FIXLEN=15),
              %02=(ENDBEFR=C'|',FIXLEN=9),
              %03=(ENDBEFR=C'|',FIXLEN=10)),
   BUILD=(1,39,%00,%01,%02,%03)
/*


Notice that I've used %01-%03 twice.

The first COPY operator would write the following in T1:

ABC  DEFGHI    JKL         MNOPQ       RSTU|VW|XYZAB|CDE|
AB   CDEFGH    IJKLMN      OPQRSTUV    W|XYZ|AB|CDEFG|


Now we can PARSE the remaining fields with the second COPY operator. Just use ABSPOS=n to start at the correct place in the T1 records.

So after the second COPY operator, OUT would have the following:

ABC  DEFGHI    JKL         MNOPQ       RSTU     VW             XYZAB    CDE     
AB   CDEFGH    IJKLMN      OPQRSTUV    W        XYZ            AB       CDEFG   


Hopefully, you can extrapolate this to the number of fields you need. Just use one COPY step with %00-%98 for the first 99 fields and %99 for the remaining fields. Then use another COPY operator with %00-%nn to handle the remaining bytes starting at the appropriate position (= the total length of the %00-%98 fields).
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: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post