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

Sort base upon differnt position


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
DB2 Guy

New User


Joined: 28 Oct 2008
Posts: 98
Location: Cubicle

PostPosted: Thu Mar 19, 2009 7:12 pm
Reply with quote

Hi,

In input if at a particular position "D" is present, I need to sort some other position if it's "D" I need to sort on other position. Say, I've this input
Code:
----+----1----+----2--
//SORTIN   DD  *     
6316383017 9059 9094 D
9316383017 9059 9094 M
9316383017 9059 9064 M
9316383017 9059 9064 M
6316383018 9062 9094 D
6316383018 9050 9092 D
8316383017 9059 9064 M
8316383017 9059 9064 M
6316383019 9061 9064 D
6316383019 9040 9064 D
7316383017 9059 9094 M
7316383017 9059 9094 M
6316383020 9070 9094 D
6316383020 9061 9094 D
5316383017 9094 9094 M
6316383021 9094 9094 D
4316383017 9094 9094 M
then teh expected output is:
Code:
----+----1----+----2--
4316383017 9094 9094 M
5316383017 9064 9065 M
5316383017 9094 9094 M
6316383017 9059 9094 D
6316383018 9050 9094 D
6316383018 9062 9092 D
6316383019 9040 9064 D
6316383019 9061 9064 D
6316383020 9061 9094 D
6316383020 9072 9094 D
7316383017 9059 9094 M
7316383017 9059 9094 M
8316383017 9059 9064 M
8316383017 9059 9064 M
9316383017 9059 9094 M
9316383017 9059 9064 M
9316383017 9059 9064 M
how to proceed, not getting any idea..stuck up. Please guide.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Thu Mar 19, 2009 7:21 pm
Reply with quote

INREC with the IFTHEN clause to set the different keys in a common area, sort on that common area and OUTREC to remove the added key location.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Thu Mar 19, 2009 7:22 pm
Reply with quote

You have not explained on what fields the sort needs to be performed if the D is present.

You have not explained what happens if D is not present. Is the data to be sorted, and if so on what fields.

What is the RECFM and LRECL of the input file.

By posting in the JCL forum is the product being used SYNCSORT, and if so, what level / release is being used.
Back to top
View user's profile Send private message
DB2 Guy

New User


Joined: 28 Oct 2008
Posts: 98
Location: Cubicle

PostPosted: Thu Mar 19, 2009 7:36 pm
Reply with quote

Hi Expat,
expat wrote:
You have not explained on what fields the sort needs to be performed if the D is present.
My mistake - if D, I need to sort on (17,4) if M, on (12,4)

Quote:
You have not explained what happens if D is not present. Is the data to be sorted, and if so on what fields.
If D and M both are not present (say SPACES) are there, don't sort.
Quote:
What is the RECFM and LRECL of the input file.
FB,80 - for exapmle. I would try to extend to my actual file, in case I failed I'll get back to you guys.
Quote:
By posting in the JCL forum is the product being used SYNCSORT, and if so, what level / release is being used.
Yes SyncSort -SYNCSORT FOR Z/OS 1.2.3.0R .
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Thu Mar 19, 2009 7:42 pm
Reply with quote

DB2 Guy wrote:
Yes SyncSort -SYNCSORT FOR Z/OS 1.2.3.0R .
That could cause a problem, does 1.2.3 have the IFTHEN?
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Mar 19, 2009 7:46 pm
Reply with quote

Quote:
That could cause a problem, does 1.2.3 have the IFTHEN?
Yes. Even my version has - 1.2.1.0
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Thu Mar 19, 2009 7:55 pm
Reply with quote

DB2 Guy wrote:
If D and M both are not present (say SPACES) are there, don't sort.

Does this mean you do not want this record included in the output?
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Mar 19, 2009 7:58 pm
Reply with quote

DB2 Guy,

The sort order you mentioned does nt seem to match the expected results.
Quote:
if D, I need to sort on (17,4)
The 'D' records in output are NOT sorted on 17,4. And it seems to be sorted on (1,10) instead. icon_rolleyes.gif
Quote:
4316383017 9094 9094 M
5316383017 9064 9065 M
5316383017 9094 9094 M
6316383017 9059 9094 D
6316383018 9050 9094 D
6316383018 9062 9092 D
6316383019 9040 9064 D
6316383019 9061 9064 D
6316383020 9061 9094 D
6316383020 9072 9094 D
7316383017 9059 9094 M
7316383017 9059 9094 M
8316383017 9059 9064 M
8316383017 9059 9064 M
9316383017 9059 9094 M
9316383017 9059 9064 M
9316383017 9059 9064 M
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Thu Mar 19, 2009 8:17 pm
Reply with quote

Here is a SyncSort for z/OS job that will produce the output as shown in the first post (not based on the written description):
Code:
//SORT1 EXEC PGM=SORT
//SORTIN  DD DSN=input.dataset,...
//SORTOUT DD DSN=output.dataset,...
//SYSOUT  DD SYSOUT=*
//SYSIN   DD *
  INREC IFTHEN=(WHEN=(22,1,CH,EQ,C'D'),OVERLAY=(24:17,4)), 
        IFTHEN=(WHEN=(22,1,CH,EQ,C'M'),OVERLAY=(24:12,4))   
  SORT FIELDS=(1,10,CH,A,24,4,CH,A)                         
  OUTREC FIELDS=(1,22)                                     
/*

If there are records present in the input data set that do not have a D or M in position 22 and you want them removed from the output, then simply add the following statement to SYSIN:
Code:
INCLUDE COND=(22,1,CH,EQ,C'D',OR,22,1,CH,EQ,C'M') 
Back to top
View user's profile Send private message
DB2 Guy

New User


Joined: 28 Oct 2008
Posts: 98
Location: Cubicle

PostPosted: Fri Mar 20, 2009 9:53 pm
Reply with quote

Hi Arun,

Thanks for your time - Your observation is right; I tried to simulate some sample input and output - and goofed up . . . icon_redface.gif
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Fri Mar 20, 2009 9:58 pm
Reply with quote

DB2 Guy wrote:
Hi Arun,

Thanks for your time - Your observation is right; I tried to simulate some sample input and output - and goofed up . . . icon_redface.gif

So which was the actual requirement - the sample data or the description you later provided?
Back to top
View user's profile Send private message
DB2 Guy

New User


Joined: 28 Oct 2008
Posts: 98
Location: Cubicle

PostPosted: Fri Mar 20, 2009 10:24 pm
Reply with quote

Hi Alissa,

Your Sort give me an idea to start with - Thanks. My file is VB & of length 10978 - will try to "imposr" this sort on that. Hopefully I would be able to it; in case I stuck up some where I'll get back you. . .
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Help with SORT - I need to validate d... DFSORT/ICETOOL 7
No new posts COBOL sorting, with input GDG base COBOL Programming 7
No new posts JCL sort to compare dates in two file... DFSORT/ICETOOL 2
No new posts Is this possible via sort (in one pass)? SYNCSORT 4
No new posts GDG generation name to GDG Base name ... DFSORT/ICETOOL 3
Search our Forums:

Back to Top