View previous topic :: View next topic
Author
Message
Claes Norreen Active User Joined: 20 Dec 2005Posts: 137 Location: Denmark
I want to squeeze 3 fields into one. Blanks in each field must be preseved. Say, I have these three fields:
Field1: Gl. Kongevej
Field2: 14 B
Field3: LGH. 231
The output must be:
Gl. Kongevej 14 B LGH. 231
I tried this code, but (of course) the quotes "inside" the resulting field are not removed. So my output is:
GL. KONGEVEJ" "14 A" "LGH. 231
Code:
//STEP01 EXEC PGM=ICETOOL
//IN DD *
GL. KONGEVEJ 14 A LGH. 231
//OUT DD SYSOUT=*
//SYMNAMES DD *
Q,X'7F' /* QUOTE
SPACE,C' '
//TOOLIN DD *
COPY FROM(IN) TO(OUT) USING(CTL1)
//CTL1CNTL DD *
INREC BUILD=(01,40,JFY=(SHIFT=LEFT,LEAD=Q,TRAIL=Q,LENGTH=42),
41,10,JFY=(SHIFT=LEFT,LEAD=Q,TRAIL=Q,LENGTH=12),
51,30,JFY=(SHIFT=LEFT,LEAD=Q,TRAIL=Q,LENGTH=32))
OUTREC BUILD=(1,86,SQZ=(SHIFT=LEFT,PAIR=QUOTE,MID=SPACE,LENGTH=40))
OUTFIL FNAMES=OUT,
BUILD=(1,40,JFY=(SHIFT=LEFT,PREBLANK=Q))
Can anyone help me with this?
Back to top
murmohk1 Senior Member Joined: 29 Jun 2006Posts: 1436 Location: Bangalore,India
Claes Norreen,
Change your CTL1 control card as below -
Code:
INREC BUILD=(01,40,JFY=(SHIFT=LEFT,LENGTH=42),
41,10,JFY=(SHIFT=LEFT,LENGTH=12),
51,30,JFY=(SHIFT=LEFT,LENGTH=32))
OUTFIL FNAMES=OUT,
BUILD=(1,40,JFY=(SHIFT=LEFT,PREBLANK=SPACE))
OUTREC FIELDS=(1,86,SQZ=(SHIFT=LEFT,PAIR=APOST,MID=SPACE,LENGTH=40))
OP of the above card -
Code:
GL. KONGEVEJ 14 A LGH. 231
Back to top
Claes Norreen Active User Joined: 20 Dec 2005Posts: 137 Location: Denmark
Hi Murali,
Thanks for your reply! Your code works, and infact can be shortened to this:
Code:
OUTREC BUILD=(1,80,SQZ=(SHIFT=LEFT,MID=SPACE,LENGTH=40))
However, this code (nor yours) won't preserve multiple blanks in the input. Can you make multiple blanks in the input work as well?
Thanks again,
Claes
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
I was going to suggest the simple SQZ statement but you came up with it yourself. As for handling multiple blanks, you're asking DFSORT to read your mind. There's no way DFSORT can tell which blanks belong to which fields - think about it. That's why this kind of input usually has quotes or apostrophes around the fields to identify them as separate fields.
Back to top
murmohk1 Senior Member Joined: 29 Jun 2006Posts: 1436 Location: Bangalore,India
Claes,
If you want to preserve the multiple blanks, my suggestion is to use your original card and in the next step remove quotes using IFTHEN condition.
Back to top
Claes Norreen Active User Joined: 20 Dec 2005Posts: 137 Location: Denmark
Thanks both of you ;)
Back to top
Please enable JavaScript!