Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

INSPECT to remove quotes help required

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: INSPECT to remove quotes help required
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject: Reply to: INSPECT to remove quotes help required
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    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Nov 05, 2008 7:51 pm    Post subject: Re: INSPECT to remove quotes help required
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    Post subject: thanks
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Remove Special Characters from Mainfr... Rodger Zhang All Other Mainframe Topics 6 Wed Jul 06, 2016 1:12 am
No new posts Inspect statement spoorni COBOL Programming 5 Mon Jun 06, 2016 9:53 pm
No new posts FTP help required amitc23 All Other Mainframe Topics 3 Thu Apr 28, 2016 12:02 pm
No new posts Why Newcopy is required when we have ... DIXINSH CICS 5 Thu Apr 28, 2016 9:47 am
No new posts To change double quotes into csv read... Robert Sample COBOL Programming 3 Fri Feb 19, 2016 8:13 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us