MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Extracting part of the record based on condition

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
mainframemouli
Beginner


Joined: 23 Feb 2005
Posts: 87
Topics: 33

PostPosted: Thu Jun 26, 2008 6:43 am    Post subject: Extracting part of the record based on condition Reply with quote

I have a file with the record length of 80. The content of the file is as below

Code:

COMMUNICATION ADDRESS COD1 INVALID AAAASDDFF
COMMUNICATION ADDRESS hhhh COD2 INVALID FFSDSDSS
COMMUNICATION ADDRESS hhh COD3 INVALID DFDGGGFG
COMMUNICATION ADDRESS kkk COD1 INVALID SDFDFFG


My requirement is , whenever I hit COD1,COD2 or COD3 in a record then in the output file I need to get like :

The 10 charecters infront of COD1 or COD2 or COD3 and 10 charecters after COD1 or COD2 or COD3 Like below :

Code:

N ADDRESS COD1 INVALID A
RESS hhhh COD2 INVALID F
DRESS hhh COD3 INVALID D
DRESS kkk COD1 INVALID S


Please let me how to do that using any utilities , our shop has a tool called selcopy I am trying out in that as well If not i will be writting a cob program for it.




Code:
Code:
Back to top
View user's profile Send private message
mainframemouli
Beginner


Joined: 23 Feb 2005
Posts: 87
Topics: 33

PostPosted: Thu Jun 26, 2008 9:51 am    Post subject: Reply with quote

I have done it through SELCOPY a product of CA.

The code is as below :
Code:

GET                               
READ INFILE INTO 1 WORKLEN 999000
IF EOF                             
THEN EOJ                           
                                   
IF POS ANY = 'COD1'       
OR POS ANY = 'COD2'       
OR POS ANY = 'COD3'       
THEN MOVE 10 AT @-10 TO 10 AT 10001   
THEN MOVE 10 AT @ TO 10 AT 10011     
                                     
WRITE OUTFILE FROM 10001 L 20       
GOTO GET                             


I am trying to get this done through sort as well , just out of interest.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12370
Topics: 75
Location: San Jose

PostPosted: Thu Jun 26, 2008 10:46 am    Post subject: Reply with quote

mainframemouli,

The following DFSORT JCL will give you desired results

Code:

//STEP0100 EXEC PGM=ICEMAN                     
//SYSOUT   DD SYSOUT=*                         
//SORTIN   DD *                                 
COMMUNICATION ADDRESS COD1 INVALID AAAASDDFF   
COMMUNICATION ADDRESS HHHH COD2 INVALID FFSDSDSS
COMMUNICATION ADDRESS HHH COD3 INVALID DFDGGGFG
COMMUNICATION ADDRESS KKK COD1 INVALID SDFDFFG 
//SORTOUT  DD SYSOUT=*                         
//SYSIN    DD *                                 
  SORT FIELDS=COPY                             
  INREC PARSE=(%00=(ENDAT=C'COD1',             
                    ENDAT=C'COD2',             
                    ENDAT=C'COD3',FIXLEN=080), 
               %01=(FIXLEN=80)),               
       BUILD=(%00,JFY=(SHIFT=RIGHT),C' ',       
              %01,JFY=(SHIFT=LEFT))             
                                               
  OUTREC BUILD=(67,24)                         
/*                                             


Hope this helps...

Cheers
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Jun 26, 2008 12:02 pm    Post subject: Reply with quote

Here's another way to do it with DFSORT:

Code:

//S1 EXEC PGM=ICEMAN
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
COMMUNICATION ADDRESS COD1 INVALID AAAASDDFF
COMMUNICATION ADDRESS HHHH COD2 INVALID FFSDSDSS
COMMUNICATION ADDRESS HHH COD3 INVALID DFDGGGFG
COMMUNICATION ADDRESS KKK COD1 INVALID SDFDFFG
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD *
  SORT FIELDS=COPY
  INREC PARSE=(%00=(STARTAT=C'COD1',
                    STARTAT=C'COD2',
                    STARTAT=C'COD3',FIXLEN=14),
               %01=(SUBPOS=24,FIXLEN=10)),
       BUILD=(%01,%00)
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group