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

Replace Sign by '('


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

New User


Joined: 28 Nov 2006
Posts: 69
Location: India

PostPosted: Fri Nov 06, 2009 3:34 pm
Reply with quote

My field is defined as

01 FIELD PIC -,---,--9.99.
01 FIELD-R REDIFINES FIELD PIC X(12).


Some numeric value is moved in FIELD, e.g. -101.75
when displayed it prints as -101.75

What I want to print is (101.75)

I can eazily put ')' as it's position is fix. Problem is with '(' as its position depends upon the size of the number.
We are using '-' for leading zero suppressing. Can i use INSPECT to replace this '-' with '('.



I have tried

INSPECT FIELD RELACING '-' BY '('

INSPECT FIELD-R RELACING '-' BY '(' ......... Nothing is working

Any work around ??
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Nov 06, 2009 4:02 pm
Reply with quote

1) The COBOL code you posted won't compile -- it is REPLACING not RELACING. This is why people are told, repeatedly, to cut and paste the code instead of typing it again -- typos can drastically change the meaning of the posted code.

2) Have you tried INSPECT FIELD-R REPLACING FIRST '-' BY '('. ?
Back to top
View user's profile Send private message
donevin

New User


Joined: 07 Jun 2005
Posts: 70
Location: South Africa

PostPosted: Fri Nov 06, 2009 4:20 pm
Reply with quote

INSPECT FIELD-R (or FIELD) REPLACING ALL "-" BY "(".

works for me
Back to top
View user's profile Send private message
hsk

New User


Joined: 28 Nov 2006
Posts: 69
Location: India

PostPosted: Fri Nov 06, 2009 5:20 pm
Reply with quote

donevin wrote:
INSPECT FIELD-R (or FIELD) REPLACING ALL "-" BY "(".

works for me



I have tried LEADING '-' ..not ALL

will check

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

New User


Joined: 28 Nov 2006
Posts: 69
Location: India

PostPosted: Fri Nov 06, 2009 5:54 pm
Reply with quote

That works ......

Probably the "LEADING" in the command was causing problems


Thanks you guys !!
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Nov 06, 2009 6:05 pm
Reply with quote

Since the first character in your field, once substituted, is a space and not a '(' the LEADING won't work. FIRST will work, ALL will work -- but LEADING means leading: if there's another character in the first position instead of the character you're looking for, the INSPECT is done.
Back to top
View user's profile Send private message
donevin

New User


Joined: 07 Jun 2005
Posts: 70
Location: South Africa

PostPosted: Fri Nov 06, 2009 6:25 pm
Reply with quote

First is then the most accurate in terms of syntax and intention in my opinion.
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 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