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

INSPECT to remove quotes help required


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ajit007_cool

New User


Joined: 08 Sep 2008
Posts: 14
Location: basel

PostPosted: Tue Sep 09, 2008 12:29 pm
Reply with quote

In my cobol values for variables is declared within single quotes as below

01 W-VARIABLE PICX(4) VALUE 'AJIT'.

Now if i wish to search a quote within a sting i have no clue how to it . because it wont allow any of the following.

INSPECT WS_VARIABLE REPLACING ALL ' ' ' BY ' '.
OR
INSPECT WS_VARIABLE REPLACING ALL" ' " BY ' '.
OR
INSPECT WS_VARIABLE REPLACING ALL QUOTE BY SPACE.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Sep 09, 2008 12:48 pm
Reply with quote

you need to use '''' (four times quote) to refer one quote.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Sep 09, 2008 1:23 pm
Reply with quote

the QUOTE figurative literal should works.

I defined a field with VALUE ALL QUOTES.

my inspect statement is as follows:

INSPECT WORKING-FIELD
REPLACING ALL QUOTES BY SPACES

and

INSPECT WORKING-FIELD
REPLACING ALL QUOTE BY SPACE

in COBOL II it both work

what compiler error are you getting?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Sep 09, 2008 1:25 pm
Reply with quote

Quote:

W-VARIABLE PICX(4) VALUE 'AJIT'.

Now if i wish to search a quote within a sting i have no clue how to it . because it wont allow any of the following.

INSPECT WS_VARIABLE REPLACING


probably complaining about WS_VARIABLE which 1) is not a legal reference name and 2) the working storage variable you provided is W-VARIABLE. ws and w. Attention to detail!!!!
Back to top
View user's profile Send private message
ajit007_cool

New User


Joined: 08 Sep 2008
Posts: 14
Location: basel

PostPosted: Tue Sep 09, 2008 1:31 pm
Reply with quote

my input string is
00006044;TEST'9

output must be
00006044;TEST 9


samabajhi i tried ur suggestion , but it didnt worked.

hey dick i tried this earlier but i didnt recieved any compiler error but my output remained same

INSPECT WORKING-FIELD
REPLACING ALL QUOTE BY SPACE
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Sep 09, 2008 1:35 pm
Reply with quote

what is your working storage definition of working-field?
Back to top
View user's profile Send private message
ajit007_cool

New User


Joined: 08 Sep 2008
Posts: 14
Location: basel

PostPosted: Tue Sep 09, 2008 1:38 pm
Reply with quote

0008 02 LDA-SUBJ PIC X(107).


and it has data as below
00006044;TEST'9 ;BSL;TEST'6 ;TEAT'5


and i want it to be like
00006044;TEST 9 ;BSL;TEST 6 ;TEAT 5
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Sep 09, 2008 1:45 pm
Reply with quote

Hi Ajit,
Am wondering why it is not working..

below is code i tried and working fine at my end...
Code:

*working storage def.
 01 MYVAR1 PIC X(30) VALUE '00006044;TEST''9'.
.
.
.
*procedure div
.
.
     DISPLAY 'INPUT: ' MYVAR1.   
     INSPECT MYVAR1               
     REPLACING ALL '''' BY SPACE.
     DISPLAY 'OUTPUT: 'MYVAR1.   
.
.
.
*output is
INPUT: 00006044;TEST'9 
OUTPUT: 00006044;TEST 9


Is it the same you want?
Back to top
View user's profile Send private message
ajit007_cool

New User


Joined: 08 Sep 2008
Posts: 14
Location: basel

PostPosted: Tue Sep 09, 2008 1:53 pm
Reply with quote

earlier i was using
INSPECT MYVAR1
REPLACING ALL '''' BY ' '.

this was not working

now i used urone it worked thanks a lot

thank u very much
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Sep 09, 2008 1:57 pm
Reply with quote

U R WEL-C icon_biggrin.gif ME..
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue Sep 09, 2008 6:30 pm
Reply with quote

Ajit,

The main thing to remember, is that to represent a quote within quotes, you must use 2 quotes. Soooo:

If the string is ABC'DEF you represent it as 'ABC''DEF'.

If the string is ' you represent it as ''''.

The rule is the same in both cases, but they look different.
Back to top
View user's profile Send private message
ajit007_cool

New User


Joined: 08 Sep 2008
Posts: 14
Location: basel

PostPosted: Tue Sep 09, 2008 6:31 pm
Reply with quote

thanks jack
Back to top
View user's profile Send private message
deepak4wd

New User


Joined: 24 Apr 2006
Posts: 4

PostPosted: Wed Nov 05, 2008 6:42 pm
Reply with quote

Hi all,
can some one tell the logic to convert double qouted string to single qouted string using the inspect claues according to above discussion.

thanks.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Nov 05, 2008 7:20 pm
Reply with quote

Quote:

can some one tell the logic to convert double qouted string to single qouted string using the inspect claues according to above discussion.

What have you tried seeing above discussion??
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Nov 05, 2008 7:51 pm
Reply with quote

If you use the hex-notation for a Quote (X'7D') and an INSPECT CONVERTING, this will be the most efficient process.

INSPECT REPLACING causes a the compiler to BALR to a COBOL Run Time routine, whereas, INSPECT CONVERTING (with literals) causes the compiler to build an in-line TR instruction with a Translate-Table.

Regards,

Bill
Back to top
View user's profile Send private message
deepak4wd

New User


Joined: 24 Apr 2006
Posts: 4

PostPosted: Fri Nov 07, 2008 1:44 pm
Reply with quote

Thank you bill, I'll try the same.
thanks a lot for the quick reply.
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Remove leading zeroes SYNCSORT 4
No new posts Help in extracting data between doubl... DFSORT/ICETOOL 5
No new posts How to remove block of duplicates DFSORT/ICETOOL 8
No new posts To Remove spaces (which is in hex for... JCL & VSAM 10
Search our Forums:

Back to Top