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

Select first 2 group data


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vice_versa
Warnings : 1

New User


Joined: 26 Feb 2006
Posts: 19
Location: usa

PostPosted: Mon Jun 13, 2016 2:21 pm
Reply with quote

Hi All,

I have a file like below,Every Transaction have serveral Task,Every Task
Have different line.Now I only select every transaction first 2 Task。
how to achieve below desired result.
Thanks in advance。
input:
Code:
Tran1TASK1LINE01
Tran1TASK1LINE02
Tran1TASK1LINE03
Tran1TASK1LINE04
Tran1TASK1LINE05
Tran1TASK2LINE01
Tran1TASK2LINE02
Tran1TASK2LINE03
Tran1TASK2LINE04
Tran1TASK2LINE05
Tran1TASK3LINE01
Tran1TASK3LINE02
Tran1TASK3LINE03
Tran1TASK3LINE04
Tran1TASK3LINE05
Tran1TASK3LINE06
Tran1TASK3LINE07
Tran1TASK3LINE08
Tran1TASK3LINE09
Tran1TASK3LINE10
Tran2TASK1LINE01
Tran2TASK1LINE02
Tran2TASK1LINE03
Tran2TASK1LINE04
Tran2TASK1LINE05
Tran2TASK2LINE06
Tran2TASK2LINE01
Tran2TASK2LINE02
Tran2TASK2LINE03


output:
Code:
Tran1TASK1LINE01
Tran1TASK1LINE02 
Tran1TASK1LINE03 
Tran1TASK1LINE04 
Tran1TASK1LINE05 
Tran1TASK2LINE01
Tran1TASK2LINE02
Tran1TASK2LINE03
Tran1TASK2LINE04
Tran1TASK2LINE05
Tran2TASK1LINE01 
Tran2TASK1LINE02 
Tran2TASK1LINE03 
Tran2TASK1LINE04 
Tran2TASK1LINE05 
Tran2TASK2LINE06 
Tran2TASK2LINE01
Tran2TASK2LINE02
Tran2TASK2LINE03
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Mon Jun 13, 2016 3:04 pm
Reply with quote

just include task1 and task2, isn't that what you want?
Back to top
View user's profile Send private message
vice_versa
Warnings : 1

New User


Joined: 26 Feb 2006
Posts: 19
Location: usa

PostPosted: Mon Jun 13, 2016 3:24 pm
Reply with quote

Rohit Umarjikar wrote:
just include task1 and task2, isn't that what you want?


Yes,For each transaction,Only select first 2 task.
task1 and task2 is comp-3 data
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Mon Jun 13, 2016 3:35 pm
Reply with quote

INCLUDE
Filter out rest all and only include task1 and task2 which meant for all the transactions indded.
Back to top
View user's profile Send private message
vice_versa
Warnings : 1

New User


Joined: 26 Feb 2006
Posts: 19
Location: usa

PostPosted: Mon Jun 13, 2016 6:56 pm
Reply with quote

Rohit Umarjikar wrote:
INCLUDE
Filter out rest all and only include task1 and task2 which meant for all the transactions indded.


Task1 and Task2 is different for different transaction.
for example:

Code:
Tran1003782CLINE01
Tran1003782CLINE02
Tran1003782CLINE03
Tran1003782CLINE04
Tran1003782CLINE05
Tran1003783CLINE01
Tran1003783CLINE02
Tran1003783CLINE03
Tran1003783CLINE04
Tran1003783CLINE05
Tran3013782CLINE01
Tran3013782CLINE02
Tran3013782CLINE03
Tran3013782CLINE04
Tran3013782CLINE05
Tran3013782CLINE06
Tran3013782CLINE07
Tran3013782CLINE08
Tran3013782CLINE09
Tran3013782CLINE10
Tran2003782CLINE01
Tran2003782CLINE02
Tran2003782CLINE03
Tran2003782CLINE04
Tran2003782CLINE05
Tran3113782CLINE06
Tran3113782CLINE01
Tran3113782CLINE02
Tran3113782CLINE03
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Mon Jun 13, 2016 7:06 pm
Reply with quote

Ok , Try GROUP on transaction ,add seq num and then outfile and include seq numbers 1 and 2 only.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Mon Jun 13, 2016 9:35 pm
Reply with quote

Try this card.
Code:
//SYSIN    DD *                                                   
   SORT FIELDS=COPY                                               
   INREC IFOUTLEN=80,                                             
   IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,11),PUSH=(81:ID=8)),           
   IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,5),PUSH=(89:81,8)),             
   IFTHEN=(WHEN=INIT,                                             
   OVERLAY=(40:+1,ADD,(81,8,ZD,SUB,89,8,ZD),M11,LENGTH=3))       
   OUTFILE INCLUDE=(40,3,ZD,EQ,001,OR,40,3,ZD,EQ,002),BUILD=(1,16)
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 213
Location: Chennai

PostPosted: Tue Jun 14, 2016 2:26 am
Reply with quote

May be you can try this too.. Assuming LREC=80, Increase the SEQNUM length according to your requirements.

Code:

OPTION COPY                                             
INREC  IFTHEN=(WHEN=INIT,                               
               OVERLAY=(81:SEQNUM,2,ZD,RESTART=(1,10))),
       IFTHEN=(WHEN=(81,2,CH,EQ,C'01'),                 
               OVERLAY=(83:SEQNUM,2,ZD,RESTART=(1,5)))   
OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(83,2,CH,NE,C'  '),     
               PUSH=(85:83,2))                           
OUTFIL INCLUDE=(85,2,SS,EQ,C'01,02'),BUILD=(1,16)       
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Tue Jun 14, 2016 2:36 am
Reply with quote

May be you want to see how does it restrict to two tasks/transaction ? I am just wondering when '02' is true?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jun 14, 2016 7:45 am
Reply with quote

Rohit,

You've over-engineered yours by trying to get a 1/2 answer, when LT 2 would do. With WHEN=GROUP you'd need to do that subtraction, so it basically does work.

magesh23586's solution works like this.

The first RESTART will get each entire key numbered from 1-N. Of these, 2-N are unimportant, it is the "1" marking the start of the groups which is important.

The second RESTART only operates on the "1"s, so the first "1" will get "1", the second "2", the others are then irrelevant.

Having only marked the first record of each group with the second RESTART, the WHEN=GROUP on OUTREC propagates that to all the records in the group, then the INCLUDE= can pick all the records marked with 1s or 2s.

The sequence numbers need to be large enough to cover the number of records within a group, else mayhem will, as usual, ensue.

If a SORT were required as well, things could be different (due to the use of OUTREC because WHEN=GROUP cannot follow WHEN=(logicalexpression)). Depends on the data and the actual requirement for that case.

Here's an alternate. Since the records which aren't wanted aren't wanted, you can destroy them (or a byte of them) to indicate they are not wanted.

This can also be applied to Rohit's solution which works even if a SORT is needed.

Code:
 OPTION COPY
 INREC  IFTHEN=(WHEN=INIT,
                OVERLAY=(81:SEQNUM,2,ZD,RESTART=(1,10))),
        IFTHEN=(WHEN=(81,2,CH,EQ,C'01'),
                OVERLAY=(83:SEQNUM,2,ZD,RESTART=(1,5)))
 OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(83,2,CH,NE,C'  '),
                PUSH=(85:83,2)),
        IFTHEN=(WHEN=(85,2,CH,GT,C'02'),
                OVERLAY=(1:C' ')),
        IFOUTLEN=16
 OUTFIL OMIT=(1,1,CH,EQ,C' ')
Back to top
View user's profile Send private message
vice_versa
Warnings : 1

New User


Joined: 26 Feb 2006
Posts: 19
Location: usa

PostPosted: Tue Jun 14, 2016 1:47 pm
Reply with quote

It is OK
thanks you very much

Rohit Umarjikar wrote:
Try this card.
Code:
//SYSIN    DD *                                                   
   SORT FIELDS=COPY                                               
   INREC IFOUTLEN=80,                                             
   IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,11),PUSH=(81:ID=8)),           
   IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,5),PUSH=(89:81,8)),             
   IFTHEN=(WHEN=INIT,                                             
   OVERLAY=(40:+1,ADD,(81,8,ZD,SUB,89,8,ZD),M11,LENGTH=3))       
   OUTFILE INCLUDE=(40,3,ZD,EQ,001,OR,40,3,ZD,EQ,002),BUILD=(1,16)
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 Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
No new posts JCL EXEC PARM data in C Java & MQSeries 2
This topic is locked: you cannot edit posts or make replies. Automation need help in sorting the data DFSORT/ICETOOL 38
Search our Forums:

Back to Top