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 

Copy records from different positions based a value

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


Joined: 22 Dec 2002
Posts: 64
Topics: 28
Location: Chennai

PostPosted: Fri Feb 25, 2005 5:16 am    Post subject: Copy records from different positions based a value Reply with quote

Hi,

I searched for the result, bu was not able to find a real solution.

I have the following input file.
Code:

ABCxVAL1
ABCDxVAL2
ABCxVAL3
ABCDxVAL4

I want to characters VAL1,VAL2,VAL3 to my output file. They start at positions 30 and 31.

Thanks
Ranjish
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Fri Feb 25, 2005 8:25 am    Post subject: Reply with quote

Ranjish,

Post detailed information on what you're trying to accomplish. Do not make people guess what you mean. This will give you a much better chance of getting a good answer to your question.

The position of VAL is variable in your sample input. Post a sample input with expected output along with the DCB attributes of the file.

Thanks

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Ranjish
Beginner


Joined: 22 Dec 2002
Posts: 64
Topics: 28
Location: Chennai

PostPosted: Fri Feb 25, 2005 8:55 am    Post subject: Reply with quote

Kolusu,

Sorry about that.

Details are:

LRECL=80

The character 'x' occurs only once in each line and can be at position 30 or 31, followed by the desired VALue. It is of length 10. I need to take the values (can start either on position 31 or 32).

Hope my requirment is clear now.

Thanks
Ranjish
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Fri Feb 25, 2005 10:22 am    Post subject: Reply with quote

Ranjish,

The following DFSORT/ICETOOL job will give you the desired results. If your shop has syncsort then change the pgm name to Synctool

Code:

//STEP0100 EXEC PGM=ICETOOL                                 
//TOOLMSG  DD SYSOUT=*                                     
//DFSMSG   DD SYSOUT=*                                     
//IN       DD DSN=YOUR INPUT FILE,
//            DISP=SHR
//T1       DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)   
//T2       DD DSN=&T2,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)   
//CON      DD DSN=&T1,DISP=OLD,VOL=REF=*.T1                 
//         DD DSN=&T2,DISP=OLD,VOL=REF=*.T2                 
//OUT      DD SYSOUT=*                                     
//TOOLIN   DD *                                             
  COPY FROM(IN)  USING(CTL1)                               
  SORT FROM(CON) USING(CTL2)                               
//CTL1CNTL DD *                                             
  OUTREC FIELDS=(01,80,        $ TOTAL LRECL               
                 SEQNUM,8,ZD)  $ 8 BYTE SEQNUM             
  OUTFIL FNAMES=T1,                                         
  INCLUDE=(31,1,CH,EQ,C'X'),   $ INCLUDE IF X IN 31         
  OUTREC=(32,10,               $ WRITE 10 BYTES FROM 32     
          81,8)                $ SEQNUM                     
  OUTFIL FNAMES=T2,SAVE,       $ REST OF THE RECORDS       
  OUTREC=(33,10,               $ WRITE 10 BYTES FROM 33     
          81,8)                $ SEQNUM                     
//CTL2CNTL DD *                                             
  SORT FIELDS=(11,8,CH,A)      $ SORT ON SEQNUM             
  OUTFIL FNAMES=OUT,                                       
  OUTREC=(1,10)                $ STRIP THE SEQNUM           
/*                                               


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Ranjish
Beginner


Joined: 22 Dec 2002
Posts: 64
Topics: 28
Location: Chennai

PostPosted: Fri Feb 25, 2005 11:02 am    Post subject: Reply with quote

Thanks Kolusu. That worked perfectly. Thanks again for the fast reply.

Regards
Ranjish
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


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

PostPosted: Fri Feb 25, 2005 11:25 am    Post subject: Reply with quote

Quote:
'x' occurs only once in each line and can be at position 30 or 31


With z/OS DFSORT V1R5 PTF UQ95214 or DFSORT R14 PTF UQ95213 (Dec, 2004), you can use the new IFTHEN function to do this more easily and efficiently as follows. This job is set up for 'x' in 30 or 31 as requested (Kolusu's job is set up for 'X' in 31 or 32).

Code:

//S1 EXEC  PGM=ICEMAN
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
ABC                          xVAL1
ABCD                          xVAL2
ABC                          xVAL3
ABCD                          xVAL4
/*
//SORTOUT  DD SYSOUT=*
  OPTION COPY
  INREC IFTHEN=(WHEN=(30,1,CH,EQ,C'x'),
           BUILD=(31,10)),
        IFTHEN=(WHEN=NONE,BUILD=(32,10))
/*


For complete information on all of the new DFSORT and ICETOOL functions available with the Dec, 2004 PTF, see:

www.ibm.com/servers/storage/support/software/sort/mvs/pdug/
_________________
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