Page 1 of 1

How to add (special character) ' in Input file using sort jc

PostPosted: Thu Oct 13, 2016 8:02 pm
by dkuma14
Hello Everyone request you to help me on my below query.

I have searched the forum and I am getting sort card to add special character or any character in a file but I am not getting any how to add special character ' which is my requirement.

I have an Input file having below records (data starting from position 1)

1234567
1761241

I need my output as below after sort.
'1234567',
'1761241',


I used a jcl as below

//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(1:C';',2:1,7,C';,',800:X)

And In this case I am getting output as expected

Output -

;1234567;,
;1761241;,

But when I am using below ( for special character ' ) which actually I need at position 1 and 9 it is showing syntax error.

//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(1:C''',2:1,7,C'',',800:X)

Thanks

Re: How to add (special character) ' in Input file using sor

PostPosted: Thu Oct 13, 2016 8:51 pm
by Aki88
Hello,

To add a single quote, you write it as two single-quotes, so your SORT card changes to below (you can add the additional space padding code):


SORT FIELDS=COPY              
OUTFIL BUILD=(C'''',1,7,C''',')
 



Output:


'1234567',
'1761241',
 

Re: How to add (special character) ' in Input file using sor

PostPosted: Thu Oct 13, 2016 8:55 pm
by Akatsukami
Welcome to the board.

As you will quickly learn, JCL does nothing but create environments in which programs can run, and then run those programs. You need (or at least want) a sort program. There are two fora for the major sort products, DFSORT and Syncsort (now called MFX). They have similar but not identical control syntax. I have moved your post to the DFSORT forum; if you are using MFX, I will move it to the Syncsort forum.

Note also that you ought to have given at least the error number and message; we are not clairvoyant. Better would be the entire SYSOUT spool data set (no, it's not a "file"; I use a file on the bars of my cell); that would tell us what sort product your shop uses.

Re: How to add (special character) ' in Input file using sor

PostPosted: Thu Oct 13, 2016 9:11 pm
by dkuma14
Thanks !! It's working fine :)

Re: How to add (special character) ' in Input file using sor

PostPosted: Thu Oct 13, 2016 11:27 pm
by dkuma14
I need one more help . In above requirement what will be the sort card if I don't want , at the end of my last record .

Note : I will be not aware about how many records will be there in the Input file. Is there any way to do this through Sort Jcl?

Here below what I am expecting .

Input
1234567
1761241
5611131


Output
'1234567',
'1761241',
'5611131'

Request you to provide sort Jcl for this.

Re: How to add (special character) ' in Input file using sor

PostPosted: Thu Oct 13, 2016 11:39 pm
by dkuma14
I need one more help . In above requirement what will be the sort card if I don't want , at the end of my last record .

Note : I will be not aware about how many records will be there in the Input file. Is there any way to do this through Sort Jcl?

Here below what I am expecting .

Input
1234567
1761241
5611131


Output
'1234567',
'1761241',
'5611131'

Request you to provide sort Jcl for this.


Thanks

Re: How to add (special character) ' in Input file using sor

PostPosted: Fri Oct 14, 2016 2:06 am
by Aki88
Various solutions to the problem; look here for starters; ignore the portion about SYNCSORT, try and understand the logic given in the SORT card.
Build your logic around this, if you face an error, post it here and we can guide you further.

Re: How to add (special character) ' in Input file using sor

PostPosted: Fri Oct 14, 2016 4:01 am
by dkuma14
Thanks Aki ... I gone through the link suggested by you above and its worked for me. Thanks a lot