Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Distinct values in a file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
mkk157

Active User


Joined: 17 May 2006
Posts: 310

PostPosted: Fri Jul 23, 2010 7:55 am    Post subject: Distinct values in a file
Reply with quote

Dear Expert,

I have a file with 5 columns say
EMPID EMPNAME SALARY DESIGNATION DEPARTMENT
101 AAAAAAA 100000 ENGINEER IT
102 BBBBBBB 100000 ADMIN ADMIN
103 CCCCCC 100000 MANAGER IT
104 DDDDDD 100000 ADMIN ADMIN
105 EEEEEEEE 100000 TEAM LEAD IT
106 FFFFFFFFF 100000 ENGINEER IT
107 GGGGGG 100000 ENGINEER IT
108 HHHHHHH 100000 MANAGER IT
109 IIIIIIIIIII 100000 TEAM LEAD IT
110 KKKKKKK 100000 HR HR

Now I would like to know
1) Distinct values in DESIGNATION column
By SQL, I can achieve this using
SELECT DISTINCT DESIGNATION FROM EMPLOYEE.

2) Distinct values in DESIGNATION column and its count.
By SQL, I can achieve this using
SELECT DISTINCT DESIGNATION, count(*) FROM EMPLOYEE group by DESIGNATION.

I would like to achieve the same results using DFSORT for the above file.
Please suggest me an idea.
Back to top
View user's profile Send private message

bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 210
Location: Cochin/Kerala/India

PostPosted: Fri Jul 23, 2010 8:46 am    Post subject:
Reply with quote

Hi MKK,
Try the below code
[/code] SORT FIELDS=(14,8,CH,A) -----> Designation
INREC FIELDS=(1,25,26:C'001')
SUM FIELDS=(26,3,ZD)
OUTREC FIELDS=(14,8,26,3)
Code:
Back to top
View user's profile Send private message
ssmukul

New User


Joined: 22 Jan 2008
Posts: 19
Location: India

PostPosted: Fri Jul 23, 2010 10:51 am    Post subject:
Reply with quote

Hi MKK,

As I don't know the starting position and length of DESIGNATION field, I have used below input to get the results as you required.
Code:
//SORTIN DD * 
101 AAA ENG IT
102 BBB ENG IT
103 CCC ADM IT
104 DDD MNG IT
105 EEE ENG IT
106 FFF ADM IT
107 GGG MNG IT

For distinct designation I have used below sort card,
Code:
//SYSIN DD *           
  SORT FIELDS=(9,3,CH,A)
  SUM FIELDS=NONE       
  OUTREC FIELDS=(1:9,3)

and the O/P is as
Code:
ADM
ENG
MNG

For distinct designation and its count,
Code:
//SYSIN DD *                           
  SORT FIELDS=(9,3,CH,A)               
    OUTFIL REMOVECC,NODETAIL,           
     SECTIONS=(9,3,                     
     TRAILER3=(9,3,COUNT=(EDIT=(IIT))))

and the O/P is as
Code:
ADM  2
ENG  3
MNG  2

Please amend the sort card according to your requirement.
Thanks.
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Fri Jul 23, 2010 7:41 pm    Post subject:
Reply with quote

Alternatively, you can also use below. I assumed your designation field starts from 24th position and is 10 bytes.

Code:
//STEP1    EXEC  PGM=ICETOOL                                 
//TOOLMSG DD SYSOUT=*                                     
//DFSMSG  DD SYSOUT=*                                     
//IN      DD *                                           
101 AAAAAAA     100000 ENGINEER   IT                     
102 BBBBBBB     100000 ADMIN      ADMIN                   
103 CCCCCC      100000 MANAGER    IT                     
104 DDDDDD      100000 ADMIN      ADMIN                   
105 EEEEEEEE    100000 TEAM LEAD  IT                     
106 FFFFFFFFF   100000 ENGINEER   IT                     
107 GGGGGG      100000 ENGINEER   IT                     
108 HHHHHHH     100000 MANAGER    IT                     
109 IIIIIIIIIII 100000 TEAM LEAD  IT                     
110 KKKKKKK     100000 HR         HR                     
//OUT      DD SYSOUT=*                                   
//TOOLIN DD *                                             
 OCCUR FROM(IN) LIST(OUT) ON(24,10,CH) BETWEEN(2) -       
   ON(VALCNT,N08) NOHEADER                               
/*                                                       


Thanks,
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am
No new posts File processing vishwakotin Mainframe Interview Questions 9 Fri Apr 28, 2017 11:38 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us