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

How to extract N & N+1 records based on the value in Nth


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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
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
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
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 Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Jul 30, 2008 9:41 pm
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:

Use [URL] BBCode for External Links
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 Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Join multiple records using splice DFSORT/ICETOOL 5
Search our Forums:

Back to Top