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

EXAMINE with Replace


IBM Mainframe Forums -> Java & MQSeries
Post new topic   Reply to topic
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
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: 2358
Location: Israel

PostPosted: Tue Sep 22, 2009 12:50 am
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
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
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: 2358
Location: Israel

PostPosted: Thu Dec 10, 2009 11:36 am
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
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: 2358
Location: Israel

PostPosted: Thu Dec 10, 2009 1:11 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Java & MQSeries

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts replace word 'MONTH' with current mon... SYNCSORT 11
No new posts To replace jobname in a file with ano... SYNCSORT 12
No new posts Conditional replace values in output ... DFSORT/ICETOOL 3
Search our Forums:

Back to Top