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

Keep only first record and remove all dups based on key.


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

New User


Joined: 11 Nov 2008
Posts: 27
Location: Canada

PostPosted: Wed Jan 12, 2011 4:41 am
Reply with quote

Hello Everbody,

My input file

MAEAED05598023190P8900024 SHOP BONUS MILES DMU000016GAEDCAD2000231557
MAEAED05598023190P8900024 SHOP BONUS MILES HHA000016GAEDCAD2000231558
MAEAED05598023190P8900024 SHOP BONUS MILES IOL000016GAEDCAD2000231559
MAEAED09418241200P8900024 SHOP BONUS MILES DMU000016GAEDCAD2000231560
MAEAED09418241200P8900024 SHOP BONUS MILES HHA000016GAEDCAD2000231561
MAEAED09418241200P8900024 SHOP BONUS MILES IOL000016GAEDCAD2000231562


Structure
X(1,43) - Key to identify the group
X(44,3) - partner code
X(47,7) - PIC S9(7)- amount
X(54,19) - other fileds

Expected output file

MAEAED05598023190P8900024 SHOP BONUS MILES DMU000100BAEDCAD2000231557
MAEAED09418241200P8900024 SHOP BONUS MILES DMU000100BAEDCAD2000231560


Explaination:
If you see the input file carefully, there are two groups based on the first 43 digits. and I need only the first record per group in the o/p file.
But i need the amount field(X(54,19) to contain sum of all group records and rest of the fields remains unchanged.

Like in above case each record of first group(of 3) in input file has 167(or 000016G in S9(7) format) as amount(X(47,7)) and in o/p file it should have 1002(167+167+167) and same for second group of records.
There could be 1 or more records in one group.

This would be a very complex logic for me as I am bit new to DFsort. I would really appreciate your help in above matter.

Note: Few commands like IF and WHEN are not supported by our maiframe system but rest all commands are supported.[img][/img][img][/img][img][/img]
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: Wed Jan 12, 2011 5:02 am
Reply with quote

Last I looked, 167+167+167 equals 501, not 1002. I assume this was just a mistake on your part. If not, please explain.

You can use these DFSORT statements to do what you asked for:

Code:

  OPTION NZDPRINT
  SORT FIELDS=(1,43,CH,A) 
  SUM FIELDS=(47,7,ZD)     


If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000080
Back to top
View user's profile Send private message
skgupta81

New User


Joined: 11 Nov 2008
Posts: 27
Location: Canada

PostPosted: Wed Jan 12, 2011 6:20 am
Reply with quote

Hi,

Yes, it was by mistake. It should be 501 in o/p file.

I will try the code given by you tomorrow.

Thanks for quick reply.
Sanjay

Frank Yaeger wrote:
Last I looked, 167+167+167 equals 501, not 1002. I assume this was just a mistake on your part. If not, please explain.

You can use these DFSORT statements to do what you asked for:


If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000080
Back to top
View user's profile Send private message
skgupta81

New User


Joined: 11 Nov 2008
Posts: 27
Location: Canada

PostPosted: Wed Jan 19, 2011 1:01 am
Reply with quote

Hello,

I am trying to go through DFSORT PDF but still facing challenges in getting required output.

I tried using the statements you specified but it seems giving the same o/p file as i/p after running the job.

could you please provide me another solution as quick fix for now and meanwhile I will continue going through the PDFs for future assignments.


Thanks,
Sanjay

skgupta81 wrote:
Hi,

Yes, it was by mistake. It should be 501 in o/p file.

I will try the code given by you tomorrow.

Thanks for quick reply.
Sanjay

Frank Yaeger wrote:
Last I looked, 167+167+167 equals 501, not 1002. I assume this was just a mistake on your part. If not, please explain.

You can use these DFSORT statements to do what you asked for:


If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000080
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jan 19, 2011 1:13 am
Reply with quote

Hello,

Post the exact jcl and sort control statements submitted (use copy/paste and the Code tag - do not re-key. If you need to "hide" the real dataset names, fine.

Post all of the informational messages generated by the run including the message ids.
Back to top
View user's profile Send private message
skgupta81

New User


Joined: 11 Nov 2008
Posts: 27
Location: Canada

PostPosted: Wed Jan 19, 2011 1:22 am
Reply with quote

Code:

//STEP10R  EXEC PGM=SORT                                       
//SORTIN   DD DISP=SHR,DSN=ID.INPUT
//SORTOUT  DD DSN=ID.OUTPUT,DISP=OLD         
//SORTWK01 DD DSN=&&SORTWK01,UNIT=PUBLIC,SPACE=(TRK,(200,100))
//SORTWK02 DD DSN=&&SORTWK02,UNIT=PUBLIC,SPACE=(TRK,(200,100))
//SORTWK03 DD DSN=&&SORTWK03,UNIT=PUBLIC,SPACE=(TRK,(200,100))
//SYSPRINT DD SYSOUT=*                                         
//SYSUDUMP DD SYSOUT=*                                         
//SYSOUT   DD SYSOUT=*                                         
//SYSDUMP  DD DUMMY                                           
//SYSIN    DD *                                               
  OPTION NZDPRINT
  SORT FIELDS=(1,43,CH,A) 
  SUM FIELDS=(47,7,ZD)     
  END                                                           
/*                                                             
//*                                                           




ICE054I 0 RECORDS - IN: 6, OUT: 6
ICE134I 0 NUMBER OF BYTES SORTED: 660
ICE165I 0 TOTAL WORK DATA SET TRACKS ALLOCATED: 600 , TRACKS USED: 0
ICE199I 0 MEMORY OBJECT STORAGE USED = 0M BYTES
ICE180I 0 HIPERSPACE STORAGE USED = 0K BYTES
ICE188I 0 DATA SPACE STORAGE USED = 0K BYTES
ICE026I 1 SMF RECORD NOT WRITTEN TO THE SMF DATA SET(RC=20)
ICE052I 0 END OF DFSORT

The o/p file is same as i/p file after running above code.

Thanks,
Sanjay

dick scherrer wrote:
Hello,

Post the exact jcl and sort control statements submitted (use copy/paste and the Code tag - do not re-key. If you need to "hide" the real dataset names, fine.

Post all of the informational messages generated by the run including the message ids.
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: Wed Jan 19, 2011 2:05 am
Reply with quote

You would only get the same output as input in two cases I can think of:

1) You DO NOT have any duplicates in positions 1-43. It's difficult to tell exactly what your data looks like from your example. Do you actually have records with the same values in 1-43? What are those values for the 6 records you show?

2) All of your summed fields overflowed (which does not appear to be the case for the input data you showed but it's difficult to tell).

I would need to see your ACTUAL input records to tell you what's happening. Perhaps you could send it to me offline (yaeger@us.ibm.com) as a .txt file?

Also, what is the RECFM and LRECL of your input file?
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: Wed Jan 19, 2011 2:59 am
Reply with quote

What you sent me offline had different positions then what you stated here. I used your input file with these DFSORT control statements and got two output records from your six input records:

Code:

  OPTION NZDPRINT               
  SORT FIELDS=(1,135,CH,A)     
  SUM FIELDS=(139,7,ZD)     
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
Search our Forums:

Back to Top