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
 

 

Select first 2 group data

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

New User


Joined: 26 Feb 2006
Posts: 15
Location: usa

PostPosted: Mon Jun 13, 2016 2:21 pm    Post subject: Select first 2 group data
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

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Mon Jun 13, 2016 3:04 pm    Post subject:
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: 15
Location: usa

PostPosted: Mon Jun 13, 2016 3:24 pm    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Mon Jun 13, 2016 3:35 pm    Post subject:
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: 15
Location: usa

PostPosted: Mon Jun 13, 2016 6:56 pm    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Mon Jun 13, 2016 7:06 pm    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Mon Jun 13, 2016 9:35 pm    Post subject:
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: 158
Location: Chennai

PostPosted: Tue Jun 14, 2016 2:26 am    Post subject: Reply to: Select first 2 group data
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

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Tue Jun 14, 2016 2:36 am    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Jun 14, 2016 7:45 am    Post subject: Reply to: Select first 2 group data
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: 15
Location: usa

PostPosted: Tue Jun 14, 2016 1:47 pm    Post subject:
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    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 ODPP(Optim Data privacy Provider) Iss... Rama kishore IBM Tools 1 Mon Nov 07, 2016 5:46 pm
No new posts Two Selects in a single select query Rohit Umarjikar DB2 1 Fri Nov 04, 2016 8:46 pm
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
No new posts output data in CSV Format janmejay COBOL Programming 8 Sat Oct 15, 2016 2:20 pm


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