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
 

 

EXAMINE with Replace

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Java & MQSeries
View previous topic :: :: View next topic  
Author Message
monasu1998

Active User


Joined: 23 Dec 2005
Posts: 176
Location: India

PostPosted: Mon Sep 21, 2009 4:17 pm    Post subject: EXAMINE with Replace
Reply with quote

Hi,

I am facing a strange situation where the EXAMINE replace is not working for me.

Situation:

I have a work file. I want to read the records and in each record I want to replace the '"' (Double quote) with SPACE and then write the record to an output file.

I coded as

EXAMINE #STRING FOR '"' REPLACE WITH ' '

When I see the output file, I do not find the '"' s replaced with SPACE.

Is there any specific reason for this.

The same statement is working for single quote, or any other symbol.

Little urgent please.

Thanks,
Aswini
Back to top
View user's profile Send private message

ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Tue Sep 22, 2009 12:50 am    Post subject:
Reply with quote

Try EXAMINE FULL #STRING FOR FULL '"' REPLACE WITH FULL ' '.

O.
Back to top
View user's profile Send private message
monasu1998

Active User


Joined: 23 Dec 2005
Posts: 176
Location: India

PostPosted: Tue Sep 22, 2009 7:07 am    Post subject:
Reply with quote

Thought I hve already tried with
EXAMINE FULL...........

let me try with other 2 FULLs in the same statement and see.

Thanks,
Back to top
View user's profile Send private message
Ralph Zbrog

New User


Joined: 21 Nov 2009
Posts: 58
Location: California

PostPosted: Wed Dec 09, 2009 4:39 pm    Post subject:
Reply with quote

By default, Natural will translate double-quotes to single-quotes at compile time, presuming that you will be using double-quotes within literal strings to represent apostrophes. For example, to write the name O'Brien, you could code
Code:
WRITE 'O"Brien'

which I find easier than
Code:
WRITE 'O''Brien'


This action is controlled by the TQ and TQMARK parameters. To set it programmatically, code an OPTIONS statement.
Code:
DEFINE DATA LOCAL
1 #A (A1) INIT <'"'>     /* Translates to apostrophe
END-DEFINE
WRITE #A #A (EM=H)
OPTIONS TQMARK=OFF       /* Do not translate
#A := '"'
WRITE #A #A (EM=H)
END


The output will look like this:
Quote:
Page 1

' 7D
" 7F


The other solution is to specify the double-quote as a hexadecimal value.
Code:
DEFINE DATA LOCAL
1 #STRING (A40)
1 #DQ (A1)         INIT <H'7F'>        /* Double-quote
END-DEFINE
READ WORK 1 #STRING
  WRITE 'Before:' #STRING
  EXAMINE #STRING FOR #DQ REPLACE WITH ' '
  WRITE ' After:' #STRING
END-WORK
END

Quote:
Page 1

Before: O"Brien, O"Houlihan, and O"Shaughnessy
After: O Brien, O Houlihan, and O Shaughnessy
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Thu Dec 10, 2009 11:36 am    Post subject:
Reply with quote

Please note that the OPTIONS statement is only available with Natural Optimizer Compiler.

O.
Back to top
View user's profile Send private message
Ralph Zbrog

New User


Joined: 21 Nov 2009
Posts: 58
Location: California

PostPosted: Thu Dec 10, 2009 12:53 pm    Post subject: Reply to: EXAMINE with Replace
Reply with quote

Would you check that please, Ofer71?

I created my example with Natural for Windows, which has no optimizer, and verified it on a machine that has NOC installed, but the documentation states that OPTIONS can be used for regular compiler options (as in COMPOPT) and Optimizer Compiler options (as in NOCOPT).
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Thu Dec 10, 2009 1:11 pm    Post subject:
Reply with quote

Just checked it in my z/OS (no NOC) - not allowed.

O.
Back to top
View user's profile Send private message
Steve Robinson

New User


Joined: 14 Nov 2009
Posts: 12
Location: U.S.

PostPosted: Thu Dec 17, 2009 4:19 am    Post subject:
Reply with quote

A note about the word FULL in the EXAMINE statement.

Basically, FULL means trailing blanks count. One should not scatter FULLs through an EXAMINE "hoping" for a good result.

Consider:

1 #A (A10) INIT <'AB C'>

EXAMINE #A FOR ' ' GIVING NUMBER #N /* #N is 1

EXAMINE FULL #A FOR ' ' GIVING NUMBER #N /* #N is 7

---------------------

1 #A (A30) INIT <'LOOKING FOR WORDS THAT END IN R'>

1) EXAMINE #A FOR 'R ' GIVING NUMBER #N /* #N is 3

2) EXAMINE #A FOR FULL 'R ' GIVING NUMBER #N /* #N is 1

3) EXAMINE FULL #A FOR FULL 'R ' GIVING NUMBER #N /* #N is 2

Explanations

1) without the word FULL before 'R ' this is looking for R's.

2) with the word FULL, this is looking for 'R '. HOWEVER, without the word FULL before #A, the final R (which does have a blank, actually, a bunch of them, after the R) does not count

3) with both FULLs, the final R counts

Understand what the statement does, then use the optional words/clauses to fit your needs.

-----------------

steve
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 -> Java & MQSeries All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Replace repeated JCL with looping REXX prino CLIST & REXX 3 Thu Oct 13, 2016 5:30 am
This topic is locked: you cannot edit posts or make replies. Sort card to replace text using cross... Susanta SYNCSORT 32 Tue Sep 13, 2016 4:17 pm
No new posts Replace function abdulrafi COBOL Programming 13 Mon Sep 12, 2016 10:12 am
No new posts Need a help how to replace a string i... gurunath82 CLIST & REXX 12 Tue Jul 26, 2016 11:43 pm
No new posts DFSORT - FIND AND REPLACE Other Field... Arunraj Murugaiyan DFSORT/ICETOOL 6 Fri Feb 12, 2016 1:52 pm


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