MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Urgent help required for syncsort a file on multiple conds!!

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
rajat_gupta
Beginner


Joined: 30 May 2007
Posts: 13
Topics: 5
Location: India

PostPosted: Fri Sep 17, 2010 1:31 am    Post subject: Urgent help required for syncsort a file on multiple conds!! Reply with quote

Hi All,

I have a requirement where in I have an input file containing multiple layouts.It has different record types like 01, 02, 03 etc. Each record type is having a different unique key.I want to sort that input file for each record type and create a single output file.
Pls guide me if it is possible thru SORT utility.
The sample input file is

00 0000000000 header data 0000 00 00 00
01 9000000002 heirarchy data 0000 44 02 00
01 9000000002 heirarchy data 0000 41 02 00
02 9000000002 address data 0050 51 61 00
02 9000000002 address data 0051 52 63 00
03 9000000002 agreement data 0051 52 64 76
03 9000000002 agreement data 0051 52 64 77


-
-
-
88 0000000000 trailor data


record type 01 needs to be sorted on col5
record type 02 needs to be sorted on col6
record type 03 needs to be sorted on col7

I have done sorting based on a single criteria only.I will highly the valuable comments and suggestions from the Mainframer's.

Thanks
Rajat
_________________
Rajat Gupta

when depressing thoughts seem to get you down
Put a smile on your face and thank God you're alive and still around.
Back to top
View user's profile Send private message
Sqlcode
Intermediate


Joined: 15 Dec 2006
Posts: 157
Topics: 38

PostPosted: Fri Sep 17, 2010 9:34 am    Post subject: Reply with quote

Rajat Gupta,
Quote:
record type 01 needs to be sorted on col5
record type 02 needs to be sorted on col6
record type 03 needs to be sorted on col7

What are field positions for col5,col6 and col7? Also, how many different record types are possible? Could you have "record type 04" and "record type 05" records? If so, what is the sorting order for them?

Also, Do you want records to be primarily sorted on "Record Types" and secondary sort on "col5","col6" and "col7"? What is LRECL and RECFM of the input file?

Thanks,
Back to top
View user's profile Send private message
rajat_gupta
Beginner


Joined: 30 May 2007
Posts: 13
Topics: 5
Location: India

PostPosted: Fri Sep 17, 2010 1:24 pm    Post subject: Reply with quote

hi sqlcode, i can have a maximum of 16 record types and each record type needs to be sorted on a diff. Key.some parts of the keys are overlapping as well.it was a sample data which i had posted.for the time being we can assume that there are only 3 rec types(01,02 and 03) and each is having an independent criteria of sorting. rec type 01 needs to be sorted on col 1 to 3,rec type 02 on col 3 to 5,rec type 03 on col 3 to 8.if we can come up with a logic catering these 3 record types,later on we can cover all the possible scenarios.i know its a bit tricky thats why i am in search of expert advices from the experts.the file is a VB one with LRECL of 2000.
_________________
Rajat Gupta

when depressing thoughts seem to get you down
Put a smile on your face and thank God you're alive and still around.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Sep 17, 2010 3:47 pm    Post subject: Reply with quote

Quote:
later on we can cover all the possible scenarios.i know its a bit tricky thats why i am in search of expert advices from the experts.the file is a VB one with LRECL of 2000.


rajat_gupta,

It is NOT tricky or complicated. It is just a simple use of padding the key at a common place using an IFTHEN statement. why post in bits and pieces? post the entire requirement in one go. If your File is a VB file , how can you have data at pos 1 and 3? Assuming that you did not account for the RDW , where is the identifier for the record type?

Post the complete details not bits and pieces. Answer ALL questions

1. What is the position and format of the record type?
2. If the record type = 01 , then what is the position and format of the key to be sorted (please don't give me arbitrary positions)
3. Do the same for all the record types.
4. Do you need to consider the record type also as a key? or just the field? for ex

Code:

01ZZZ           
01YYY           
01XXX           
02   DDD         
02   FFF         
02   EEE         
03      AAAAAA   
03      CCCCCC   
03      GGGGGG     



If you don't consider the record type as key , the output would be as follows

Code:

03      AAAAAA   
03      CCCCCC   
02   DDD         
02   EEE         
02   FFF         
03      GGGGGG   
01XXX             
01YYY             
01ZZZ             


but if you consider the record type also as key , the output would be

Code:

01XXX         
01YYY         
01ZZZ         
02   DDD       
02   EEE       
02   FFF       
03      AAAAAA
03      CCCCCC
03      GGGGGG


so tell us in detail about the order you want and post a sample data of input and desired output
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
rajat_gupta
Beginner


Joined: 30 May 2007
Posts: 13
Topics: 5
Location: India

PostPosted: Sat Sep 18, 2010 4:48 am    Post subject: Reply with quote

Hi Kolusu,

Here we GO !!

1) I did'nt posted the data because it was a huge file of 2000 bytes.This time around also, I was only able to copy only a part of it.(staring 70 bytes for each record type but have modified the required keys accordingly)

2) The actual requirement is to identify the duplicates from this file(which will be later on done by a COBOL routine).The duplicates can come for any record type and any number of times.For ex if original Rec type 01 is at row no 2, the duplicates for this record type can arrive anywhere in the file(for ex. row no 3, row no 10, etc).This is happening because this file is a merged version of certain GDG generations which are receiving the data from upstream and more than 1 generations can contain the same repeated data.Even we need to arrange the duplicate headers and duplicate trailers as well based on their keys.

Note:: During the entire SORT process we are no where eliminating any records from the input file.Its just we are re-ordering them based on their record types and record keys.


THIS IS THE SAMPLE DATA,


INDIA4 2 019541100188 35456/999912/31/9999 12/31/9999
INDIA4 2 089541100188 225 SPLENDORS SHOP GARCIA
INDIA4 2 089541100188 217 *SPLENDORS SHOP GARCIA
INDIA4 2 129541100188 1 92 1198FOTOGRAFIA SALES PASTOR
INDIA4 2 139541100188 071444072010 01/01/
INDIA4 2 139541100188 080555062010 01/01/
INDIA4 2 019841100255 I 35467/999912/31/9999 12/31/9999
INDIA4 2 139841100255 071999062010 01/01/
INDIA4 2 139841100255 071991062010 01/01/
DUPLIC 2 019541100188 35456/999912/31/9999 12/31/9999
DUPLIC 2 089541100188 225 SPLENDORS SHOP GARCIA
DUPLIC 2 089541100188 217 *SPLENDORS SHOP GARCIA
DUPLIC 2 129541100188 1 92 1198FOTOGRAFIA SALES PASTOR
DUPLIC 2 139541100188 071444072010 01/01/
DUPLIC 2 139541100188 080555062010 01/01/




In the Above Sample the last six records are duplicates which I have prefixed with "DUPLIC".
Data starts from pos 5 as its a VB file.Yes it needs to be sorted on Record type as well.
Pos 14-15 is the record type X(02).Sample values are 01,08,12,13,14,15 and 20.(At max I can receive 16.Minimum is 0)

Key for 01:

16,10,ch,A, (Acc no)
14,2,ch,A (rec type)

Key for 08:
16,10,ch,A, (Acc no)
14,2,ch,A, (rec type)
27,3,ch,A

Key for 12:
16,10,ch,A, (Acc no)
14,2,ch,A, (rec type)
29,2,ch,A

Key for 13:
16,10,ch,A , (Acc no)
14,2,ch,A , (rec type)
30,3,ch,A ,
33,2,ch,A



The output should look like,

INDIA4 2 019541100188 35456/999912/31/9999 12/31/9999
DUPLIC 2 019541100188 35456/999912/31/9999 12/31/9999
INDIA4 2 089541100188 225 SPLENDORS SHOP GARCIA
DUPLIC 2 089541100188 225 SPLENDORS SHOP GARCIA
INDIA4 2 089541100188 217 *SPLENDORS SHOP GARCIA
DUPLIC 2 089541100188 217 *SPLENDORS SHOP GARCIA
INDIA4 2 129541100188 1 92 1198FOTOGRAFIA SALES PASTOR
DUPLIC 2 129541100188 1 92 1198FOTOGRAFIA SALES PASTOR
INDIA4 2 139541100188 071444072010 01/01/
DUPLIC 2 139541100188 071444072010 01/01/
INDIA4 2 139541100188 080555062010 01/01/
DUPLIC 2 139541100188 080555062010 01/01/
INDIA4 2 019841100255 I 35467/999912/31/9999 12/31/9999
INDIA4 2 139841100255 071999062010 01/01/
INDIA4 2 139841100255 071991062010 01/01/

In the output file, for every account no I need to get all the record types in sorted order of their keys.
Sort cord could be of any length but we need a single output file in the same format (VB,2000).Waiting eagerly for any possible solution.

Many Thanks,
_________________
Rajat Gupta

when depressing thoughts seem to get you down
Put a smile on your face and thank God you're alive and still around.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Sat Sep 18, 2010 11:45 am    Post subject: Reply with quote

rajat_gupta,

Your output does NOT match the sort criteria you have shown especially for the 08 type , how did 225 record come before 217 record? Assuming that it is a typo here is a DFSORT JCL which will give you the desired results

You already have the common key (16,10, and 14,2) for every record type all you need to account for is the additional 5 bytes you have for type 13. For that we pad 5 spaces right after the RDW and using an Ifthen we populate the contents on to that validating the record types. For record type 01 you don't need to. Since we added 5 bytes at the beginning the entire record is shifted by 5 bytes. After the sort is done we remove this temp 5 bytes using OUTREC to retain the original file length.


Code:

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD DSN=your inout vb file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                         
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,5X,5)),             
  IFTHEN=(WHEN=(19,2,CH,EQ,C'08'),OVERLAY=(5:32,03)),   
  IFTHEN=(WHEN=(19,2,CH,EQ,C'12'),OVERLAY=(5:34,02)),   
  IFTHEN=(WHEN=(19,2,CH,EQ,C'13'),OVERLAY=(5:35,05))     
  SORT FIELDS=(21,10,CH,A,19,2,CH,A,5,5,CH,A),EQUALS     
  OUTREC BUILD=(1,4,10)                                 
//*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
rajat_gupta
Beginner


Joined: 30 May 2007
Posts: 13
Topics: 5
Location: India

PostPosted: Sun Sep 19, 2010 11:03 am    Post subject: Reply with quote

Kolusu,

Thanks a Ton!
I have implemented this Logic for all the possible record types.
However I had missed a point while asking this question.

The key values I provided in sample data were all in Characters, however the actual data has got keys in BI (comp) and PD (comp3) format as well.
What I am doing for that is, I am converting all the binary and PD fields(using edit masks) and putting them together at starting position and then sorting on that.

I am able to do so but just have a small doubt,hope you can clarify that as well.
If in a file I am having a single field(VB 2000) defined as S9(9) comp and I am converting it to CH using the below edit mask,
Overlay=(5:5,4,BI,EDIT=(SIIIIIIIIT),SIGNS=(,-,,),

and after that If I sort that file based on the below Sort card,
SORT FIELDS=(5,10,CH,A), will it always produce the same result if I had given the sort condition directly on the original BI field, like below.(The BI field in signed and can contain both the positive and negative values).
SORT FIELDS=(5,4,BI,A)

I am bit afraid on moving this logic to production environment because of this threat raising in my mind.(Or if you can suggest an alternative approach to my problem).

Many Thanks,
_________________
Rajat Gupta

when depressing thoughts seem to get you down
Put a smile on your face and thank God you're alive and still around.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Sun Sep 19, 2010 11:49 am    Post subject: Reply with quote

rajatgupta wrote:
I am bit afraid on moving this logic to production environment because of this threat raising in my mind.(Or if you can suggest an alternative approach to my problem).


rajat_gupta,

You should be very afraid. I specifically asked you about the format of keys to be sorted and yet you provide some arbitrary formats. You are just wasting my time as well as your time. A simple requirement which should have been solved in less than 15 minutes has now spanned over 2 days.

Quote:
The key values I provided in sample data were all in Characters, however the actual data has got keys in BI (comp) and PD (comp3) format as well.
What I am doing for that is, I am converting all the binary and PD fields(using edit masks) and putting them together at starting position and then sorting on that.


You shouldn't be doing any such stuff to convert the data. Sort is capable of sorting the various formats.

If you really need help , then start over once again and explain ALL the details of the keys involved with their position and format for each record type.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
rajat_gupta
Beginner


Joined: 30 May 2007
Posts: 13
Topics: 5
Location: India

PostPosted: Mon Sep 20, 2010 2:55 am    Post subject: Reply with quote

Hi Kolusu,

Sincere apologies for not sharing the entire picture initially.
Below are the actual Keys for every record type,

Record types starting pos is 18 in the file.(after adding up 4 bytes for VB).

Type 01
SORT FIELDS=(11,2,BI,A,30,4,BI,A)

Type 02
SORT FIELDS=(11,2,BI,A,30,4,BI,A,77,4,BI,A,57,2,BI,A,34,20,CH,A)

Type 03
SORT FIELDS=(11,2,BI,A,30,4,BI,A,77,4,BI,A,57,2,BI,A,34,20,CH,A)

Type 04
SORT FIELDS=(11,2,BI,A,30,4,BI,A,196,4,BI,A,79,20,CH,A)

Type 05
SORT FIELDS=(11,2,BI,A,30,4,BI,A,196,4,BI,A,79,20,CH,A)

Type 06
SORT FIELDS=(11,2,BI,A,30,4,BI,A,54,2,CH,A)

Type07
SORT FIELDS=(11,2,BI,A,30,4,BI,A,45,6,PD,A)

Type 08
SORT FIELDS=(11,2,BI,A,20,10,CH,A)

Type 09
SORT FIELDS=(11,2,BI,A,20,10,CH,A)

Type 10
SORT FIELDS=(11,2,BI,A,20,10,CH,A,151,5,CH,A)

Type 11
SORT FIELDS=(11,2,BI,A,20,10,CH,A,34,3,CH,A)

Type 12
SORT FIELDS=(11,2,BI,A,20,10,CH,A,325,5,CH,A,355,5,CH,A,268,3,CH,A,
214,4,CH,A)

Type 13
SORT FIELDS=(11,2,BI,A,35,10,CH,A,45,5,CH,A,51,5,CH,A)

Type 14
SORT FIELDS=(11,2,BI,A,20,10,CH,A,76,3,CH,A)


Many Thanks,
_________________
Rajat Gupta

when depressing thoughts seem to get you down
Put a smile on your face and thank God you're alive and still around.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon Sep 20, 2010 11:33 am    Post subject: Reply with quote

rajat_gupta,

It is really tough to get the requirements from you. Yesterday you are telling that you have positive and negative values for someone of the fields and today you show the fields as binary ( unsigned). Whatever happened to sorting of the record-type? Either way here is my final guess solution for you.

The biggest key you need to sort is 32 bytes. (type 02 and 03). We also have a common key of 6 bytes ( types 1 - 7 ). so we pad these right after RDW and pad 26 bytes for accommodating the largest key.

since we are padding extra 32 bytes , the entire record is shifted by 32 bytes. so you need to add 32 for all the positions you mentioned. ex: record type which is originally at position 18 is now at position 50.

I did not account for the record type in sorting. You can add that if you need it. Any field which can have positive and negative numbers should be sorted as FI format. Character data can be sorted as BI. So depending on the fields change your sort format.

Code:

//SYSIN    DD *                                                     
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,11,2,30,4,26X,5)),             
  IFTHEN=(WHEN=(50,2,SS,EQ,C'02,03'),OVERLAY=(11:109,4,89,2,66,20)),
  IFTHEN=(WHEN=(50,2,SS,EQ,C'04,05'),OVERLAY=(11:228,4,111,20)),   
  IFTHEN=(WHEN=(50,2,CH,EQ,C'06'),OVERLAY=(11:86,2)),               
  IFTHEN=(WHEN=(50,2,CH,EQ,C'07'),OVERLAY=(11:77,6,PD,FI,LENGTH=8)),
  IFTHEN=(WHEN=(50,2,SS,EQ,C'08,09'),OVERLAY=(07:52,10)),           
  IFTHEN=(WHEN=(50,2,CH,EQ,C'10'),OVERLAY=(07:52,10,183,5)),       
  IFTHEN=(WHEN=(50,2,CH,EQ,C'11'),OVERLAY=(07:52,10,66,3)),         
  IFTHEN=(WHEN=(50,2,CH,EQ,C'12'),                                 
  OVERLAY=(07:52,10,357,5,387,5,300,3,246,4)),                     
  IFTHEN=(WHEN=(50,2,CH,EQ,C'13'),OVERLAY=(07:67,10,77,5,83,5))     
                                                                   
  SORT FIELDS=(05,02,FI,A,                                         
               07,04,BI,A,                                         
               11,26,BI,A),EQUALS     

  OUTREC BUILD=(1,4,37)                             
//*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
rajat_gupta
Beginner


Joined: 30 May 2007
Posts: 13
Topics: 5
Location: India

PostPosted: Tue Sep 21, 2010 9:25 am    Post subject: Reply with quote

Thanks Kolusu,

This is working fine for all the key types except the rec type 07 which has a PD field in the Key.When I am running the Job Its throwing S000 U0016 Abend and giving an ARITHMETIC OVERFLOW.(Sort parameters are exactly the same which you mentioned)

Below is the Sysout for the Sort Step:

SYSDIAG= 295286, 1897435, 1897435, 2650575
24,620K BYTES OF VIRTUAL STORAGE AVAILABLE, MAX REQUESTED,
0 BYTES RESERVE REQUESTED, 24,572K BYTES USED
4K BYTES OF EMERGENCY SPACE ALLOCATED
SORTIN : RECFM=VB ; LRECL= 2000; BLKSIZE= 27998
INREC RECORD LENGTH = 2032
POTENTIALLY INEFFICIENT USE OF INREC
OUTREC RECORD LENGTH = 2000
SORTOUT : RECFM=VB ; LRECL= 2000; BLKSIZE= 27832
23,592K BYTES OF VIRTUAL STORAGE AVAILABLE ABOVE THE 16MEG LINE,
0 BYTES RESERVE REQUESTED, 23,592K BYTES USED
G=3134,SEGLEN=7848
INREC ARITHMETIC OVERFLOW
SYNCSMF CALLED BY SYNCSORT; RC=0000
_________________
Rajat Gupta

when depressing thoughts seem to get you down
Put a smile on your face and thank God you're alive and still around.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Sep 21, 2010 10:03 am    Post subject: Reply with quote

rajat_gupta,

The messages indicates you are using SYNCSORT. I'm a DFSORT developer. DFSORT and Syncsort are competitive products. I'm happy to answer questions on DFSORT and DFSORT's ICETOOL, but I don't answer questions on Syncsort.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
papadi
Supermod


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Tue Sep 21, 2010 3:52 pm    Post subject: Reply with quote

It may help if you post the hex values of some of the packed-decimal data in the type 07 records.
_________________
All the best,

di
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group