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
 

 

SORT - I want the output this way

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

New User


Joined: 04 Jul 2005
Posts: 12
Location: Pune

PostPosted: Thu Jul 17, 2008 2:10 pm    Post subject: SORT - I want the output this way
Reply with quote

Code:

Field1       Field2           Field3        Field4
AAA          1458675          Multiplex     ABCDEFGHIJ0
AAA          1458675          Normal        ABCDEFGHOST


Field1 and Field2 are the same for both the records
If there is such an input then I want the output to include only the
record where the Field4 value ends in 'T'
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Thu Jul 17, 2008 2:12 pm    Post subject:
Reply with quote

Your RECFM= your LRECL=
Field 4 has a fixed position and length ?
Back to top
View user's profile Send private message
dip62001

New User


Joined: 04 Jul 2005
Posts: 12
Location: Pune

PostPosted: Thu Jul 17, 2008 2:54 pm    Post subject:
Reply with quote

Field 4 has a fixed position of 45 and length of 11
LRECL=80 RECFM=FB
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jul 17, 2008 5:02 pm    Post subject:
Reply with quote

great subject title. will definitely help anyone searching for wanting there output to be this way.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Jul 17, 2008 9:11 pm    Post subject:
Reply with quote

dip,

Does your input file have only two records or can it have more? For each pair of records, will the record with T in the last position always be the second record or can it be the first record? Can the other record of the pair (not the T record) have only specific values (which specific values) in the last position or can it have any value in the last position?

It would really help if you would show a better example of your input records with all possible variations and the expected output records. It's difficult to get the complete picture from just two records.
Back to top
View user's profile Send private message
dip62001

New User


Joined: 04 Jul 2005
Posts: 12
Location: Pune

PostPosted: Fri Jul 18, 2008 11:36 am    Post subject:
Reply with quote

The input file can have multiple records and the record with T in the last position can be the first one or the last one.The other record can have values ('0','A','9','C')
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Fri Jul 18, 2008 12:13 pm    Post subject: Reply to: SORT - I want the output this way
Reply with quote

Dip,

Frank Wrote:

Quote:
It would really help if you would show a better example of your input records with all possible variations and the expected output records. It's difficult to get the complete picture from just two records.


Show better examples if you want the exact solution.
Back to top
View user's profile Send private message
dip62001

New User


Joined: 04 Jul 2005
Posts: 12
Location: Pune

PostPosted: Fri Jul 18, 2008 4:05 pm    Post subject:
Reply with quote

Code:

Field1       Field2           Field3       Field4
ABA          7134567          Multiplex    ABCDEFGHIJ0
AAA          1458675          Normal       ABCDEFGHOST
ABA          7134567          Duplex       ABCDEFGHIJT
AAA          1458675          Single       ABCDEFGHOSO
BBA          7132227          Multiplex    ABCDEFGHIJc
AAc          1333375          Normal       AREFTREHOST
BBA          7132227          Duplex       ABCDEFGHIJT
AAc          1333375          Single       ABCDEFGHOS9


Code:

Field1       Field2           Field3       Field4
AAA          1458675          Normal       ABCDEFGHOST
ABA          7134567          Duplex       ABCDEFGHIJT
BBA          7132227          Duplex       ABCDEFGHIJT
AAc          1333375          Normal       AREFTREHOST
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Jul 18, 2008 9:59 pm    Post subject:
Reply with quote

Here's a DFSORT/ICETOOL job that will do what you asked for.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD *
ABA          7134567          Multiplex    ABCDEFGHIJ0
AAA          1458675          Normal       ABCDEFGHOST
ABA          7134567          Duplex       ABCDEFGHIJT
AAA          1458675          Single       ABCDEFGHOSO
BBA          7132227          Multiplex    ABCDEFGHIJc
AAc          1333375          Normal       AREFTREHOST
BBA          7132227          Duplex       ABCDEFGHIJT
AAc          1333375          Single       ABCDEFGHOS9
/*
//OUT DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(1,3,CH) ON(14,7,CH) -
  FIRSTDUP USING(CTL1)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'1')),
    IFTHEN=(WHEN=(54,1,CH,EQ,C'T'),OVERLAY=(81:C'0'))
  SORT FIELDS=(1,3,CH,A,14,7,CH,A,81,1,CH,A)
  OUTFIL FNAMES=OUT,BUILD=(1,80)
/*


OUT will have the records in sorted order by field1 and field2:

Code:

AAc          1333375          Normal       AREFTREHOST   
AAA          1458675          Normal       ABCDEFGHOST   
ABA          7134567          Duplex       ABCDEFGHIJT   
BBA          7132227          Duplex       ABCDEFGHIJT   
Back to top
View user's profile Send private message
dip62001

New User


Joined: 04 Jul 2005
Posts: 12
Location: Pune

PostPosted: Thu Jul 24, 2008 9:43 am    Post subject:
Reply with quote

Thanks..Its working fine .. There is one more doubt ........I want the output this way..........

Field 1 and Field 2 for some records can be similar. The idea is to remove the duplicates. If Field4 has a T as the last character then write that record to the output. If Field4 has a T as the last character for all the duplicate records then write the first one that is encountered.
Field4 can have a value that does not end in T. In such cases, write to the output the first value that is encountered.
The non-duplicare records should be written as-is to the output file

Field1 Field2 Field3 Field4
ABA 713456 Multiplex ABCDEFGHIJ0
AAA 145867 Normal ABCDEFGHOST
ABA 713456 Duplex ABCDEFGHIJT
AAA 145867 Single ABCDEFGHOSO
BBA 713222 Multiplex ABCDEFGHIJc
AAc 133337 Normal AREFTREHOST
BBA 713222 Duplex ABCDEFGHIJT
AAC 133337 Single ABCDEFGHOS9
CCC 234567 Single DHGJF892222
AZA 247298 Normal ADSSSSHDSj9

Field1 - length 3
Field2 - start -5, length 6
Field3 - start 12 , length 15
field 4 - start 25 length 11
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Jul 25, 2008 4:08 am    Post subject:
Reply with quote

If I understand correctly what you want, then this DFSORT/ICETOOL job should do it:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD *
ABA 713456 Multiplex    ABCDEFGHIJ0
AAA 145867 Normal       ABCDEFGHOST
ABA 713456 Duplex       ABCDEFGHIJT
AAA 145867 Single       ABCDEFGHOSO
BBA 713222 Multiplex    ABCDEFGHIJc
AAc 133337 Normal       AREFTREHOST
BBA 713222 Duplex       ABCDEFGHIJT
AAc 133337 Single       ABCDEFGHOS9
CCC 234567 Single       DHGJF892222
AZA 247298 Normal       ADSSSSHDSj9
/*
//OUT DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(1,3,CH) ON(5,6,CH) -
  FIRST USING(CTL1)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'1')),
    IFTHEN=(WHEN=(35,1,CH,EQ,C'T'),OVERLAY=(81:C'0'))
  SORT FIELDS=(1,3,CH,A,5,6,CH,A,81,1,CH,A)
  OUTFIL FNAMES=OUT,BUILD=(1,80)
/*


OUT would have:

Code:

AAc 133337 Normal       AREFTREHOST   
AAA 145867 Normal       ABCDEFGHOST   
ABA 713456 Duplex       ABCDEFGHIJT   
AZA 247298 Normal       ADSSSSHDSj9   
BBA 713222 Duplex       ABCDEFGHIJT   
CCC 234567 Single       DHGJF892222   


If that's not what you want, then you need to explain more clearly what you do want with a good example of your input records and the records you expect for output.
Back to top
View user's profile Send private message
dip62001

New User


Joined: 04 Jul 2005
Posts: 12
Location: Pune

PostPosted: Fri Jul 25, 2008 10:22 am    Post subject:
Reply with quote

The above sort is not producing the correct output .
Below is the actual output that is written to OUT DD.
The non-duplicate records are not written to the output.
Please help.
AAA 145867 NORMAL ABCDEFGHOST
AAC 133337 NORMAL AREFTREHOST
ABA 713456 DUPLEX ABCDEFGHIJT
BBA 713222 DUPLEX ABCDEFGHIJT
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Fri Jul 25, 2008 11:50 am    Post subject: Reply to: SORT - I want the output this way
Reply with quote

Dips,

Quote:
The non-duplicate records are not written to the output.


From the output posted by frank i can see the non-duplicates displayed too.

below mentioned are the non-duplicates

Code:
CCC 234567 Single       DHGJF892222
AZA 247298 Normal       ADSSSSHDSj9


Are you not getting this in your output?
Back to top
View user's profile Send private message
dip62001

New User


Joined: 04 Jul 2005
Posts: 12
Location: Pune

PostPosted: Fri Jul 25, 2008 2:29 pm    Post subject:
Reply with quote

No I am not getting this in output.

Only the records where duplicates are present are displayed in the output file
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Fri Jul 25, 2008 2:44 pm    Post subject: Reply to: SORT - I want the output this way
Reply with quote

Dip,

Quote:
Only the records where duplicates are present are displayed in the output file


I tested this and got the desired output. The output is same as that of Frank's.

The Problem could be because of the version used. Could you pls post your JCL and the version used?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Jul 25, 2008 9:00 pm    Post subject:
Reply with quote

Dip,

I suspect you did NOT copy my latest job correctly. For example, I changed FIRSTDUP to FIRST - did you? If you are still using FIRSTDUP, then you would only get the duplicate records, whereas my job with FIRST gets the duplicate and nonduplicate records. Check your job against my latest job. If it looks different, fix it. If it looks the same, post your job and the TOOLMSG and DFSMSG messages you receive when you run it.
Back to top
View user's profile Send private message
dip62001

New User


Joined: 04 Jul 2005
Posts: 12
Location: Pune

PostPosted: Thu Aug 07, 2008 4:07 pm    Post subject:
Reply with quote

Hi

The above logic is going wrong somewhere. If I execute for the below input:


ABC 02087 B MMMMMMMMMS0
ABC 02087 C PPPPPPPPPST
ABC 15050 A LMMMMMMMM2T
ABC 15247 D FRRRRRRRR2T
ABC 15247 F FCCCCCCCCS0
ABC 15447 R FTTTTTTTTT0
ABC 15447 U FGGGGGGGGGT
SSS 11111 N AAAAAAAAAAA
SSS 15687 I JDDDDDDDDD0
SSS 15687 O JNNNNNNNN2C
TTT 15887 O PCCCCCCCCC0
TTT 15887 P PAAAAAAAA29
WWW 16048 K FDDDDDDDDD0
WWW 16287 J WUUUUUUUUU0


It gives me the below output:
ABC 02087 C PPPPPPPPPST
ABC 15247 D FRRRRRRRR2T
ABC 15447 U FGGGGGGGGGT
SSS 15687 I JDDDDDDDDD0
TTT 15887 O PCCCCCCCCC0

The below records are missing:
SSS 11111 N AAAAAAAAAAA
ABC 15050 A LMMMMMMMM2T
WWW 16048 K FDDDDDDDDD0
WWW 16287 J WUUUUUUUUU0

Please help me .This is very urgent.
Back to top
View user's profile Send private message
dip62001

New User


Joined: 04 Jul 2005
Posts: 12
Location: Pune

PostPosted: Thu Aug 07, 2008 5:59 pm    Post subject:
Reply with quote

the output is the correct one now...
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Thu Aug 07, 2008 10:03 pm    Post subject:
Reply with quote

dip62001,

Can you please post here the card you used? Did you modify the card to get the desired output?.

Thanks,
Arun
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 Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts Syncsort - Hard coded Value in output PORYES SYNCSORT 1 Thu Nov 03, 2016 9:23 am
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


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