NEED HELP IN SORT

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
amolpawar
Member
Posts: 25
Joined: Mon Jun 29, 2009 2:52 pm

NEED HELP IN SORT

Post by amolpawar » Wed Apr 09, 2014 12:08 pm

Hi,

I have a file having length 80.

The file contains records with several record types i.e. 1,2,---8( One byte field only)

Sample Layout

1000 1 abcd -----
1000 2 hjaskdjk ----
2000 3 dfjkdjf dfgfg
2000 5 abcd -----
1000 5 hjaskdjk ----
2000 6 dfjkdjf dfgfg
1000 6 dfjkdjf dfgfg


I want above file to be sorted only for record type 5 for first 4 bytes , rest of the data should be same as input.

Sample output :

1000 1 abcd -----
1000 2 hjaskdjk ----
2000 3 dfjkdjf dfgfg
1000 5 abcd -----
2000 5 hjaskdjk ----
2000 6 dfjkdjf dfgfg
1000 6 dfjkdjf dfgfg

Regards,
Amol

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Wed Apr 09, 2014 2:04 pm

Is the data already in the order of the second field? Can you have multiple records for other record types? Going by the data supplied a simple sort on major key of record type and minor key of the first four bytes should be sufficient. If not, why not?
Regards
Nic

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Wed Apr 09, 2014 11:15 pm

Suggest you repost your examples or clarify how the output came to be . . .

It would help if you defined the fields and used beter values than alphabet soup . . .
Have a good one

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Thu Apr 10, 2014 2:32 am

Use OPTION EQUALS
In INREC, use IFTHEN=(WHEN=(logical expression to identify your type 5s, and OVERLAY=(81:1,4).

SORT on your record-type, followed by the extended field.

Use OUTREC BUILD=(1,80) to return to your original size.

amolpawar
Member
Posts: 25
Joined: Mon Jun 29, 2009 2:52 pm

Post by amolpawar » Thu Apr 10, 2014 2:15 pm

Hi,

I have a file having length 80.

The file contains records with several record types i.e. 1,2,---8( One byte field only)

input

1000 1 Amol
1000 2 Amit
2000 3 Sumit
2000 5 Supriya
1000 5 Rakesh
2000 6 Sarita
1000 6 satish


I want above file to be sorted only for record type 5 for first 4 bytes , rest of the data should be same as input.

Sample output :

1000 1 Amol
1000 2 Amit
2000 3 Sumit
1000 5 Rakesh -- order changed
2000 5 Supriya -- Order changed
2000 6 Sarita
1000 6 satish


There are multiple records for each record type but is it not neccessary to have amount field should be sorted in input file ( Position 1 to 4) , i want to sort on this amount field only for record type 5, rest of the record should be same as sorted on record type.

Regards,
Amol

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Thu Apr 10, 2014 3:08 pm

Did you try what I suggested?

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Thu Apr 10, 2014 7:04 pm

no need to repost your original query - it just 'hides' the additional text.
but is it not neccessary to ...
does this mean that the others must not sorted on bytes 1-4 or does it mean that they can be and no harm is done?
Regards
Nic

amolpawar
Member
Posts: 25
Joined: Mon Jun 29, 2009 2:52 pm

Post by amolpawar » Fri Apr 11, 2014 10:09 am

Yes Nicc, i dont want to sort other record ( other than record type 5) on bytes 1-4.

Regards,
Amol

amolpawar
Member
Posts: 25
Joined: Mon Jun 29, 2009 2:52 pm

Post by amolpawar » Fri Apr 11, 2014 10:37 am

Hi William,

I am trying same, by increasing the record lenth for record type 5 and sorting on extended data and as per requirement , it should work. Thank you !

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others