|
View previous topic :: View next topic
|
| Author |
Message |
TS70363
New User
Joined: 07 Apr 2010 Posts: 94 Location: Bangalore, India
|
|
|
|
Hi all,
I am working on a requirement where in a variable - CSV mainframe DSN, I have last 2 bytes as a Comma (,) and a character - A,U,D.
I would like to ignore the comma and any characters that appear at the end.
Is it possible to achieve it thru Syncsort?
Sample Records:
| Code: |
UNKNOWN,DNAINGDEG,U
,UNKNOWN, ,U
UNKNOWN, ,A |
Expected Output
| Code: |
UNKNOWN,DNAINGDEG
,UNKNOWN,
UNKNOWN, |
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Yes. If you shift to the right to the maximum length, then blank out the last two characters and shift to the left. Look at JFY. |
|
| Back to top |
|
 |
TS70363
New User
Joined: 07 Apr 2010 Posts: 94 Location: Bangalore, India
|
|
|
|
Thanks, Bill
Your post helps.
Just an add on to my requirement, I need to filter my output files based on the last character - if it is A,U it should go to ADD output file and if it is D, it should go to DELETE file
Please correct my understanding, if on a wrong track:
1) Use INREC IFTHEN WHEN INIT - JFY=RIGHT, LENGTH = MAX LENGTH
2) OUTFIL FILES=ADD,INCLUDE=(MAX-LENGTH,1,CH,EQ,L(C'A',C'U')),
IFTHEN WHEN INIT, BUILD=(1, MAXLENGTH - 2, JFY=LEFT),
3) OUTFIL FILES=DEL,INCLUDE=(MAX-LENGTH,1,CH,EQ,L(C'D')),
IFTHEN WHEN INIT, BUILD=(1, MAXLENGTH - 2, JFY=LEFT) |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| If you have fixed-length records, that'll be close, but you BUILD not be needed. |
|
| Back to top |
|
 |
TS70363
New User
Joined: 07 Apr 2010 Posts: 94 Location: Bangalore, India
|
|
|
|
Hi,
As I am using VB input records, the sort fails with INREC SHORT RECORD |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| You'll need to post what you are running, easiest is to past the full sysout for the failing step. |
|
| Back to top |
|
 |
TS70363
New User
Joined: 07 Apr 2010 Posts: 94 Location: Bangalore, India
|
|
|
|
RECFM=VB
LRECL=50
| Code: |
SORT FIELDS=COPY
INREC FIELDS=(1,4,5,46,JFY=(SHIFT=RIGHT,LENGTH=46))
OUTFIL FILES=OUT,INCLUDE=(50,1,CH,EQ,C'A'),
OUTREC=(1,4,5,46,JFY=(VL)),FTOV |
SYSOUT:
| Code: |
| WER244A INREC - SHORT RECORD |
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Code: |
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(51:X)),
IFTHEN=(WHEN=INIT,
OVERLAY=(5,46,JFY=(SHIFT=RIGHT,LENGTH=46))
OUTFIL FILES=OUT,INCLUDE=(50,1,CH,EQ,C'A'),
BUILD=(1,4,5,46,JFY=(VL)),FTOV |
I'm not sure what the VL means. Why are you trying to use FTOV? You haven't truncated the last two bytes in the OUTFIL, I thought you needed that. |
|
| Back to top |
|
 |
TS70363
New User
Joined: 07 Apr 2010 Posts: 94 Location: Bangalore, India
|
|
|
|
| Thanks Bill. Yes I do want to truncate the last 2 bytes. As this is just a test version of the Sort Card, I have retained it. I will reduce the length in BUILD statement bt 2 bytes. TA. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Code: |
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(51:X)),
IFTHEN=(WHEN=INIT,
BUILD=(1,4,5,46,JFY=(SHIFT=RIGHT,LENGTH=46))
OUTFIL FILES=OUT,INCLUDE=(50,1,CH,EQ,C'A'),
BUILD=(1,4,5,46,JFY=(SHIFT=LEFT,LENGTH=46)),
VLTRIM |
OK, I've discovered what VL means (a variable-length field with trailing blanks dropped) and that it only works on OUTFIL with FTOV.
That doesn't mean you just add FTOV onto OUTFIL to make the VL work. FTOV converts Fixed-length-record TO Variable-length-records. So you'd need to have fixed-length input you wanted as variable-length output. So you can't use FTOV here, so you can't use VL on JFY. In this case it will make the JFY not do what you want, even if it did "work".
When you want to drop the last two, use 5,44 in the final BUILD. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|