Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
ICEMAN: How to detect the BEGIN of a group (variable content

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: ICEMAN: How to detect the BEGIN of a group (variable content
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    Post subject: Reply to: ICEMAN: How to detect the BEGIN of a group (variab
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    Post subject: contradiction
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    Post subject: Reply to: ICEMAN: How to detect the BEGIN of a group (variab
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    Post subject: Reply to: ICEMAN: How to detect the BEGIN of a group - runs!
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: 3158
Location: Tucson AZ

PostPosted: Mon Jul 19, 2010 5:16 am    Post subject: Re: Reply to: ICEMAN: How to detect the BEGIN of a group - r
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    Post subject: Missing instruction
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 Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Mon Jul 19, 2010 9:12 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Moving a COMP-3 Variable to a Numeric... ajayachander COBOL Programming 2 Thu Dec 14, 2017 5:46 pm
This topic is locked: you cannot edit posts or make replies. Cobol to fetch the content by using s... arunc55 COBOL Programming 4 Fri Nov 17, 2017 1:25 pm
No new posts Increment number for every group of r... srajendran2 DFSORT/ICETOOL 7 Thu Nov 09, 2017 10:31 pm
No new posts Move from Comp3 variable to Edited Va... Revathy.nair0485 COBOL Programming 7 Fri Nov 03, 2017 3:30 pm
This topic is locked: you cannot edit posts or make replies. Can a alphanumeric data be moved to a... nico_neoz COBOL Programming 10 Mon Oct 30, 2017 8:28 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us