INSPECT clause search



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

INSPECT clause search

Postby luckyboyroh » Fri May 10, 2013 11:25 am

hi friends,

is it possible to use inspect clause to replace characters of different lengths?

ex: INSPECT WS-DESC REPLACING ALL '&' BY '&'
WS-DESC:johnson & johnson

i want it to be modified as :
WS-DESC: johnson & johnson.

Wen i try, it is showing compiler error,"REPLACING" operand "'&'" was not the same length as the "BY" operand "'&'"

is there any other way to acheive this? coz i am trying to parse in xml and it doesn allow.

XML has a special set of characters that cannot be used in normal XML strings. These characters are:
Character should be replaced with
& &
< &lt;
> &gt;
" &quot;
' &#39;
luckyboyroh
 
Posts: 35
Joined: Wed Jan 16, 2013 4:05 pm
Has thanked: 3 times
Been thanked: 0 time

Re: INSPECT clause search

Postby Pandora-Box » Fri May 10, 2013 12:02 pm

You could achieve this by using UNSTRING delimited by '&'

and then string back the value '&amp' with the needed data
User avatar
Pandora-Box
 
Posts: 65
Joined: Fri Feb 10, 2012 8:30 pm
Location: Mars
Has thanked: 3 times
Been thanked: 6 times

Re: INSPECT clause search

Postby BillyBoyo » Fri May 10, 2013 1:47 pm

You should read closely, and believe, the compiler messages. For first step for a fuller understanding is then the COBOL manuals, the Language Reference first, and then the Programming Guide. They are available through IBM on the web, and there is a link at the top and bottom of the page here.

What XML processing are you doing?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post