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

SORT - I want the output this way


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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: 8797
Location: Welsh Wales

PostPosted: Thu Jul 17, 2008 2:12 pm
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
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
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 Developer


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

PostPosted: Thu Jul 17, 2008 9:11 pm
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
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: 1287
Location: Chennai, India

PostPosted: Fri Jul 18, 2008 12:13 pm
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
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 Developer


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

PostPosted: Fri Jul 18, 2008 9:59 pm
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
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 Developer


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

PostPosted: Fri Jul 25, 2008 4:08 am
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
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: 1287
Location: Chennai, India

PostPosted: Fri Jul 25, 2008 11:50 am
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
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: 1287
Location: Chennai, India

PostPosted: Fri Jul 25, 2008 2:44 pm
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 Developer


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

PostPosted: Fri Jul 25, 2008 9:00 pm
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
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
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: 2481
Location: @my desk

PostPosted: Thu Aug 07, 2008 10:03 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
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