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

Sort group of records between header and trailer


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Sathish Gurumoorthy

New User


Joined: 12 Feb 2009
Posts: 33
Location: Chennai, India

PostPosted: Thu Feb 12, 2009 4:17 pm
Reply with quote

Hi!
I have a requirement like below. Can anyone pls help me to get this done.
My input file has a format which looks like below.

1 to 4 - lot 9(7) comp-3 5 to 7 - sku 9(4) comp-3
8 - rec code pic9 9 to 10 - dc pic 99
17 to 21 - supplier 9(9) comp-3

1 5 8 9 11 15 17 22 25 100
0000000|0000|0|00| |xxxxxxxxxxxx - header
103531 |18 |2|04|xxxxxxx|xxx|6452700|xxxxxxxxx - SKU rec
103531 |10 |2|04|xxxxxxx|xxx|6452700|xxxxxxxxx - SKU rec
103531 |34 |2|04|xxxxxxx|xxx|6452700|xxxxxxxxx - SKU rec
103531 |182 |2|04|xxxxxxx|xxx|6452700|xxxxxxxxx - SKU rec
103531 | |1|04|xxxxxxx|xxx|6452700|xxxxxxxxx - Lot rec
115540 |34 |2|04|xxxxxxx|xxx|6452700|xxxxxxxxx - SKU rec
115540 |20 |2|04|xxxxxxx|xxx|6452700|xxxxxxxxx - SKU rec
115540 |56 |2|04|xxxxxxx|xxx|6452700|xxxxxxxxx - SKU rec
115540 | |1|04|xxxxxxx|xxx|6452700|xxxxxxxxx - Lot rec
..............
..............
9999999|9999|9|xxxxxxxxxxxxxx - trailer

similarly i have 3 more input files with DC no(pos 9 to 10) varies. There can be same lot no for more than input DC files. There is one DC no for one file.
Now, i need to sort the 4 files based on LOT/DC/SKU/Supplier and write into an output file.
can anyone help on this? Thanks.
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 Feb 12, 2009 10:07 pm
Reply with quote

I can't really figure out what you want to do. Are the "groups" in your Subject line the records in each file (between the file header and file trailer) or the records in the "lots" (not sure what such a group would be) or what?

Show example records from all four input files (relevant fields only) and what you expect for output. Explain the "rules" for getting from input to output and what you mean by a "group". Give the RECFM and LRECL of the input file.

Please use ubb code tags to line up the fields in the examples correctly (use Preview until you get it right).
Back to top
View user's profile Send private message
Sathish Gurumoorthy

New User


Joined: 12 Feb 2009
Posts: 33
Location: Chennai, India

PostPosted: Fri Feb 13, 2009 11:07 am
Reply with quote

my input files looks like below.

LRECL = 100 for all types of records. RECFM = FB
size of each field is (in the order it follows in the i/p file)
lot pic 9(7) comp-3
sku pic 9(4) comp-3
rec code pic 9
dc no pic 99
po pic 9(7) comp-3
supplier pic 9(9) comp-3
input file 1:

0000000 0000 0 04 xxxxxxxxxxxxxxxxxxxxxxxxx - header for dc 4
lot1 sku3 2 04 po shipkey supplier - sku rec
lot1 sku2 2 04 po shipkey supplier - sku rec
lot1 sku1 2 04 po shipkey supplier - sku rec
lot1 sku0 1 04 po shipkey supplier - lot rec
lot3 sku2 2 04 po shipkey supplier - sku rec
lot3 sku1 2 04 po shipkey supplier - sku rec
lot3 sku0 1 04 po shipkey supplier - lot rec
9999999 9999 9 xxxxxxxxxxxxxxxxxxxxxxxxxxxx - trailer for dc 4

input file 2:
0000000 0000 0 02 xxxxxxxxxxxxxxxxxxxxxxxxx - header for dc 2
lot3 sku1 2 02 po shipkey supplier - sku rec
lot3 sku3 2 02 po shipkey supplier - sku rec
lot3 sku2 2 02 po shipkey supplier - sku rec
lot3 sku0 1 02 po shipkey supplier - lot rec
lot2 sku1 2 02 po shipkey supplier - sku rec
lot2 sku2 2 02 po shipkey supplier - sku rec
lot2 sku0 1 02 po shipkey supplier - lot rec
9999999 9999 9 xxxxxxxxxxxxxxxxxxxxxxxxxxxx - trailer for dc 2

input file 3:
0000000 0000 0 03 xxxxxxxxxxxxxxxxxxxxxxxxx - header for dc 3
lot1 sku1 2 03 po shipkey supplier - sku rec
lot1 sku3 2 03 po shipkey supplier - sku rec
lot1 sku2 2 03 po shipkey supplier - sku rec
lot1 sku0 1 03 po shipkey supplier - lot rec
lot2 sku1 2 03 po shipkey supplier - sku rec
lot2 sku2 2 03 po shipkey supplier - sku rec
lot2 sku0 1 03 po shipkey supplier - lot rec
9999999 9999 9 xxxxxxxxxxxxxxxxxxxxxxxxxxxx - trailer for dc 3

my ouyput file should be the one like below.

0000000 0000 0 02 xxxxxxxxxxxxxxxxxxxxxxxxx - header for dc 2
0000000 0000 0 03 xxxxxxxxxxxxxxxxxxxxxxxxx - header for dc 3
0000000 0000 0 04 xxxxxxxxxxxxxxxxxxxxxxxxx - header for dc 4
lot1 sku0 1 03 po shipkey supplier - lot rec
lot1 sku1 2 03 po shipkey supplier - sku rec
lot1 sku2 2 03 po shipkey supplier - sku rec
lot1 sku3 2 03 po shipkey supplier - sku rec
lot1 sku0 1 04 po shipkey supplier - lot rec
lot1 sku1 2 04 po shipkey supplier - sku rec
lot1 sku2 2 04 po shipkey supplier - sku rec
lot1 sku3 2 04 po shipkey supplier - sku rec
lot2 sku0 1 02 po shipkey supplier - lot rec
lot2 sku1 2 02 po shipkey supplier - sku rec
lot2 sku2 2 02 po shipkey supplier - sku rec
lot2 sku0 1 03 po shipkey supplier - lot rec
lot2 sku1 2 03 po shipkey supplier - sku rec
lot2 sku2 2 03 po shipkey supplier - sku rec
lot3 sku0 1 02 po shipkey supplier - lot rec
lot3 sku1 2 02 po shipkey supplier - sku rec
lot3 sku2 2 02 po shipkey supplier - sku rec
lot3 sku3 2 02 po shipkey supplier - sku rec
lot3 sku0 1 04 po shipkey supplier - lot rec
lot3 sku1 2 04 po shipkey supplier - sku rec
lot3 sku2 2 04 po shipkey supplier - sku rec
9999999 9999 9 xxxxxxxxxxxxxxxxxxxxxxxxxxxx - trailer for dc 2
9999999 9999 9 xxxxxxxxxxxxxxxxxxxxxxxxxxxx - trailer for dc 3
9999999 9999 9 xxxxxxxxxxxxxxxxxxxxxxxxxxxx - trailer for dc 4

the output file should be sorted in LOT/DC/REC CODE/SKU order.
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 Feb 13, 2009 10:34 pm
Reply with quote

This seems like a pretty straightforward sort. Here's a DFSORT job that will do what you asked for:

Code:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file1 (FB/100)
//       DD DSN=...  input file2 (FB/100)
//       DD DSN=...  input file3 (FB/100)
//SORTOUT DD DSN=...  output file (FB/100)
//SYSIN    DD    *
  SORT FIELDS=(1,4,PD,A,9,2,CH,A,8,1,CH,A,5,3,PD,A)
/*
Back to top
View user's profile Send private message
Sathish Gurumoorthy

New User


Joined: 12 Feb 2009
Posts: 33
Location: Chennai, India

PostPosted: Tue Feb 17, 2009 10:30 am
Reply with quote

Thanks Frank. But how to get all the headers at top and trailers at bottom as in the output file.
Back to top
View user's profile Send private message
shanuss

New User


Joined: 16 Jul 2008
Posts: 17
Location: Chennai

PostPosted: Tue Feb 17, 2009 9:19 pm
Reply with quote

Frank,

Can this be accomplished by altering the collating sequence? I could not recollect exaclty how this can be done. Can you please help me?
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: Tue Feb 17, 2009 11:11 pm
Reply with quote

sathish,

Your example shows the headers with a PD 0 value in positions 1-4 and the trailers with a PD 9999999 value in positions 1-4. I assumed 0 was lower than any lot number and 9999999 was higher than any lot number. So sorting on 1,4 PD would automatically put the headers at the top and trailers at the bottom.

If that's not happening, then you need to show me an example of what the values in 1-4 for the headers, lot numbers and trailers actually look like (in hex).
Back to top
View user's profile Send private message
Sathish Gurumoorthy

New User


Joined: 12 Feb 2009
Posts: 33
Location: Chennai, India

PostPosted: Wed Feb 18, 2009 9:20 am
Reply with quote

Thanks Frank. I got it icon_smile.gif
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 Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
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
Search our Forums:

Back to Top