GANAPATH
New User
Joined: 06 Mar 2006 Posts: 35
|
|
|
|
Hi,
i have a file and i want to copy only certain things from that file to another file. The problem is, what i want to copy might not be in same position always, in such scenario how can i copy.
Ex: INPUTFILE
ABC FIRSTNAME = "KALYAN" LAST NAME ="VRIDHI CHANDIKA" 123,DOB="12-22-34"
OUTPUT FILE should look like this
kalyan,vridhi chandika,12-22-34
since the names are always of different length i cannot specify the position, now how can i copy this file and create my output, i don't want to write any programs for this, is there a simple way.
Appreciate it.
Thanks,
Ganapath |
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
You can now do this using the new PARSE and SQZ functions available with z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006) as shown in the DFSORT job below. What makes this tricky is that a string with blanks can be embedded in quotes for
input, but for output the string with blanks has to be kept as is with no quotes around it.
For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTFs, see:
Use [URL] BBCode for External Links
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file
//SORTOUT DD DSN=... output file
//SYSIN DD *
OPTION COPY
ALTSEQ CODE=(40FF,FF40)
* b represents blank and x represents FF.
INREC IFTHEN=(WHEN=INIT,
* Get %00="VALUEb1", %01="VALUEb2", %02="VALUEb3"
PARSE=(%00=(STARTAT=C'"',ENDAT=C'"',FIXLEN=12),
%01=(STARTAT=C'"',ENDAT=C'"',FIXLEN=22),
%02=(STARTAT=C'"',ENDAT=C'"',FIXLEN=10)),
* Build record with "valueb1"bbbb,"valueb2"bbbb,"valueb3"
BUILD=(%00,TRAN=UTOL,C',',%01,TRAN=UTOL,C',',%02)),
* Squeeze out blanks outside of "s to get:
* "valueb1","valueb2","valueb3"b...b
IFTHEN=(WHEN=INIT,BUILD=(1,46,SQZ=(SHIFT=LEFT,PAIR=QUOTE))),
* Replace blanks with FFs to get
* "valuex1","valuex2","valuex3"x...x
IFTHEN=(WHEN=INIT,BUILD=(1,46,TRAN=ALTSEQ)),
* Remove "s and shift left to get
* valuex1,valuex2,valuex3x...xb...b
IFTHEN=(WHEN=INIT,BUILD=(1,46,SQZ=(SHIFT=LEFT,PREBLANK=C'"'))),
* Replace FFs with blanks and blanks with FFs to get
* valueb1,valueb2,valueb3b...bx...x
IFTHEN=(WHEN=INIT,BUILD=(1,46,TRAN=ALTSEQ)),
* Get %03=valueb1,valueb2,valueb3b...b
IFTHEN=(WHEN=INIT,PARSE=(%03=(ENDBEFR=X'FF',FIXLEN=46)),
* Build final record with
* valueb1,valueb2,valueb3b...b
BUILD=(%03))
/*
|
|
|