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

How to use SORT for below Quey


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

New User


Joined: 06 May 2008
Posts: 96
Location: Delhi

PostPosted: Tue Apr 02, 2013 11:59 pm
Reply with quote

I want to use SORT function to do the following function.

Input FILE
Code:

1,2,3,4  EMC6RAH1 ndqlndlqndlqnldnql
2,3,4    EMC6RAH2 ndqlndlqndlqnldnql
1,3,4    EMC6RAH3 ndqlndlqndlqnldnql
3,4      EMC6RAH1 ndqlndlqndlqnldnql



Output File
Code:

EMC6RAH1
EMC6RAH2
EMC6RAH3


Input file is of RECLENGTH = 80
Basically I want to remove duplicates from the Input files taking in consideration the fields starting from position 16 and 8 length.

And output file should only have unique rows and only the data which start from position 16 and 8 length.

Can anyone please guide me some initial steps which I can use to acheive this.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Apr 03, 2013 12:14 am
Reply with quote

Have a look in the manual at how the different parts of the SORT hang together.

You need to SORT your data. SUM FIELDS=NONE can get rid of the duplicates.

To get the minimum amount of data into SORT, use INREC to prepare only the data you need. You can use BUILD on INREC.

Code:
  INREC BUILD=(for you to determine)
  SORT FIELDS=(again straightforward)
  SUM FIELDS=(NONE)
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Apr 03, 2013 12:19 am
Reply with quote

Your INPUT and OUTPUT does not match.

Position 16 for 8 bytes has the following

Code:

----+----1----+----2----+----3----+----4----+
1,2,3,4  EMC6RAH1 NDQLNDLQNDLQNLDNQL         
2,3,4    EMC6RAH2 NDQLNDLQNDLQNLDNQL         
1,3,4    EMC6RAH3 NDQLNDLQNDLQNLDNQL         
3,4      EMC6RAH1 NDQLNDLQNDLQNLDNQL         


H1 NDQLN
H2 NDQLN
H3 NDQLN
H1 NDQLN


Your Output shows the contents from position 10. is your Input a VB file? or FB file?

As Bill points out it is an elementary task.

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
scorp_rahul23

New User


Joined: 06 May 2008
Posts: 96
Location: Delhi

PostPosted: Thu Apr 04, 2013 4:20 pm
Reply with quote

I have used below conditions

Code:

//SYSIN DD *                         
    INREC BUILD=(1:16,8)             
    SORT FIELDS=(16,8,CH,A)         
    SUM FIELDS=NONE                 
*/                                   


And Input file is like

Code:


----+----1----+----2----+----3----+----4----+
1,2,3,4        EMC6RAH1 NDQLNDLQNDLQNLDNQL         
2,3,4          EMC6RAH2 NDQLNDLQNDLQNLDNQL         
1,3,4          EMC6RAH3 NDQLNDLQNDLQNLDNQL         
3,4            EMC6RAH1 NDQLNDLQNDLQNLDNQL         




I am getting below error

Code:


3 INVALID DATA SET ATTRIBUTES: SORTOUT  RECFM   - REASON CODE IS 08   
0 VLSHRT NOT USED FOR SORT, MERGE, INCLUDE, OMIT OR SUM STATEMENT FIELD

Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Apr 04, 2013 4:28 pm
Reply with quote

Can you post the messages including the message numbers, please?
Back to top
View user's profile Send private message
scorp_rahul23

New User


Joined: 06 May 2008
Posts: 96
Location: Delhi

PostPosted: Thu Apr 04, 2013 4:35 pm
Reply with quote

Code:

ICE250I 0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES A
ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R12 - 06:47 ON THU A
              INREC BUILD=(1:16,8)                                             
              SORT FIELDS=(16,8,CH,A)                                         
              SUM FIELDS=NONE                                                 
          */                                                                   
ICE043A 3 INVALID DATA SET ATTRIBUTES: SORTOUT  RECFM   - REASON CODE IS 08   
ICE150I 0 VLSHRT NOT USED FOR SORT, MERGE, INCLUDE, OMIT OR SUM STATEMENT FIELD
Back to top
View user's profile Send private message
scorp_rahul23

New User


Joined: 06 May 2008
Posts: 96
Location: Delhi

PostPosted: Thu Apr 04, 2013 4:55 pm
Reply with quote

I got it write finally

//SYSIN DD *
SORT FIELDS=(16,8,CH,A)
SUM FIELDS=NONE
OUTREC FIELDS=(1:16,8)
*/
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Thu Apr 04, 2013 4:58 pm
Reply with quote

Why do you have '*/' in your sort control cards?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Apr 04, 2013 5:03 pm
Reply with quote

Is your input variable (as Kolusu guessed already?)

Try:

Code:
//SYSIN DD *
  INREC BUILD=(1,4,16,8)
  SORT FIELDS=(5,8,CH,A)
  SUM FIELDS=NONE


If you input is variable and you want your output fixed, look at OUTFIL and VTOF.
Back to top
View user's profile Send private message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 275
Location: Mumbai

PostPosted: Thu Apr 04, 2013 5:07 pm
Reply with quote

scorp_rahul23 wrote:
I have used below conditions

Code:

//SYSIN DD *                         
    INREC BUILD=(1:16,8)             
    SORT FIELDS=(16,8,CH,A)         
    SUM FIELDS=NONE                 
*/                                   




For this change the code as below and it will work

Code:
//SYSIN DD *                         
    INREC BUILD=(1:16,8)             
    SORT FIELDS=(1,8,CH,A)         
    SUM FIELDS=NONE           


I am not sure but I guess Inrec will be more efficient than Outrec..
May be Bill or Skolusu can confirm on this

Regards,
Chandan
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Apr 04, 2013 5:48 pm
Reply with quote

The less data which goes into the actual SORT, the better. Unless dependent on the sorted order (like the need to use WHEN=GROUP, or similar), "cutting down" a record should be done with INREC.

BUILD would never need "1:", as this is the default. Columns in BUILD can lead to spaces in between fields, which may be the design, or not. Can also lead to "overlapping" fields, which is not allowed on BUILD.

I thing the problem is that the input is variable, requiring the input RDW (position one for length of four) to be included in the INREC record.

scorp_rahul23,

I avoid using FIELDS= in such situations. It is equivalent to BUILD, and is there for "backwards compatibility" for Sort Control Decks written many years ago. FIELDS is very "overloaded" (the same word meaning different things in different contexts, like SUM, SORT, INCLUDE/OMIT), so just because you can, doesn't mean it is a good idea to do so.

If you can clear up the variable/fixed question for your input and output, we can finish this off.
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 Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top