Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Help with WHEN=GROUP,BEGIN=

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Thu Jul 24, 2014 12:34 pm    Post subject: Help with WHEN=GROUP,BEGIN=
Reply with quote

I have below input record
Code:

----+----1----+
BLUEJAY     10
BLUEJAY     20
BLUEJAY     60
BLUEJAY     60
RAVEN       10
RAVEN       20
RAVEN       60
FINCH       10
FINCH       60
FINCH       60
FINCH       60
FINCH       60
BLUEJAY     60
SPARROW     60
SPARROW     60
EAGLE       60
EAGLE       60
CROW        10
CROW        20
CROW        60
CROW        60


Records are in group with position (1,12) being the key field for each group. Group starts with' 10' and ends with '60' in position (13,2).
Group can have multiple '60' type records and the last 60 type records will be the end of group.
So, below BLUEJAY is a group.
Code:

BLUEJAY     10
BLUEJAY     20
BLUEJAY     60
BLUEJAY     60


However , BLUEJAY at 13th record does not have any record type 10, but only 60 type record.

My requirement is to identify all such records which does not have a 10 type record , but they have only 60 type record.

So my output will be as below -

Code:

BLUEJAY     60
SPARROW     60
SPARROW     60
EAGLE       60
EAGLE       60


i have tried a lot of but unable to figure out to get this done.
Any help will be highly appreciated.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Thu Jul 24, 2014 2:17 pm    Post subject: Reply to: Help with WHEN=GROUP,BEGIN=
Reply with quote

You can have multiple conditions on on BEGIN. You can have multiple IFTHEN=(WHEN=GROUP. You can have IFTHEN=(WHEN=INIT to do something unconditionally.

If you use your existing GROUP but include a SEQ, you can establish a second group where the SEQ-field is equal to one, and the record-type is not equal to ten. Push a flag to indicate those. Since you can't PUSH a constant, add the flag to the temporarily extended record first, then PUSH that to a new position. You should then be able to identify individual, or groups of, disconnected 60s. Except in one situation.

This is where a 60 is actually disconnected (however that happened) but is coincidentally adjactend to a 10 or another 60 for the same referenece. See if you can create those, then see if you can identify them.
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 159
Location: Chennai

PostPosted: Fri Jul 25, 2014 12:36 am    Post subject: Reply to: Help with WHEN=GROUP,BEGIN=
Reply with quote

Here is the code for you.

Code:

//S1 EXEC PGM=SORT       
//SYSOUT DD SYSOUT=*     
//SORTIN DD *             
BLUEJAY     10           
BLUEJAY     20           
BLUEJAY     60           
BLUEJAY     60           
RAVEN       10           
RAVEN       20           
RAVEN       60           
FINCH       10           
FINCH       60           
FINCH       60           
FINCH       60           
FINCH       60           
BLUEJAY     60           
SPARROW     60           
SPARROW     60           
EAGLE       60                                                       
EAGLE       60                                                       
CROW        10                                                       
CROW        20                                                       
CROW        60                                                       
CROW        60                                                       
/*                                                                   
//SORTOUT DD SYSOUT=*                                               
//SYSIN DD *                                                         
  INREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,12),END=(14,2,ZD,LE,61),     
               PUSH(15:1,12)),                                       
        IFTHEN=(WHEN=GROUP,BEGIN=(15,1,CH,NE,C' '),                 
               END=(13,2,CH,NE,C'60'),                               
               PUSH(35:ID=1))                                       
  OPTION COPY                                                       
  OUTFIL INCLUDE=((15,1,CH,NE,C' ',                                 
                 AND,13,2,CH,NE,C'10'),OR,(35,1,CH,NE,C' ',         
                 AND,13,2,CH,NE,C'10')),                             
         BUILD(1,14)                                                 
/*                                                                   


Hope this helps...
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 159
Location: Chennai

PostPosted: Fri Jul 25, 2014 11:28 am    Post subject: Reply to: Help with WHEN=GROUP,BEGIN=
Reply with quote

FYI..
PUSH(15:1,12)), or PUSH(15:ID=1)), both will work.
PUSH(15:ID=1)) is better..

Thanks
Magesh
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Fri Jul 25, 2014 5:52 pm    Post subject: Reply to: Help with WHEN=GROUP,BEGIN=
Reply with quote

magesh23586,

Your code works, here's a simplification:

Code:
 OPTION COPY
 INREC IFTHEN=(WHEN=GROUP,
                 KEYBEGIN=(1,12),
                 RECORDS=1,
                 PUSH(15:1,12)),
       IFTHEN=(WHEN=GROUP,
                 BEGIN=(15,1,CH,NE,C' ',
                       AND,
                        13,2,CH,EQ,C'60'),
                 END=(13,2,CH,NE,C'60'),
                 PUSH(35:ID=1))
 OUTFIL OMIT=(35,1,CH,EQ,C' ',
             OR,
              13,2,CH,NE,C'60'),
        BUILD(1,14)


Your first GROUP will always end after one record, it is marking the first of a group. So use RECORDS=1, not END= (where did you get LE,C'61' from?).

The GROUPs we are interested in are those that start with 60, so the second GROUP can be limited to that. This will simplify the OUTFIL. The "end" of the GROUP can, however, go beyond the key, but not a problem, so we need to deal with that.

Using OMIT= makes the OUTFIL easier to follow. Now excludes all records not marked by the second GROUP, and those marked by the second GROUP which are not 60.

The ID=1 is fine for the first GROUP, and the second, because all we need to know is ID or not ID, it does not matter if it overflows (more than nine groups).

techslam,

To see how this is working, comment out the entire OUTFIL.

Once you are happy that you understand it, you can change the first PUSH to an ID=1 and change the location of the second PUSH to immediately after that ID, and change the position of the OMIT= to that position (16 in the example).

Assuming you are trying to find data errors, remember that it might be possible for a 60 to coincidentally appear in the "right" place, and it will not be possible to code for that from what we know. If there is something somewhere which tells how many 60s there should be for a 10, that should be included in this.
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 159
Location: Chennai

PostPosted: Sat Jul 26, 2014 11:16 am    Post subject: Reply to: Help with WHEN=GROUP,BEGIN=
Reply with quote

Bill Woodger wrote:
Your first GROUP will always end after one record, it is marking the first of a group. So use RECORDS=1, not END= (where did you get LE,C'61' from?).


LE,C'61' is just a negative condition to stop/end with one record, RECORDS=1 does the same, Thanks for the suggestion. I was little rush while coding doesn't strike to me.

Bill Woodger wrote:
Using OMIT= makes the OUTFIL easier to follow. Now excludes all records not marked by the second GROUP, and those marked by the second GROUP which are not 60.


I don't recommend OMIT, Its always confusing.
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 Group Data based on a key Arun Raj DFSORT/ICETOOL 4 Thu Apr 27, 2017 11:29 pm
No new posts Need Help with : IFTHEN(WHEN=GROUP) Sumanta_89 DFSORT/ICETOOL 1 Wed Apr 19, 2017 5:23 pm
No new posts Group elements using ICETOOL Learncoholic DFSORT/ICETOOL 2 Fri Apr 14, 2017 11:01 am
No new posts Why TS/OP would Not contact site supp... RahulG31 All Other Mainframe Topics 4 Wed Mar 22, 2017 7:46 am
No new posts Sorting group data rajella DFSORT/ICETOOL 4 Sun Jan 22, 2017 11:32 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us