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: 7225

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: 158
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: 158
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: 7225

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: 158
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 abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm
No new posts Select first 2 group data vice_versa DFSORT/ICETOOL 10 Mon Jun 13, 2016 2:21 pm
No new posts Hookup group of records in multiple p... V S Amarendra Reddy DFSORT/ICETOOL 3 Thu Feb 18, 2016 11:49 pm
No new posts GROUP of undefined number of lines Khadhar Basha DFSORT/ICETOOL 4 Fri Feb 05, 2016 5:15 am


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