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
 

 

Need to remove First special charecter in the string

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
SHAILESH OZA

New User


Joined: 10 Jun 2005
Posts: 21
Location: Mumbai

PostPosted: Mon Jul 11, 2011 12:10 pm    Post subject: Need to remove First special charecter in the string
Reply with quote

HI,

Having requirement, If very first charecter in the string is any of the special charecter then It needs to be replaced by alphabet. Is there any shortest way to do this? Like any cobol function is available to check the values of special charecter
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Mon Jul 11, 2011 12:32 pm    Post subject:
Reply with quote

Your requirement is about as clear as mud.

Please specify exactly what it is that you want to do, specify special characters, which letter of the alphabet replaces which special character, are there any exceptions to the rule.

DSORG, RECFM and LRECL of input file.

Not too much to ask is it.
Back to top
View user's profile Send private message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Mon Jul 11, 2011 1:03 pm    Post subject:
Reply with quote

Also give us some sample input and sample output...
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2429
Location: Netherlands, Amstelveen

PostPosted: Mon Jul 11, 2011 1:07 pm    Post subject:
Reply with quote

And last but not least, what did you try yourself?
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Mon Jul 11, 2011 1:22 pm    Post subject: Re: Need to remove First special charecter in the string wit
Reply with quote

SHAILESH OZA wrote:
Having requirement, If very first charecter in the string is any of the special charecter then It needs to be replaced by alphabet. Is there any shortest way to do this? Like any cobol function is available to check the values of special charecter
There is no such intrinsic function in COBOL. How would COBOL, for your given application, understand that what is "special character"?

For COBOL, you need to define some working-storage variable to list your special character-set, then there you go.

This earlier thread also have a hint: http://ibmmainframes.com/viewtopic.php?t=49281&highlight= , there are some more threads in the forum on similar topic. Please search.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7307

PostPosted: Mon Jul 11, 2011 3:47 pm    Post subject:
Reply with quote

Code:
05  W-STRINGY-THING.
    10  W-ST-FIRST-BYTE PIC X.
        88  W-ST-FIRST-BYTE-TO-BE-REPLACED VALUE "<", "@", etc.
    10  FILLER PIC X(??).


IF W-ST-FIRST-BYTE-TO-BE-REPLACED
    MOVE whatever-you-decide TO W-ST-FIRST-BYTE
END-IF
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: Tue Jul 12, 2011 7:37 am    Post subject: Reply to: Need to remove First special charecter in the stri
Reply with quote

Try INSPECT TALLYING -

Code:

MOVE ZERO TO TALLY.

INSPECT WS-STRING TALLYING TALLY FOR CHARACTERS BEFORE INITIAL 'SPECIAL CHARACTER'.

MOVE 'REPLACEMENT CHARACTER' TO WS-STRING (TALLY + 1:1).

WS-STRING is the made up field.

To make things easier, the 'SPECIAL CHARACTER' should be coded in hex-notation, so there's no question of intent.

I can't recall (CRS, ya know) if the REFERENCE MODIFICATION uses TALLY or TALLY + 1 to get to the target offset, so you'll need to fool with it or another member can verify.

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

New User


Joined: 10 Jun 2005
Posts: 21
Location: Mumbai

PostPosted: Tue Jul 12, 2011 2:47 pm    Post subject:
Reply with quote

Well, i applied the below logic

i am getting input from cics screen.

I declare variable WS-FIRST CHAR to store the first charecter of the name. on the 88 LEVEL OF THE VARIABLE, GIVEN THE VALUES OF SPEICAL CHARECTERS LIKE QUOTE, @ # THEN CHECKING THIS IN IF CLAUSE AND IF 88 LEVEL IS TRUE THEN MOVING ALPHABET IN THAT THAT IS WHAT IS WHAT THE SOLUTION I HAVE PROVIDED FOR MY REQUIREMENT
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 Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
No new posts Remove junk values in a file and rite... KP1125 DFSORT/ICETOOL 2 Wed Jan 25, 2017 9:58 pm
No new posts Sort Card to Remove Duplicate records... raj4neo SYNCSORT 2 Wed Jan 25, 2017 4:44 am
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am


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