Data Manipulation from multiple files and COUNT in DFSORT



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

Data Manipulation from multiple files and COUNT in DFSORT

Postby jimscholes » Tue Sep 15, 2009 12:35 am

Hi,

I have a data file and want to split into 4 different files, each with a trailer record that states the number of records in the file together with specific details extracted from parameter files.

Trailer information is getting from two parameter files, each parameter file has only one record.

Parameter File 1: .....0900..... (890 bytes. fixed length record) --- want to extract from offset 6-10 (4 bytes)
Parameter File 2: 20090731.... (100 bytes, fixed length record) --- want to extract from offset 1-8 (8 bytes)

Final trailor record looks like: .....0900......20090731....."counter value"...... --- where "counter value" contains number of data records after split and "......." are constant literals

Original Data file

Rec 1: .........4614......... (let's say offset is 5-9)
Rec 2: .........4611.........
Rec 3: .........4614.........
Rec 4: .........4612.........
Rec 5: .........4611.........

Final output file 1:
........4611.......... (copy from original data file)
........4611..........
.....0900......20090731......0000002...... ("0900" offset is 7-10, "20090731" offset is 21-28, "0000002" offset is 35-41)

Final output file 2:
........4612..........
.....0900......20090731......0000001......

Final output file 3: (no data record, just trailer, with counter value = 0)
.....0900......20090731......0000000......

Final output file 4:
........4614..........
........4614..........
.....0900......20090731......0000002......

Any idea how this can be done in DFSORT?

Thanks.
jimscholes
 
Posts: 6
Joined: Tue Sep 15, 2009 12:06 am
Has thanked: 0 time
Been thanked: 0 time

Re: Data Manipulation from multiple files and COUNT in DFSORT

Postby Frank Yaeger » Tue Sep 15, 2009 1:21 am

You can use a DFSORT/ICETOOL job like the following to do what you asked for. I showed an example of your ... contstant in TRAILER1 - fill in the real constants.

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN1 DD DSN=...  parm file1 (FB/890)
//IN2 DD DSN=...  parm file2 (FB/100)
//SYM1 DD DSN=&&S1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//TOOLIN DD *
COPY FROM(IN1) TO(SYM1) USING(CTL1)
COPY FROM(IN2) TO(SYM1) USING(CTL2)
//CTL1CNTL DD *
  INREC BUILD=(C'F1PRM,''',6,4,C'''',80:X)
/*
//CTL2CNTL DD *
  INREC BUILD=(C'F2PRM,''',1,8,C'''',80:X)
/*
//S2    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=...  input file
//OUT1 DD DSN=...  output file1
//OUT2 DD DSN=...  output file2
//OUT3 DD DSN=...  output file3
//OUT4 DD DSN=...  output file4
//SYSIN    DD    *
  OPTION COPY
  OUTFIL FNAMES=OUT1,REMOVECC,INCLUDE=(5,4,CH,EQ,C'4611'),
    TRAILER1=(1:'CON1',7:F1PRM,11:'CON2',F2PRM,
      35:COUNT=(M11,LENGTH=7))
  OUTFIL FNAMES=OUT2,REMOVECC,INCLUDE=(5,4,CH,EQ,C'4612'),
    TRAILER1=(1:'CON1',7:F1PRM,11:'CON2',F2PRM,
      35:COUNT=(M11,LENGTH=7))
  OUTFIL FNAMES=OUT3,REMOVECC,INCLUDE=(5,4,CH,EQ,C'4613'),
    TRAILER1=(1:'CON1',7:F1PRM,11:'CON2',F2PRM,
      35:COUNT=(M11,LENGTH=7))
  OUTFIL FNAMES=OUT4,REMOVECC,INCLUDE=(5,4,CH,EQ,C'4614'),
    TRAILER1=(1:'CON1',7:F1PRM,11:'CON2',F2PRM,
      35:COUNT=(M11,LENGTH=7))
/*
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: Data Manipulation from multiple files and COUNT in DFSORT

Postby jimscholes » Wed Sep 16, 2009 2:20 am

Thanks Frank, the code works pretty well and I get what I want.

Some more questions.

Can I format the symbol field in the trailer record? i.e. F2PRM in the example. The data in the original file is 20090731 and I want to format it to 2009-07-31 in the trailer.

Is it possible to extract multiple data from IN2 in one shot in step S1? Let's say I want to extact offset 15-19 as well from IN2 and put it to F3PRM. What does the 80:X mean? I tried to remove it but the JCL failed.

I also want to put the current time in the symbol table in F4PRM, i.e. TIME=(24.) There is no input file for this one so how do I put it in the symbol table?

Thanks.
jimscholes
 
Posts: 6
Joined: Tue Sep 15, 2009 12:06 am
Has thanked: 0 time
Been thanked: 0 time

Re: Data Manipulation from multiple files and COUNT in DFSORT

Postby Frank Yaeger » Wed Sep 16, 2009 3:54 am

Yes, you can do all of that by replacing the INREC statement in CTL2CNTL with the following OUTFIL statement:

  OUTFIL FNAMES=SYM1,                                           
    BUILD=(C'F2PRM,''',1,8,ZD,EDIT=(TTTT-TT-TT),C'''',80:X,/,   
     C'F3PRM,''',15,5,C'''',/,                                   
     C'F4PRM,''',TIME=(24.),C'''')                               


The 80:X ensures that the SYMNAMES data set has an LRECL of 80 which is required.
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: Data Manipulation from multiple files and COUNT in DFSORT

Postby jimscholes » Fri Sep 18, 2009 11:51 am

Thanks again. My JCL now looks better.
jimscholes
 
Posts: 6
Joined: Tue Sep 15, 2009 12:06 am
Has thanked: 0 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post