Create multiple records on the basis of counts in a field



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

Create multiple records on the basis of counts in a field

Postby Himanshu.Verma » Mon Sep 06, 2010 1:01 pm

Hi,

I have been looking a number of links to findout the solution for my specific requirement but did not find anyone.

I need to create multiple records of one input record based on the count in a perticular field in the input record.
if the count in the field is 2 then it should write 2 records and if the field has 5 then it sud write 5 records in the output file.
Does anybody have any solution using SORT. Any help will be highly apprreciated.


Regards,
Himanshu
Himanshu.Verma
 
Posts: 2
Joined: Mon Sep 06, 2010 12:47 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Create multiple records on the basis of counts in a field

Postby dick scherrer » Mon Sep 06, 2010 10:02 pm

Hello and welcome to the forum,

In addition to the "rules" you need to post some sample input data and the output you want when that sample iknput is processed.

Also, mention the dsorg and lrecl of the files.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Create multiple records on the basis of counts in a field

Postby Himanshu.Verma » Tue Sep 07, 2010 10:06 am

Hello Dick,

Thanks, below mention are the two sample records in the file with
Record format . . . : FB
Record length . . . : 78

 000001     Y         <4        -Ø 020001001   -c  -Ø      0000 -Ø<90448UNDE NOF
        002E0000110004F00000000681FFFFFFFFF000681068100340FFFF0684FFFFFEDCC4DDC4
        00C80000C0C01C400C0000800C0200010010C803C800C0050D0000800C90448454505660
 ------------------------------------------------------------------------------
 000002    *Y         <4        -Ø 020001001   -c  -Ø      0000 -Ø<90448UNDE NOF
        005E0000110004F00000000681FFFFFFFFF000681068100340FFFF0684FFFFFEDCC4DDC4
        00C80000C0C01C400C0000800C0200010010C803C800C0050D0000800C90448454505660
 ------------------------------------------------------------------------------


The first three character contains a count in PD. Now I have the requirement as per the count i need to write that many records.

i.e. for the first record,the count is 2 so it should write 2 records in the output similarly for the next record the count is 5 so the output file shall contain 5 records.
E.g.

 000001     Y         <4        -Ø 020001001   -c  -Ø      0000 -Ø<90448UNDE NOF
        002E0000110004F00000000681FFFFFFFFF000681068100340FFFF0684FFFFFEDCC4DDC4
        00C80000C0C01C400C0000800C0200010010C803C800C0050D0000800C90448454505660
 ------------------------------------------------------------------------------ 
000001     Y         <4        -Ø 020001001   -c  -Ø      0000 -Ø<90448UNDE NOF
        002E0000110004F00000000681FFFFFFFFF000681068100340FFFF0684FFFFFEDCC4DDC4
        00C80000C0C01C400C0000800C0200010010C803C800C0050D0000800C90448454505660
 ------------------------------------------------------------------------------
 000002    *Y         <4        -Ø 020001001   -c  -Ø      0000 -Ø<90448UNDE NOF
        005E0000110004F00000000681FFFFFFFFF000681068100340FFFF0684FFFFFEDCC4DDC4
        00C80000C0C01C400C0000800C0200010010C803C800C0050D0000800C90448454505660
 ------------------------------------------------------------------------------
 000002    *Y         <4        -Ø 020001001   -c  -Ø      0000 -Ø<90448UNDE NOF
        005E0000110004F00000000681FFFFFFFFF000681068100340FFFF0684FFFFFEDCC4DDC4
        00C80000C0C01C400C0000800C0200010010C803C800C0050D0000800C90448454505660
 ------------------------------------------------------------------------------
 000002    *Y         <4        -Ø 020001001   -c  -Ø      0000 -Ø<90448UNDE NOF
        005E0000110004F00000000681FFFFFFFFF000681068100340FFFF0684FFFFFEDCC4DDC4
        00C80000C0C01C400C0000800C0200010010C803C800C0050D0000800C90448454505660
 ------------------------------------------------------------------------------
 000002    *Y         <4        -Ø 020001001   -c  -Ø      0000 -Ø<90448UNDE NOF
        005E0000110004F00000000681FFFFFFFFF000681068100340FFFF0684FFFFFEDCC4DDC4
        00C80000C0C01C400C0000800C0200010010C803C800C0050D0000800C90448454505660
 ------------------------------------------------------------------------------ 
000002    *Y         <4        -Ø 020001001   -c  -Ø      0000 -Ø<90448UNDE NOF
        005E0000110004F00000000681FFFFFFFFF000681068100340FFFF0684FFFFFEDCC4DDC4
        00C80000C0C01C400C0000800C0200010010C803C800C0050D0000800C90448454505660
 ------------------------------------------------------------------------------



Regards,
Himanshu
Himanshu.Verma
 
Posts: 2
Joined: Mon Sep 06, 2010 12:47 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Create multiple records on the basis of counts in a field

Postby Frank Yaeger » Tue Sep 07, 2010 11:08 pm

DFSORT does not have any built-in functions to repeat records based on a count in each record. I would suggest you write your own program, or E35 exit, to do this.
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: Create multiple records on the basis of counts in a field

Postby kilaru » Tue Oct 12, 2010 1:34 am

I am not denying what Frank Said, but, incase if you are not comfortable writng Exit Routines and the multiple occurrences are not greater than 9 for any key, then you can think of writing 10 OUTFIL Statements as below.
//SYMNAMES DD *
KEY-COUNT,1,3,PD
//*
OUTFIL R1, INCLUDE=(KEY-COUNT,EQ,+1)
OUTFIL R2, INCLUDE=(KEY-COUNT,EQ,+2)
,,
,,
OUTFIL R9, INCLUDE=(KEY-COUNT,EQ,+9)
* capture all others into a file.
OUTFIL SAVE,FNAMES=OTHERS

Thanks
Krishna Kilaru
kilaru
 
Posts: 3
Joined: Tue Oct 12, 2010 1:21 am
Has thanked: 0 time
Been thanked: 0 time

Re: Create multiple records on the basis of counts in a field

Postby kilaru » Tue Oct 12, 2010 1:52 am

Sorry, I missed to include REPEAT Parm earlier. Here are the OUTFIL statements with REPEAT par,

//SYMNAMES DD *
KEY-COUNT,1,3,PD
//*
//SORTCNTL DD *
OUTFIL R1, INCLUDE=(KEY-COUNT,EQ,+1),REPEAT=1
OUTFIL R2, INCLUDE=(KEY-COUNT,EQ,+2),REPAET=2
,,
,,
OUTFIL R9, INCLUDE=(KEY-COUNT,EQ,+9),REPEAT=9
* capture all others into a file.
OUTFIL SAVE,FNAMES=OTHERS
//*

Thanks
Krishna Kilaru
kilaru
 
Posts: 3
Joined: Tue Oct 12, 2010 1:21 am
Has thanked: 0 time
Been thanked: 0 time

Re: Create multiple records on the basis of counts in a field

Postby Frank Yaeger » Tue Oct 12, 2010 2:03 am

Kilaru,

If you had actually tried your suggested control statements, you would have found they have syntax errors.

Please don't post untested solutions here.
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: Create multiple records on the basis of counts in a field

Postby kilaru » Tue Oct 12, 2010 3:16 am

Sorry Frank. I was just curious to present my thought and didn't pay much attention on Syntax or Testing. Here after I will make sure to test before posting.
Here are the control cards from my Test run that used ICETOOL. I found from this test that REPEAT=n is valid when 'n' is any except 1.
000037 //SYMNAMES DD *
000038   KEY-COUNT,1,3,PD
000039 //*
000040 //OPTIONS  DD SYSOUT=*
000041 //SYSOUT   DD SYSOUT=*
000042 //SYSUDUMP DD SYSOUT=*
000043 //TOOLIN DD *
000044  SORT FROM(FILEIN) USING(CTL1)
000045 /*
000046 //CTL1CNTL    DD *
000047   SORT FIELDS=(COPY)
000048   OUTFIL FNAMES=R1,
000049           INCLUDE=(KEY-COUNT,EQ,+1)
000050   OUTFIL FNAMES=R2,REPEAT=2,
000051        INCLUDE=(KEY-COUNT,EQ,+2)
000052   OUTFIL FNAMES=R3,REPEAT=3,
000053    INCLUDE=(KEY-COUNT,EQ,+3)
000054   OUTFIL SAVE,FNAMES=OTHERS
000055 /*

Here is what I got in my DFSMSG.

    ICE055I 0 INSERT 0, DELETE 0
    ICE054I 0 RECORDS - IN: 3, OUT: 3
    ICE227I 0 R1 : DELETED = 2, REPORT = 0, DATA = 1
    ICE228I 0 R1 : TOTAL IN = 3, TOTAL OUT = 1
    ICE227I 0 R2 : DELETED = 2, REPORT = 0, DATA = 2
    ICE228I 0 R2 : TOTAL IN = 3, TOTAL OUT = 2
    ICE227I 0 R3 : DELETED = 2, REPORT = 0, DATA = 3
    ICE228I 0 R3 : TOTAL IN = 3, TOTAL OUT = 3
    ICE227I 0 OTHERS : DELETED = 3, REPORT = 0, DATA = 0
    ICE228I 0 OTHERS : TOTAL IN = 3, TOTAL OUT = 0
    ICE174I 0 NO DATA RECORDS FOR AN OUTFIL DATA SET - RC=0
    ICE052I 0 END OF DFSORT
kilaru
 
Posts: 3
Joined: Tue Oct 12, 2010 1:21 am
Has thanked: 0 time
Been thanked: 0 time

Re: Create multiple records on the basis of counts in a field

Postby steve-myers » Tue Oct 12, 2010 5:28 am

kilaru - I think most of us that respond fairly often have been guilty of making this kind of goof. Me, I learned my lesson long ago. These days I try everything before I post!
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post