Page 1 of 1

How to Extract a string from a VB record

PostPosted: Tue Jan 22, 2013 10:54 pm
by akjs
Hi,

I have requirement to extract data from a variable length record.

Input:
other data<txt>Need to Extract1 <\txt>other dataother data
other dataother datadsfdadsdsa<txt>Need to Extract2 <\txt>dsdasafdda
ohter<txt>Need to Extract3 <\txt>otheresdfasfdas

Output Expected:
Need to Extract1
Need to Extract2
Need to Extract3

Note: The position of <txt> and <\txt> varies record to record.
Could you please suggest me a control card to achieve this using Sort/ICETOOL /ICEMAN

Thanks

Re: How to Extract a string from a VB record

PostPosted: Wed Jan 23, 2013 2:15 am
by NicC
Look up PARSE. Search the forum for examples.

Re: How to Extract a string from a VB record

PostPosted: Wed Jan 23, 2013 2:23 am
by skolusu
akjs,

use the following DFSORT JCL which will give you the desired results. I assumed the extract text to be 30 bytes. If it is more than that change the value of 'n' in the FIXLEN=n parm.
//STEP0050 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                     
OTHER DATA<TXT>NEED TO EXTRACT1 <\TXT>OTHER DATAOTHER DATA         
OTHER DATAOTHER DATADSFDADSDSA<TXT>NEED TO EXTRACT2 <\TXT>DSDASAFDDA
OHTER<TXT>NEED TO EXTRACT3 <\TXT>OTHERESDFASFDAS                   
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                 
  INREC PARSE=(%00=(STARTAFT=C'<TXT>',ENDBEFR=C'<\TXT>',FIXLEN=30)),
  BUILD=(%00)                                                       
//*