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
 
How to extract N & N+1 records based on the value in Nth

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

New User


Joined: 03 Mar 2006
Posts: 48
Location: Chennai

PostPosted: Wed Jul 30, 2008 10:50 am    Post subject: How to extract N & N+1 records based on the value in Nth
Reply with quote

Hi,

I have a report file as given below.

CUSTOMER CLIENT GROUP GRP EFF GRP TERM
------------------------------------------------------------------------------------
0000000000 CDHP0000000000 TST6PVM001 20080101 99991231
--->PENDING CODES: 033 032

0000000000 CDHP0000000000 TST6PVM002 20080101 99991231
--->PENDING CODES: 033 032

0000000000 CDHP0000000000 TST6PVM003 20080101 99991231
--->PENDING CODES: 033 032

03012007 CDHPGAWGAHRA TESG90M001 20070301 99991231
--->PENDING CODES: 033 032

ABC CDHPXYZ GRP11 20070101 20070301
--->PENDING CODES: 033 032

ABCD CDHPPQRS DMDL002 20070101 99991231
--->PENDING CODES: 033 032

CA CDHPGROUPHIA 170041M012 20070701 99991231
--->PENDING CODES: 060

CA CDHPGROUPHIA 170041M013 20070701 99991231
--->PENDING CODES: 060

CA CDHPGROUPHIA 170041M014 20070701 99991231
--->PENDING CODES: 060

When i give the value 'TST6PVM001' in the include condition; my output file should contain the record with this Group and the next record with pending codes. So for the above example the output should look like

0000000000 CDHP0000000000 TST6PVM001 20080101 99991231
--->PENDING CODES: 033 032

All the starting positions are standard and will remain same for all. Here the group field begins only at 31st position.

Please provide me with the sort/icetool to solve this. Any other alternatives are also appreciated.

Thanks,
Karthik. P
Back to top
View user's profile Send private message

karthikr44

Active User


Joined: 25 Aug 2007
Posts: 235
Location: Chennai

PostPosted: Wed Jul 30, 2008 1:31 pm    Post subject: Reply to: How to extract N & N+1 records based on the va
Reply with quote

HI,

The following sort card wil give u solution. I assumed the grp field at 31, and lrecl as 133.

Code:

//STEP0100  EXEC  PGM=ICETOOL                                 
//TOOLMSG   DD SYSOUT=*                                       
//DFSMSG    DD SYSOUT=*                                       
//IN        DD DSN=DEV2.RK.TEST(@@CASE),DISP=SHR               
//OUT       DD DSN=DEV2.RK.TEST(@@CASE1),DISP=SHR             
//TOOLIN    DD *                                               
  SELECT FROM(IN) TO(OUT) ON(134,8,CH) ALLDUPS USING(CTL1)     
//CTL1CNTL DD *                                               
  INREC IFTHEN=(WHEN=INIT,                                     
       OVERLAY=(134:SEQNUM,8,ZD)),                             
        IFTHEN=(WHEN=(31,10,CH,EQ,C'TST6PVM001'),             
       OVERLAY=(134:+1,ADD,134,8,ZD,M11,LENGTH=8))             
                                                               
  OUTFIL FNAMES=OUT,BUILD=(01,133)                             
/*                                                             


INPUT:

Code:

0000000000 CDHP0000000000     TST6PVM001 20080101 99991231     
--->PENDING CODES: 033 032                                     
0000000000 CDHP0000000000     TST6PVM002 20080101 99991231     
--->PENDING CODES: 033 032                                     
0000000000 CDHP0000000000     TST6PVM003 20080101 99991231     
--->PENDING CODES: 033 032                                     
03012007 CDHPGAWGAHRA         TESG90M001 20070301 99991231     
--->PENDING CODES: 033 032                                     


Output:

Code:

0000000000 CDHP0000000000     TST6PVM001 20080101 99991231         
--->PENDING CODES: 033 032                                         


Regards
R KARTHIK
Back to top
View user's profile Send private message
rz061m

New User


Joined: 03 Mar 2006
Posts: 48
Location: Chennai

PostPosted: Wed Jul 30, 2008 2:29 pm    Post subject:
Reply with quote

Thanks Karthik.

I have one more query; is it possible to have mulitple check in the when condition using OR operator or SS option.

IFTHEN=(WHEN=(31,10,CH,EQ,C'TST6PVM001') --> what if i need one more group to check.

Thanks,
Karthik. P
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Wed Jul 30, 2008 2:34 pm    Post subject:
Reply with quote

rz061m wrote:
Thanks Karthik.

I have one more query; is it possible to have mulitple check in the when condition using OR operator or SS option.

IFTHEN=(WHEN=(31,10,CH,EQ,C'TST6PVM001') --> what if i need one more group to check.

Thanks,
Karthik. P


Did you try using OR operator or SS option? Did you face any problems?
Back to top
View user's profile Send private message
karthikr44

Active User


Joined: 25 Aug 2007
Posts: 235
Location: Chennai

PostPosted: Wed Jul 30, 2008 3:14 pm    Post subject: Reply to: How to extract N & N+1 records based on the va
Reply with quote

Hi,

U can use the substring option for multiple conditions like below.

Code:

//CTL1CNTL DD *                                             
  INREC IFTHEN=(WHEN=INIT,                                 
       OVERLAY=(134:SEQNUM,8,ZD)),                         
        IFTHEN=(WHEN=(31,10,SS,EQ,C'TST6PVM001,TST6PVM002'),
       OVERLAY=(134:+1,ADD,134,8,ZD,M11,LENGTH=8))         
                                                           
  OUTFIL FNAMES=OUT,BUILD=(01,133)                         
/*                                                         


Regards
R KARTHIK
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: Wed Jul 30, 2008 9:41 pm    Post subject:
Reply with quote

You can now do this more easily and efficiently with the new WHEN=GROUP function available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) as follows:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/133)
//SORTOUT DD DSN=...  output file (FB/133)
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,
     BEGIN=(31,10,SS,EQ,C'TST6PVM001,TST6PVM002'),
     RECORDS=2,
     PUSH=(134:ID=1))
  OUTFIL INCLUDE=(134,1,CH,NE,C' '),BUILD=(1,133)
/*


For complete details on the new WHEN=GROUP function and the other new functions available with PTF UK90013, see:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
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 BUILD OUTFIL based on condition other... balaji81_k DFSORT/ICETOOL 13 Fri Sep 08, 2017 11:06 pm
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts Join records from 2 files with No Dup... Poha Eater DFSORT/ICETOOL 21 Sun Aug 27, 2017 10:35 pm
No new posts Extract Data till prev hour balaji81_k DB2 16 Fri Aug 25, 2017 9:25 pm
No new posts How do you create Eclipse based dialogs jasorn IBM Tools 0 Thu Aug 03, 2017 5:05 pm

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