SPLIT file using SORT based on totals



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

SPLIT file using SORT based on totals

Postby kkamarnath » Wed Apr 17, 2013 6:20 pm

Hi,

My requirement is to split a file into three files based on the totals. Please find the example below

INPUT FILE:

RECORD 1
RECORD 1
RECORD 1
.
.
RECORD 1
TOTAL-1 XXX
RECORD 2
RECORD 2
.
.
RECORD 2
TOTAL-2 XXX
RECORD 3
RECORD 3
.
.
RECORD 3
TOTAL-3 XXX
RECORD 4
RECORD 4
.
.
RECORD 4
TOTAL-4 XXX

OUTPUT FILEs:

FILE1:
RECORD 1
RECORD 1
RECORD 1
.
.
RECORD 1
TOTAL-1 XXX

FILE2:
RECORD 2
RECORD 2
RECORD 2
.
.
RECORD 2
TOTAL-2 XXX
RECORD 3
RECORD 3
.
.
RECORD 3
TOTAL-3 XXX

FILE3:
RECORD 4
RECORD 4
.
.
RECORD 4
TOTAL-4 XXX

Input and output files should have same record length of 133 and same format as FB. I am familier with splitting the files using number of records, But the record count is not constant in this case.

Please help me in solving the above problem.

Thanks in Advance,

Amar
kkamarnath
 
Posts: 10
Joined: Wed Apr 17, 2013 6:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: SPLIT file using SORT based on totals

 

Re: SPLIT file using SORT based on totals

Postby BillyBoyo » Wed Apr 17, 2013 6:41 pm

Why is RECORD 3 in file 2?

Is there nothing to distinguish the records apart from the TOTAL record?

Can you post the sysout from this step, to determine your DFSORT level?

//S1 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN DD *
JUST SOME ARBITRARY TEXT
/*
//SORTOUT DD DUMMY
//SYSIN   DD   *
  OPTION COPY
/*
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: SPLIT file using SORT based on totals

Postby kkamarnath » Wed Apr 17, 2013 7:02 pm

Hi BillyBoyo,

Only totals are available to distinguish. and I need RECORD2 and RECORD3 in file2 only. That is the requirement for me.

From the code, I understood that you are trying to copy the "RECORD" from input to output. Since SORTOUT is dummy we cannot verify the output anywhere.

Let me know if you still need anything from me.

Thanks,
Amar
kkamarnath
 
Posts: 10
Joined: Wed Apr 17, 2013 6:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: SPLIT file using SORT based on totals

Postby enrico-sorichetti » Wed Apr 17, 2013 7:14 pm

Let me know if you still need anything from me.


that You run the job as is and post the result.

what we want to know is the <level> of You sort product so that
we will able to suggest a solution compatible with Your <sort> features

and running that snippet is the simplest way to find out
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2644
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: SPLIT file using SORT based on totals

Postby BillyBoyo » Wed Apr 17, 2013 7:29 pm

I see the confusion. The code I copied had the text RECORD, which unfortunately clashes with your data.

Just run it, as enrico has suggested, and post the full sysout here.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: SPLIT file using SORT based on totals

Postby kkamarnath » Wed Apr 17, 2013 7:49 pm

1ICE201I H RECORD TYPE IS F - DATA STARTS IN POSITION 1                 
 ICE751I 0 C5-K76982 C6-K90026 C7-K82419 C8-K67572 E9-K60824 C9-BASE   E
 ICE143I 0 BLOCKSET     COPY  TECHNIQUE SELECTED                       
 ICE250I 0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EX
 ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R12 - 09:23
0            OPTION COPY                                               
 ICE201I H RECORD TYPE IS F - DATA STARTS IN POSITION 1                 
 ICE751I 0 C5-K76982 C6-K90026 C7-K82419 C8-K67572 E9-K60824 C9-BASE   E
 ICE193I 0 ICEAM1 INVOCATION ENVIRONMENT IN EFFECT - ICEAM1 ENVIRONMENT
 ICE252I 1 PARMLIB OPTIONS WERE MERGED WITH INSTALLATION MODULE DEFAULTS
 ICE088I 0 TESTSORT.S1      .        , INPUT LRECL = 80, BLKSIZE = 80, T
 ICE093I 0 MAIN STORAGE = (MAX,6291456,6278238)                         
 ICE156I 0 MAIN STORAGE ABOVE 16MB = (6200798,6200798)                 
 ICE127I 0 OPTIONS: OVFLO=RC0 ,PAD=RC0 ,TRUNC=RC0 ,SPANINC=RC16,VLSCMP=N
 ICE128I 0 OPTIONS: SIZE=6291456,MAXLIM=1048576,MINLIM=450560,EQUALS=N,L
 ICE129I 0 OPTIONS: VIO=N,RESDNT=ALL ,SMF=FULL ,WRKSEC=Y,OUTSEC=Y,VERIFY
 ICE130I 0 OPTIONS: RESALL=4096,RESINV=0,SVC=109 ,CHECK=Y,WRKREL=Y,OUTRE
 ICE131I 0 OPTIONS: TMAXLIM=6291456,ARESALL=0,ARESINV=0,OVERRGN=65536,CI
 ICE132I 0 OPTIONS: VLSHRT=N,ZDPRINT=Y,IEXIT=N,TEXIT=N,LISTX=N,EFS=NONE
 ICE133I 0 OPTIONS: HIPRMAX=OPTIMAL,DSPSIZE=MAX ,ODMAXBF=0,SOLRF=Y,VLLON
 ICE235I 0 OPTIONS: NULLOUT=RC0                                         
 ICE236I 0 OPTIONS: DYNAPCT=10 ,MOWRK=Y                                 
 ICE084I 0 BSAM ACCESS METHOD USED FOR SORTOUT                         
 ICE084I 0 BSAM ACCESS METHOD USED FOR SORTIN                           
 ICE751I 1 EF-BASE   F0-K66717 E8-K79990                               
 ICE090I 0 OUTPUT LRECL = 80, BLKSIZE = 80, TYPE = FB                   
 ICE055I 0 INSERT 0, DELETE 0                                           
 ICE054I 0 RECORDS - IN: 1, OUT: 1                                     
 ICE052I 0 END OF DFSORT


Code'd
kkamarnath
 
Posts: 10
Joined: Wed Apr 17, 2013 6:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: SPLIT file using SORT based on totals

Postby kkamarnath » Wed Apr 17, 2013 7:51 pm

Hi,
Hope above details will help you... Looking forward for your cooperation.

Thanks,
Amar
kkamarnath
 
Posts: 10
Joined: Wed Apr 17, 2013 6:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: SPLIT file using SORT based on totals

Postby BillyBoyo » Wed Apr 17, 2013 8:36 pm

Thanks, the ICE201I has H, which is good.

You'll need three OUTFILs, each with INCLUDE.

You'll need an "extra" byte on your record, to tell where to include. What is your RECFM and LRECL?

You can use IFTHEN=(WHEN=INIT to set the extra byte to 0, which the first INCLUDE will use.

Have a WHEN=GROUP which identifies the TOTAL record and PUSHes the indicator (1,2, whatever) into a second new field.

WHEN=GROUP on the second field for the indicator which has been PUSHed and not TOTAL, to PUSH the value to the selection marker.

Then the other OUTFILs will INCLUDE on 1 and 2, for the second, and 3 for the third.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: SPLIT file using SORT based on totals

Postby enrico-sorichetti » Wed Apr 17, 2013 10:20 pm

given the foggy description of the requirement this the most You might get...
modify the the 80/81 according to Your LRECL

//ENRICO1  JOB NOTIFY=&SYSUID,
//             MSGLEVEL=(1,1),CLASS=A,MSGCLASS=H
//*
//S1      EXEC PGM=SORT
//SYSPRINT  DD SYSOUT=*
//SYSOUT    DD SYSOUT=*
//SORTIN    DD *
RECORD 1 1
RECORD 1 2
RECORD 1 3
RECORD 1 4
RECORD 1 5
TOTAL-1
RECORD 2 1
RECORD 2 2
RECORD 2 3
RECORD 2 4
RECORD 2 5
TOTAL-2
RECORD 3 1
RECORD 3 2
RECORD 3 3
RECORD 3 4
RECORD 3 5
TOTAL-3
RECORD 4 1
RECORD 4 2
RECORD 4 3
RECORD 4 4
RECORD 4 5
TOTAL-4
RECORD 5 1
RECORD 5 2
RECORD 5 3
RECORD 5 4
RECORD 5 5
TOTAL-5
//OUT1      DD SYSOUT=*,
//             DCB=(RECFM=FB,LRECL=80)
//OUT2      DD SYSOUT=*,
//             DCB=(RECFM=FB,LRECL=80)
//OUT3      DD SYSOUT=*,
//             DCB=(RECFM=FB,LRECL=80)
//OTHR      DD SYSOUT=*,
//             DCB=(RECFM=FB,LRECL=80)
//SYSIN     DD *
  SORT   FIELDS=COPY
  INREC  IFTHEN=(WHEN=GROUP,END=(1,5,CH,EQ,C'TOTAL'),
                 PUSH=(81:ID=4))
  OUTFIL FNAMES=OUT1,
         INCLUDE=(81,4,ZD,EQ,1),BUILD=(1,80)
  OUTFIL FNAMES=OUT2,
         INCLUDE=(81,4,ZD,EQ,2),BUILD=(1,80)
  OUTFIL FNAMES=OUT3,
         INCLUDE=(81,4,ZD,EQ,3),BUILD=(1,80)
  OUTFIL FNAMES=OTHR,
         INCLUDE=(81,4,ZD,GT,3),BUILD=(1,80)
//*
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2644
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: SPLIT file using SORT based on totals

Postby kkamarnath » Thu Apr 18, 2013 11:57 am

Thank you soo much for the replies.

Enrico

Your code is lot helpful to understand Billy's suggestion.

I believe that, I didn't provide the requirement clearly. Please find the details below.

Input file:
REC-1
REC-1
..
TOTAL-1
REC-2
REC-2
..
TOTAL-2
REC-2
REC-2
..
TOTAL-2
...
REC-3
REC-3
..
TOTAL-3

Here REC-2 and Total-2 occurrences may vary every time the input file is generated. But REC-1 & TOtal-1 AND REC-3 & TOTAL-3 will always occurs 1 time.

Output file:

file1:
REC-1
REC-1
..
TOTAL-1

file2:
REC-2
REC-2
..
TOTAL-2
REC-2
REC-2
..
TOTAL-2
..

file3:

REC-3
REC-3
..
TOTAL-3

Your code will help me if the REC-2 & TOTAL-2 occurrences are constant. But in my requirement they always vary evey time input file is generated.

Please suggest how can I achieve the above requirement.

Let me know if my requirement is still confusing.

Thanks in Advance.

Amar
kkamarnath
 
Posts: 10
Joined: Wed Apr 17, 2013 6:08 pm
Has thanked: 0 time
Been thanked: 0 time

Next

Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post