IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Syncsort 1.4.2 - Variable file - Ignore last 2 bytes


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
TS70363

New User


Joined: 07 Apr 2010
Posts: 94
Location: Bangalore, India

PostPosted: Fri May 22, 2015 9:45 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7310
Location: Inside the Matrix

PostPosted: Sat May 23, 2015 1:13 am
Reply with quote

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
View user's profile Send private message
TS70363

New User


Joined: 07 Apr 2010
Posts: 94
Location: Bangalore, India

PostPosted: Sat May 23, 2015 2:17 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7310
Location: Inside the Matrix

PostPosted: Sat May 23, 2015 4:28 am
Reply with quote

If you have fixed-length records, that'll be close, but you BUILD not be needed.
Back to top
View user's profile Send private message
TS70363

New User


Joined: 07 Apr 2010
Posts: 94
Location: Bangalore, India

PostPosted: Sun May 24, 2015 1:49 am
Reply with quote

Hi,
As I am using VB input records, the sort fails with INREC SHORT RECORD
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7310
Location: Inside the Matrix

PostPosted: Sun May 24, 2015 2:57 am
Reply with quote

You'll need to post what you are running, easiest is to past the full sysout for the failing step.
Back to top
View user's profile Send private message
TS70363

New User


Joined: 07 Apr 2010
Posts: 94
Location: Bangalore, India

PostPosted: Sun May 24, 2015 3:34 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7310
Location: Inside the Matrix

PostPosted: Sun May 24, 2015 3:50 am
Reply with quote

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
View user's profile Send private message
TS70363

New User


Joined: 07 Apr 2010
Posts: 94
Location: Bangalore, India

PostPosted: Sun May 24, 2015 11:47 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7310
Location: Inside the Matrix

PostPosted: Mon May 25, 2015 12:49 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts COBOL Table data to a flat file with ... COBOL Programming 5
No new posts DECIMAL HOST VARIABLE OR PARAMETER 14... DB2 6
No new posts Compare 2 files replace data in 1st f... DFSORT/ICETOOL 4
No new posts Merging 2 files but ignore duplicate... DFSORT/ICETOOL 1
No new posts DB2 SQL query to read and update data... DB2 12
Search our Forums:

Back to Top