Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Here's a DFSORT job that will do what you asked for using DFSORT's PARSE and SQZ functions. The tricky part here is preserving a blank for each ;; value while not adding other blanks for the variable length values. You'll need z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006) in order to use DFSORT's PARSE and SQZ functions. If you don't have the April, 2006 PTF, ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, see:
Use [URL] BBCode for External Links
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
123;231;1;abvc;;;32;
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
* Extract each field between the semicolons as a
* 10-character right-justified value.
INREC IFTHEN=(WHEN=INIT,
PARSE=(%01=(ENDBEFR=C';',FIXLEN=10),
%02=(ENDBEFR=C';',FIXLEN=10),
%03=(ENDBEFR=C';',FIXLEN=10),
%04=(ENDBEFR=C';',FIXLEN=10),
%05=(ENDBEFR=C';',FIXLEN=10),
%06=(ENDBEFR=C';',FIXLEN=10),
%07=(ENDBEFR=C';',FIXLEN=10)),
* Build a record with the extracted fields.
BUILD=(1:%01,11:%02,21:%03,31:%04,41:%05,51:%06,61:%07)),
* Replace each blank extracted field with a X'FF' character so
* we can preserve the blank fields.
IFTHEN=(WHEN=(1,1,CH,EQ,C' '),OVERLAY=(1:X'FF'),HIT=NEXT),
IFTHEN=(WHEN=(11,1,CH,EQ,C' '),OVERLAY=(11:X'FF'),HIT=NEXT),
IFTHEN=(WHEN=(21,1,CH,EQ,C' '),OVERLAY=(21:X'FF'),HIT=NEXT),
IFTHEN=(WHEN=(31,1,CH,EQ,C' '),OVERLAY=(31:X'FF'),HIT=NEXT),
IFTHEN=(WHEN=(41,1,CH,EQ,C' '),OVERLAY=(41:X'FF'),HIT=NEXT),
IFTHEN=(WHEN=(51,1,CH,EQ,C' '),OVERLAY=(51:X'FF'),HIT=NEXT),
IFTHEN=(WHEN=(61,1,CH,EQ,C' '),OVERLAY=(61:X'FF'))
* Squeeze out the blanks - keep the X'FF' characters.
OUTREC IFTHEN=(WHEN=INIT,BUILD=(1,70,SQZ=(SHIFT=LEFT))),
* Replace each X'FF' character with a blank.
IFTHEN=(WHEN=INIT,BUILD=(1,70,TRAN=ALTSEQ))
ALTSEQ CODE=(FF40)
/*
|
|
|