Joined: 21 May 2010 Posts: 4 Location: Düsseldorf, Germany
I have the following problem.
My dataset (parts list) has following format
Key-1 1:11 (product)
BeginDate 25:08
Key-2 44:11 (part)
Assume a record length 54.
The dataset is sorted (1,11,CH,A,44,11,CH,A,25,8,CH,D), but of course it is no problem to sort it in another way. Also it is no problem to create a reference dataset and to join (for example). Or we change the order of columns. There is no limitation :-)
The dataset has following content
Code:
Key-1 BeginDate Key-2
1 2 3 4 5
12345678901234567890123456789012345678901234567890123456789
A1111111111|any data |20100301|any data|M2222222222
A1111111111|any data |20090215|any data|M2222222222
A1111111111|any data |20010922|any data|M2222222222
A1111111111|any data |20010922|any data|N2222222222
B1111111111|any data |20100301|any data|M2222222222
B1111111111|any data |20010922|any data|M2222222222
B1111111111|any data |20100301|any data|O2222222222
B1111111111|any data2 |20100301|any data|O2222222222
B1111111111|any data |20010922|any data|O2222222222
B1111111111|any data2 |20010922|any data|O2222222222
C1111111111|any data |20010922|any data|N2222222222
C1111111111|any data |20010922|any data|O2222222222
C1111111111|any data |20010922|any data|P2222222222
I have to add the EndDate, it should look like
Code:
Key-1 BeginDate Key-2 EndDate
1 2 3 4 5
12345678901234567890123456789012345678901234567890123456789
A1111111111|any data |20100301|any data|M2222222222|*no end*
A1111111111|any data |20090215|any data|M2222222222|20100301
A1111111111|any data |20010922|any data|M2222222222|20010922
A1111111111|any data |20010922|any data|N2222222222|*no end*
B1111111111|any data |20100301|any data|M2222222222|*no end*
B1111111111|any data |20010922|any data|M2222222222|20100301
B1111111111|any data |20100301|any data|O2222222222|*no end*
B1111111111|any data2 |20100301|any data|O2222222222|*no end*
B1111111111|any data |20010922|any data|O2222222222|20100301
B1111111111|any data2 |20010922|any data|O2222222222|20100301
C1111111111|any data |20010922|any data|N2222222222|*no end*
C1111111111|any data |20010922|any data|O2222222222|*no end*
C1111111111|any data |20010922|any data|P2222222222|*no end*
The rule to get end date is very simple:
- If the actual record has another key-1 *or* another key-2 as the record above, than we have the first record of the product or the first record of a part of the product, and we have no EndDate,
- If the actual record has same key-1 and same key-2 as the record above and the same BeginDate, we have variant of the product part above, and we get the same (or no) EndDate as the record above (see example "any data2")
- If the actual record has same key-1 and same key-2 as the record above and a lower BeginDate, set EndDate := BeginDate of the record above
Is it possible to solve using ICEMAN?
My problem is the missing instruction of
IFTHEN=(WHEN=GROUP,BEGIN=(key1 change,OR,key2 change),...)
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
Jochen Matthes,
The following DFSORT JCL will give you the desired results. I think I covered most of the scenarios, but let me know if I missed any. btw your sample data shows the DATE field at pos 26 but in your layout you mentioned it at pos 25. So I took pos 25 as the start of date field
The output from this is a 63 byte file with the following contents
Code:
A1111111111|ANY DATA |20100301|ANY DATA |M2222222222|**NOEND*
A1111111111|ANY DATA |20090215|ANY DATA |M2222222222|20100301
A1111111111|ANY DATA |20010922|ANY DATA |M2222222222|20090215
A1111111111|ANY DATA |20010922|ANY DATA |N2222222222|**NOEND*
B1111111111|ANY DATA |20100301|ANY DATA |M2222222222|**NOEND*
B1111111111|ANY DATA |20010922|ANY DATA |M2222222222|20100301
B1111111111|ANY DATA |20100301|ANY DATA |O2222222222|**NOEND*
B1111111111|ANY DATA2 |20100301|ANY DATA |O2222222222|**NOEND*
B1111111111|ANY DATA |20010922|ANY DATA |O2222222222|20100301
B1111111111|ANY DATA2 |20010922|ANY DATA |O2222222222|20100301
C1111111111|ANY DATA |20010922|ANY DATA |N2222222222|**NOEND*
C1111111111|ANY DATA |20010922|ANY DATA |O2222222222|**NOEND*
C1111111111|ANY DATA |20010922|ANY DATA |P2222222222|**NOEND*
Joined: 21 May 2010 Posts: 4 Location: Düsseldorf, Germany
Dear Skolusu,
your solution runs, thank you!
I have transfered the solution to the real problem (the record has a longer LRECL), and haven't found any error. (But there are about 100,000 records, and I didn't scroll through ...)
The main idea is "RECORDS=2"! That avoids, that a date is pushed into all following records.
Now, I'll simplify the solution and (i.e.) put column 44 beside column 1.
But, nevertheless, there is missing a instruction to detect change of group key directly, isn't it? O.k., perhaps next PTF ...
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
Jochen Matthes wrote:
But, nevertheless, there is missing a instruction to detect change of group key directly, isn't it? O.k., perhaps next PTF ...
Perhaps you would like to be more specific?
What instruction are you missing?
What was not to your specifications with the solution?
PTFs can not be proposed without some lack specified.....
Joined: 21 May 2010 Posts: 4 Location: Düsseldorf, Germany
The solution above is o.k. and runs and I'm happy. That is not my problem.
My problem is a suggestion:
If the BEGIN of a group is a specific constant, it is very simple to write
Code:
IFTHEN=(WHEN=GROUP,BEGIN=(001,003,CH,EQ,C'ABC'))
(for example)
But if the BEGIN of the group is the change of the key (in my example, when ABC changes to ABD) itself, then there are tricky constructions necessary with a SEQNUM and a RESTART of it, when the key changes.
It would be more simple (and would be easier to understand when reading) to have an instruction