View previous topic :: View next topic
|
Author |
Message |
SHAILESH OZA
New User
Joined: 10 Jun 2005 Posts: 21 Location: Mumbai
|
|
|
|
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
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 |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
Also give us some sample input and sample output... |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
And last but not least, what did you try yourself? |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
SHAILESH OZA
New User
Joined: 10 Jun 2005 Posts: 21 Location: Mumbai
|
|
|
|
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 |
|
|
|