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

Need to remove First special charecter in the string


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 8797
Location: Welsh Wales

PostPosted: Mon Jul 11, 2011 12:32 pm
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
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: 2481
Location: Netherlands, Amstelveen

PostPosted: Mon Jul 11, 2011 1:07 pm
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

Superior Member


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

PostPosted: Mon Jul 11, 2011 1:22 pm
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: 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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Jul 11, 2011 3:47 pm
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Tue Jul 12, 2011 7:37 am
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
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 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 PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Remove leading zeroes SYNCSORT 4
No new posts file manager is doing string conversion IBM Tools 3
Search our Forums:

Back to Top