How to replace '&' with '&' and more



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

How to replace '&' with '&' and more

Postby 96B5A4485 » Sat Oct 06, 2007 5:02 am

Hi,

I have tried a lot and am not able to achieve this.
Using DFSORT SORT step, I have created an xml output file. But if my output file had any of these characters '&', '<', '>', ''' (single quotes) or '"' (double quotes) then the xml fails to open.

Option 1:
If my data is wrapped between '<![CDATA[' and ']]>' tags, then I won't have a problem. But when I did this, the '[' and ']' characters came out as junk characters and xml failed again.

 
   SORT FIELDS=COPY                 
   OUTFIL FNAMES=MYEXT,REMOVECC,   
       BUILD=(4:C'<Row>',/,             
          5:C'<Cell><Data><![CDATA[',     
          1,20,JFY=(LENGTH=20,SHIFT=LEFT),
          C']]></Data></Cell>',/,         
          4:C'</Row>')                     


This is what I get:
<!CDATAsome data   Ã™Ã™>


Option 2:
Instead of using CDATA tags, there will not be any problem, if I replaced:
'&' with '&amp;'
'<' with '&lt;'
'>' with '&gt;'
''' with '&apos;'
'"' with '&quot;'
I tried using CHANGE= option, but if I do not know the position of these characters in my file (say, these characters can be anywhere from 1 to 20th position in my input file), then how do I achieve this?

Can any of you help me with any of my options (or is there any new option for me)?

Much appreciated.
96B5A4485
 
Posts: 3
Joined: Sat Oct 06, 2007 4:31 am
Has thanked: 0 time
Been thanked: 0 time

Re: How to replace '&' with '&amp;' and more

Postby Frank Yaeger » Sat Oct 06, 2007 5:43 am

I believe DFSORT is outputting the characters you used as input, but your display of the output can't handle them.

On the input side [ is X'BA'. When I run your job, I get the line with [ as:

    <Cell><Data><! CDATA AAA...


and it looks like the [ is missing. But when I display this line in hex with DFSORT, it's:

404040404CC38593936E4CC481A3816E4C5ABAC3C4C1E3C1BAC1C1C1...
                                    **


You can see that the X'BA' is actually there (I put ** below it to identify it).

So I'd say that DFSORT is most likely outputting the characters you told it to and the problem lies somewhere else.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: How to replace '&' with '&amp;' and more

Postby 96B5A4485 » Wed Oct 10, 2007 2:32 am

Hi Frank,

You are right. The hex characters X'BA' is in the output, but still, when I FTP the file and open with notepad/excel/IE, it shows something else. So, I tried the other way. I transferred the file with chars '[' and ']' to mainframe and was surprised to see that the char '[' was translated to X'AD' and ']' to X'BD'. Now, I reran my DFSORT with these hex chars and it worked.

Just curious about my option 2. Do you know how to replace the ";" with "&amp;" and so on (as mentioned in the original post) using DFSORT?

Thanks.
96B5A4485
 
Posts: 3
Joined: Sat Oct 06, 2007 4:31 am
Has thanked: 0 time
Been thanked: 0 time

Re: How to replace '&' with '&amp;' and more

Postby Frank Yaeger » Wed Oct 10, 2007 3:20 am

Just curious about my option 2. Do you know how to replace the ";" with "&amp;" and so on (as mentioned in the original post) using DFSORT?


If you're asking about finding a character (e.g. '>') anywhere in a record and replacing it with a string (e.g. '&gt;'), DFSORT does not have any built-in functions for that.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: How to replace '&' with '&amp;' and more

Postby 96B5A4485 » Wed Oct 10, 2007 9:40 pm

Thanks Frank.
96B5A4485
 
Posts: 3
Joined: Sat Oct 06, 2007 4:31 am
Has thanked: 0 time
Been thanked: 0 time

Re: How to replace '&' with '&amp;' and more

Postby Frank Yaeger » Tue Jul 29, 2008 5:00 am

If you're asking about finding a character (e.g. '>') anywhere in a record and replacing it with a string (e.g. '&gt;'), DFSORT does not have any built-in functions for that.


DFSORT now has a find and replace capability with z/OS DFSORT V1R5 PTF UK90013. For example:

   OPTION COPY
   INREC FINDREP=(INOUT=(C'&',C'&amp;',C'<',C'&lt;',C'>',C'&gt;',
      C'''',C'&apos;',C'"',C'&quot;'))


For complete details on the new FINDREP function and the other new functions available with PTF UK90013, see:

http://www.ibm.com/systems/support/stor ... /mvs/ugpf/
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post