IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Spliting an input record


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ojdiaz

New User


Joined: 19 Nov 2008
Posts: 98
Location: Spain

PostPosted: Fri Sep 18, 2009 4:52 pm
Reply with quote

Maybe this seems simple, but I've had spend quite some time trying to figure how to do this with a SORT/ICTOOL and i can't seem to figure how how.

I have an input file of 20 bytes FB LRECL like this example:

Code:

key aaa ky2 ddddddd
001 xxx 000 xxxxxxx
001 xxx 001 xxxxxxx
001 xxx 002 xxxxxxx
001 xxx 003 xxxxxxx
001 xxx 004 xxxxxxx
002 xxx 000 xxxxxxx
002 xxx 001 xxxxxxx
002 xxx 002 xxxxxxx
003 xxx 001 xxxxxxx
003 xxx 002 xxxxxxx
003 xxx 004 xxxxxxx
004 xxx 099 xxxxxxx
005 xxx 010 xxxxxxx
005 xxx 015 xxxxxxx


I have a key field in bytes 1 trhough 3, and a secod key in in bytes 9 trhough 12

I need to split the file and put the first record from each key1 group into a file, and the rest of the records in the other. The outputs should look like this:

Output File 1
Code:

001 xxx 000 xxxxxxx
002 xxx 000 xxxxxxx
003 xxx 001 xxxxxxx
004 xxx 099 xxxxxxx
005 xxx 010 xxxxxxx

Output File 2
Code:

001 xxx 001 xxxxxxx
001 xxx 002 xxxxxxx
001 xxx 003 xxxxxxx
001 xxx 004 xxxxxxx
002 xxx 001 xxxxxxx
002 xxx 002 xxxxxxx
003 xxx 002 xxxxxxx
003 xxx 004 xxxxxxx
005 xxx 015 xxxxxxx


I though on using the COPY FIRST from ICETOOL and that works nice for the first record of each group,

Code:
SELECT FROM(S1DQPREV) TO(S2DQTOP1) ON(1,3,CH) FIRST(1) USING(CTL2)

//CTL2CNTL DD *                       
  SORT FIELDS=(1,3,A),FORMAT=CH


Then using FIRSTDUP for the rest of the records:

Code:
SELECT FROM(SQDQPREV) TO(S3DQREST) ON(1,3,CH) FIRSTDUP(999) USING(CTL2)


However, when i Tried that, The number don't add up:

Code:

*COPIA EL PRIMER REGISTRO PARA CADA COMBINACION OFICINA - ENTORNO           
  SELECT FROM(E1DQPREV) TO(S1DQTOP1) ON(1,3,CH) FIRST(1) USING(CTL2)                                                     
DFSORT CALL 0001 FOR SORT FROM E1DQPREV TO S1DQTOP1 USING CTL1CNTL COMPLETED
RECORD COUNT:  000000000000301                                             
NUMBER OF RECORDS RESULTING FROM CRITERIA:  000000000000296                 
OPERATION RETURN CODE:  00                                                 
                                                                           
*COPIA EL RESTRO DE LOS REGISTROS                                           
  SELECT FROM(E1DQPREV) TO(S2DQREST) ON(1,3,CH) FIRSTDUP(999) USING(CTL1)                                                 

DFSORT CALL 0002 FOR SORT FROM E1DQPREV TO S2DQREST USING CTL1CNTL COMPLETED
RECORD COUNT:  000000000000301                                             
NUMBER OF RECORDS RESULTING FROM CRITERIA:  000000000000010                 
OPERATION RETURN CODE:  00


Any advice in implementing this? I though on using HEADERS/TRAILERS from the OUTFIL operator, but i'm still elarning how to use it and I might be missing something.

Thanks a lot in advance

Best regards

Oliver
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Sep 18, 2009 9:43 pm
Reply with quote

You were on the right track. Here's a DFSORT/ICETOOL job that will do what you asked for:

Code:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//S1DQPREV DD DSN=...  input file
//S2DQTOP1 DD DSN=...  output file1
//S3DQREST DD DSN=...  output file2
//TOOLIN DD *
SELECT FROM(S1DQPREV) TO(S2DQTOP1) ON(1,3,CH) FIRST -
  DISCARD(S3DQREST)
/*
Back to top
View user's profile Send private message
ojdiaz

New User


Joined: 19 Nov 2008
Posts: 98
Location: Spain

PostPosted: Mon Sep 21, 2009 2:45 pm
Reply with quote

Thanks a Lot Frank. That Worked just fine

Best Regards

Oliver
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
Search our Forums:

Back to Top