View previous topic :: View next topic
|
Author |
Message |
nanny
New User
Joined: 13 Jun 2006 Posts: 14 Location: India
|
|
|
|
Below are the input records,
Code: |
H010000100100XXXXXXXXXXX 0001
H020000100200XXXXXXXXXXX 0002
H030000100300XXXXXXXXXXX 0003
F010000000 0000
W0100000000000000000000 0004
W0200000000000000000000 0005
H010000200400xxxxxxxxxxxx0006
H020000200400XXXXXXXXXXX 0007
W01111111111111111111 0008
H010000300500 0009 |
My Requirement is as follows..
Code: |
1. Sort Based on the last 4 characters of the Sequence Number
2. Group the H records of a specific category
Ex. First 3 H records are belongs the one category (1 st byte is H and
5 bytes starting from 4 th position is 00001)
in this case we have to get one H record (Seq. No 0003) and 2nd
and 3rd records are added to the first.
Output: H010000100600XXXXXXXXXXX0001
H records with the sequence number 0006 and 0007 are of one
category
Output: H010000200800xxxxxxxxxxxx0006
H record with the sequence number 0009 is another category
So, in the final output there will be 3 H records. |
Final Output will be
Code: |
F010000000 0000
H010000100600XXXXXXXXXXX 0001
W0100000000000000000000 0004
W0200000000000000000000 0005
H010000200800xxxxxxxxxxxx0006
W01111111111111111111 0008
H010000300500 0009 |
We have one solution,
1. Split H records into one file (File 1) and other records into the second file (File 2)
2. Sort and Sum H records from File 1 into File 3 as required
3. Merge File 3 and File 2 and SORT based on the Sequence Number
Above will take 3 job steps,
Can we achieve the above in 1 step or 2 steps ?
Thanks in advance for your time and Effort..
Thanks,
nanny.
Code'd and unpickling of sequence number attempted |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Will the sequence number be at any position of a record?? |
|
Back to top |
|
|
nanny
New User
Joined: 13 Jun 2006 Posts: 14 Location: India
|
|
|
|
Sequence Number Position is Fixed (Last 4 Bytes) and the file is Fixed Record Length File. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Can you please post the input data in code tags ?? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Yes, please use the Code tags in future, and the Preview button to ensure that things line-up how you want them to.
When you say "merge and SORT" what would be the problem in actually using MERGE? Probably doesn't matter for a solution to your requirement, as it can probably be done in one step. |
|
Back to top |
|
|
nanny
New User
Joined: 13 Jun 2006 Posts: 14 Location: India
|
|
|
|
You are right. Sorry for the inconvenience caused. Will use code tags going forward.
What I mean to say is,
1. Will separate the input file into two files based on H records and other records.
2. Sort the H records (one H record per category and field values from duplicate records will be added).
3. Sort the above H record's sorted file and other records file based on the Sequence number to produce a single output file.
(As we are merging two files and applying the SORT on sequence number i used the word Merge and SORT...)
As, above takes 3 steps, Is it possible to implement all the above one step or may be in two steps...! |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Can you post the ICE201I message from the sysout one of your Sort steps please.
You have one "F" record which is out-of-sequence. Can any of the "H" records be out-of-sequence? |
|
Back to top |
|
|
nanny
New User
Joined: 13 Jun 2006 Posts: 14 Location: India
|
|
|
|
Bill,
Here F record is not out of the sequence. Its sequence number is 0000 and this makes where ever F records present in the input file, in the final output
F record will be written at the beginning (i.e. first record).
Below is the ICE201I message displayed on the spool..
ICE201I 0 RECORD TYPE IS F - DATA STARTS IN POSITION 1 |
|
Back to top |
|
|
nanny
New User
Joined: 13 Jun 2006 Posts: 14 Location: India
|
|
|
|
Currently I am using the below code..
Code: |
//STEP0001 EXEC PGM=SORT
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FILES=01,INCLUDE=(1,1,CH,EQ,C'H')
OUTFIL FILES=02,INCLUDE=(1,1,CH,EQ,C'W',OR,1,1,CH,EQ,C'F',OR,
1,1,CH,EQ,C'J')
/*
//*
//STEP0002 EXEC PGM=SORT
//SYSIN DD *
SORT FIELDS=(4,5,CH,A),EQUALS
SUM FIELDS=(9,5,ZD)
/*
//*
//STEP0003 EXEC PGM=SORT
//SYSIN DD *
SORT FIELDS=(26,4,CH,A)
SUM FIELDS=NONE
/*
//* |
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
That ICE201I means you are very out-of-date with your DFSORT. Your site is missing out on many useful functions available since then. This will probably limit your solution.
Please refer to this and post the full sysout from the step shown at the end.
Try the functions which Frank mentioned to see what you have available. |
|
Back to top |
|
|
nanny
New User
Joined: 13 Jun 2006 Posts: 14 Location: India
|
|
|
|
Bill,
The other machine, I am using has the below ICE201I message
ICE201I H RECORD TYPE IS F - DATA STARTS IN POSITION 1
Seems, this had the latest patch installed. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Code: |
OPTION COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(1:SEQNUM,1,ZD)) |
You could try that to see if you have 2004 and something which may help. |
|
Back to top |
|
|
nanny
New User
Joined: 13 Jun 2006 Posts: 14 Location: India
|
|
|
|
Bill,
I think your solution will give me the Sequence number at the first byte..
correct me if i am wrong...!
I am looking for the solution to have two different sort conditions in one single job step... |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Nanny,
I am not at the moment trying to provide you with a solution. I am trying to find out what functions you have available with your out-of-date and out-of-support version of DFSORT.
I am not going to attempt/suggest anything for you to turn around and say "nope, that gives me a syntax error", as that is just a waste of time for everyone.
Knowing that you don't have JOINKEYS, my earlier question is moot, but, on your INPUT the F is out of sequence as far as the sequence number is concerned. I fully understand that if you SORT on that sequence number, the position of the record will change. What I wanted to know was, are there any examples of you H records, on the INPUT, not being in ascending order given that there was already an example, the F, of your input not being in sequence number order?
As I say, the answer no longer matters. |
|
Back to top |
|
|
nanny
New User
Joined: 13 Jun 2006 Posts: 14 Location: India
|
|
|
|
Bill,
Thanks for your timely responses.
also the other machine, I am using has the below ICE201I message
ICE201I H RECORD TYPE IS F - DATA STARTS IN POSITION 1
Seems, this had the latest patch installed.
So we may use all the possible functions.
Code: |
Most of the times H records are in sequence and also while grouping we will consider the H record with the least sequence number as base and all the duplicate record's field values are added to that.
For Example:
H010000100100XXXXXXXXXXX 0001
H020000100200XXXXXXXXXXX 0002
H030000100300XXXXXXXXXXX 0003
For the above 3 H records, H record with the sequence number 0001 taken as base and the final output will be
H010000100600XXXXXXXXXXX 0001
|
|
|
Back to top |
|
|
nanny
New User
Joined: 13 Jun 2006 Posts: 14 Location: India
|
|
|
|
Hi,
Any suggestions on this ...? |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
try these control cards.
Code: |
//SYSIN DD *
INREC IFOUTLEN=30,IFTHEN=(WHEN=INIT,
OVERLAY=(31:26,4,X,1,1,4,5,X,SEQNUM,3,ZD,RESTART=(36,6))),
IFTHEN=(WHEN=GROUP,BEGIN=(36,1,CH,EQ,C'H',AND,43,3,ZD,EQ,1),
PUSH=(26:26,4)),
IFTHEN=(WHEN=(36,1,CH,NE,C'H'),OVERLAY=(26:31,4))
SORT FIELDS=(26,4,CH,A)
SUM FIELDS=(9,5,ZD)
//* |
|
|
Back to top |
|
|
nanny
New User
Joined: 13 Jun 2006 Posts: 14 Location: India
|
|
|
|
Thanks a lot.
Its working. |
|
Back to top |
|
|
|