searching for a special character through sort

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
4ubobby
Member
Posts: 19
Joined: Fri Nov 06, 2009 7:49 pm
Location: USA

searching for a special character through sort

Post by 4ubobby » Mon Nov 09, 2009 7:00 pm

hi,

I have a requirement where in my jcl sort needs to search for a special character like *.

the sample data would be like this

1234545*
1*32345
1234*11
1234555
2343566


My sort jcl needs to pick only the first three records which contains *

thanks in advance
thanks

Bobby

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Mon Nov 09, 2009 9:53 pm

You can a DFSORT job like the following to do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

Code: Select all

//S1    EXEC  PGM=SORT                   
//SYSOUT    DD  SYSOUT=*                 
//SORTIN DD *                            
1234545*                                 
1*32345                                  
1234*11                                  
1234555                                  
2343566                                  
9234*11                                  
//SORTOUT DD SYSOUT=*                    
//SYSIN    DD    *                       
  OPTION COPY,STOPAFT=3                  
  INCLUDE COND=(1,80,SS,EQ,C'*')         
/*
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:

http://www.ibm.com/support/docview.wss? ... g3T7000080
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

4ubobby
Member
Posts: 19
Joined: Fri Nov 06, 2009 7:49 pm
Location: USA

Post by 4ubobby » Mon Dec 21, 2009 9:07 pm

Hi frank,

I have two input files and require a output format based on the following conditions.

input file 1 lrecl 80
****************
1234 test data
2345 sample
3456 test sample


input file 2 lrecl 80
***************
1234 bobby
1234 frank
2345 adam
3456 john

my output file should look like

output file
********

1234 test data bobby
2345 sample adam
3456 test sample john

the key in both the input files is first 4 bytes. If the key field is present in both the files i want the complete record from the first file and one field from the second file. input file 1 has no duplicates. Input file 2 has duplicates i want to consider the first occurance in that case.

could you please help me with this..
thanks

Bobby

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Mon Dec 21, 2009 11:07 pm

Are you using DFSORT (ICExxxs messages?).

If so, do you have the Nov, 2009 DFSORT PTF? To find out, look at the ICE201I message from a DFSORT run - if it has

ICE201I G

then you have the Nov, 2009 PTF installed. Otherwise, you don't. Let me know.

In the future, please start a New Topic for a new question rather than appending it to an old, unrelated one. Also, please use ubb code tags around your examples.
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

4ubobby
Member
Posts: 19
Joined: Fri Nov 06, 2009 7:49 pm
Location: USA

dfsort

Post by 4ubobby » Mon Dec 21, 2009 11:44 pm

hi frank,

From next time, i would open a new topic for a new question. i don't have ICE201I G in my shop....
thanks

Bobby

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Tue Dec 22, 2009 12:26 pm

Bobby,

You did not answer this yet:
Are you using DFSORT (ICExxxs messages?).
Regards,
Anuj

4ubobby
Member
Posts: 19
Joined: Fri Nov 06, 2009 7:49 pm
Location: USA

dfsort icetool

Post by 4ubobby » Tue Dec 22, 2009 7:32 pm

Hi,

My shop as Dfsort icettol however frank was asking for some specific message ice201I G which i don't find in the icetool messages..
thanks

Bobby

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Tue Dec 22, 2009 11:08 pm

Hmmm ... I can't figure out the positions of the fields in the input or output records.

Please tell me the starting position, length and format of each field in each input file and in the output file.
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

4ubobby
Member
Posts: 19
Joined: Fri Nov 06, 2009 7:49 pm
Location: USA

Post by 4ubobby » Wed Dec 23, 2009 12:12 am

input file 1 lrecl 80
****************
1234 test
2345 host
3456 also


input file 2 lrecl 80
***************
1234 bobby
1234 frank
2345 adam
3456 john

my output file should look like

output file
********

1234 test bobby
2345 host adam
3456 also john

if input file-1 first four bytes matches with the first four bytes of input file-2. Then copy the record from input file and the second field in the second file 5 bytes that is from 6th position.

in the above example 1234 is present in both the files in this case

i want the following data in output file.

1234 test data bobby

Please let me know if you have questions in my question :?:
thanks

Bobby

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Thu Dec 24, 2009 12:03 am

Please let me know if you have questions
In your example, every key in file1 has a match in file2. Is that always the case or can there be a key in file1 that is not in file2 and/or a key in file2 that is not in file1? If so, please expand your input/output example to show the other possible cases, and explain what you want to do in those cases.

Also, you show the records already sorted by the key in file1 and in file2. Is that always true or can the records be in unsorted order in file1 and/or file2?
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

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others