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

ICEMAN: How to detect the BEGIN of a group (variable content


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

New User


Joined: 21 May 2010
Posts: 4
Location: Düsseldorf, Germany

PostPosted: Fri Jul 16, 2010 5:29 pm
Reply with quote

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),...)

Thank you!

Regards from Germany
Jochen
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Jul 16, 2010 10:34 pm
Reply with quote

Jochen Matthes,

Your rules seem to contradict the output you show. How come this record have an end date of 20010922 ? Shouldn't it be 20090215?
Code:

A1111111111|any data    |20010922|any data|M2222222222|20010922
Back to top
View user's profile Send private message
Jochen Matthes

New User


Joined: 21 May 2010
Posts: 4
Location: Düsseldorf, Germany

PostPosted: Fri Jul 16, 2010 10:42 pm
Reply with quote

Hello Skolusu,
sorry, you're right (and you understood the rule)!

the result must be

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|20090215 <==
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*


I hope, there are not more errors :-(
Regards,
Jochen
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Sat Jul 17, 2010 2:19 am
Reply with quote

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

Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=* 
//SORTIN   DD DSN=your input fb 54 file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                       
  SORT FIELDS=(1,11,CH,A,44,11,CH,A,25,08,CH,D),EQUALS                 
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(56:1,11,44,11)),                   
  IFTHEN=(WHEN=INIT,OVERLAY=(79:SEQNUM,8,ZD,RESTART=(56,22))),         
  IFTHEN=(WHEN=GROUP,BEGIN=(79,8,ZD,EQ,1),PUSH=(88:25,8),RECORDS=2),   
  IFTHEN=(WHEN=GROUP,PUSH=(97:25,8),RECORDS=2,                         
  BEGIN=(79,8,ZD,GT,1,AND,88,8,CH,NE,25,8,CH,AND,88,8,CH,GT,C' ')),   
  IFTHEN=(WHEN=GROUP,PUSH=(97:25,8),RECORDS=2,                         
  BEGIN=(79,8,ZD,GT,1,AND,88,8,CH,EQ,25,8,CH,AND,97,8,CH,EQ,C' ')),   
  IFTHEN=(WHEN=GROUP,PUSH=(97:97,8),RECORDS=2,                         
  BEGIN=(79,8,ZD,GT,1,AND,88,8,CH,EQ,C' ',AND,97,8,CH,GT,C' ')),       
  IFTHEN=(WHEN=(79,8,ZD,EQ,1,AND,88,8,CH,EQ,25,8,CH),                 
  OVERLAY=(106:C'**NOEND*')),                                         
  IFTHEN=(WHEN=(79,8,ZD,GT,1,AND,88,8,CH,EQ,C' ',AND,97,8,CH,GT,C' '),
  OVERLAY=(106:97,8)),                                                 
  IFTHEN=(WHEN=(79,8,ZD,GT,1,AND,88,8,CH,EQ,C' ',AND,97,8,CH,EQ,C' '),
  OVERLAY=(106:C'**NOEND*')),                                         
  IFTHEN=(WHEN=(25,8,CH,EQ,88,8,CH,AND,25,8,CH,EQ,97,8,CH),           
  OVERLAY=(106:C'**NOEND*')),                                         
  IFTHEN=(WHEN=NONE,OVERLAY=(106:88,8))                               
                                                                       
  OUTFIL BUILD=(1,54,C'|',106,8)                                       
//*


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*
Back to top
View user's profile Send private message
Jochen Matthes

New User


Joined: 21 May 2010
Posts: 4
Location: Düsseldorf, Germany

PostPosted: Mon Jul 19, 2010 3:31 am
Reply with quote

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 ...

Regards,
Jochen
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Mon Jul 19, 2010 5:16 am
Reply with quote

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.....
Back to top
View user's profile Send private message
Jochen Matthes

New User


Joined: 21 May 2010
Posts: 4
Location: Düsseldorf, Germany

PostPosted: Mon Jul 19, 2010 3:01 pm
Reply with quote

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

Code:
IFTHEN=(WHEN=GROUP,BEGIN=(001,003,CH,<keychange>,OR,015,004,CH,<keychange>))
(<keychange> would be the missing instruction)
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: Mon Jul 19, 2010 9:12 pm
Reply with quote

Thanks for the suggestion.
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
No new posts Compare latest 2 rows of a table usin... DB2 1
Search our Forums:

Back to Top