View previous topic :: View next topic
|
Author |
Message |
Sudhanshu Shekhar
New User
Joined: 23 Jul 2008 Posts: 27 Location: City of Joy
|
|
|
|
Hi All,
The requirement states to replace all unnecessary alphanumeric characters with * .
For Example
Code: |
0123456789 Transaction Not Found shekhar1 |
This Should be converted to
Code: |
********** Transaction Not Found ******** |
The issue is neither the length of such numeric characters is fixed nor is their position. It can be "Transaction Not Found ********"
Thanks in advance |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
How do you make the difference between the necessary and the unnecessary ?? |
|
Back to top |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
Hi Sudhanshu,
You have specified ur requirement. What is it that you want our help with ?? |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Quote: |
... neither the length of such numeric characters is fixed nor is their position... |
the issue is that the gentleman is trying to discover what cannot be discovered
at least reading the quoted fragment - but, maybe as too often happens, he simply forgot to tell something |
|
Back to top |
|
|
Sudhanshu Shekhar
New User
Joined: 23 Jul 2008 Posts: 27 Location: City of Joy
|
|
|
|
@ Marso
I need only "Trans not found" the rest of the characters have to be masked.
@binop
I need assistance on how i can mask the characters when the length and position is dynamic |
|
Back to top |
|
|
Sudhanshu Shekhar
New User
Joined: 23 Jul 2008 Posts: 27 Location: City of Joy
|
|
|
|
@enrico ....
it might be my inability to present you with the exact request but the requirement is a lil fuzzy and i am still trying to figure it out. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
still You are not telling much more
let' s see
You have a file with some lines/records where a string transaction not found is the trigger to do some processing
( the value of the string is not really an issue as long as it is unique in the file)
now in simple steps describe what You have to do...
for example
...
if the string is found substitute the first word after it with asterisks
-here word means a sequence of chars delimited by blanks
the ball is in Your court now for a better explanation of Your requirement |
|
Back to top |
|
|
Sudhanshu Shekhar
New User
Joined: 23 Jul 2008 Posts: 27 Location: City of Joy
|
|
|
|
@enrico
yes u got it right.
There are some records where a string "Transaction Not Found" exits which will be used for some further trigger.
However the postion of the string "Transaction Not Found" is not fixed. It might be after the first word (delimited by space) or the second word or it can even be the first word itself. It also might have a few characters after the word " found".
I need to subtitute all characters except for the string "Transaction Not Found" by *. |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Quote: |
I need to subtitute all characters except for the string "Transaction Not Found" by *.
|
This code will do needful ..
Note multiple occurance of string to be found is not covered here..
Code: |
WORKING-STORAGE SECTION.
01 MYVAR1 PIC X(40) VALUE
'0123456789 Transaction Not Found shekhar'.
*01 MYVAR1 PIC X(40) VALUE
* 'Transaction Not Found some data here '.
*01 MYVAR1 PIC X(40) VALUE
* 'SOME DATA here Transaction Not Found'.
01 MYVAR2 PIC X(40) VALUE ALL '*'.
01 WS-I PIC 99 VALUE 1.
01 WS-STRFND-CNT PIC 99 VALUE 0.
PROCEDURE DIVISION.
BEGIN.
PERFORM PARA1 VARYING WS-I FROM 1 BY 1 UNTIL WS-I > 20
IF WS-STRFND-CNT NOT = 0
MOVE 'Transaction Not Found'
TO MYVAR2(WS-STRFND-CNT:21)
END-IF
DISPLAY MYVAR1
DISPLAY MYVAR2
STOP RUN.
PARA1.
IF MYVAR1(WS-I:21) = 'Transaction Not Found'
MOVE WS-I TO WS-STRFND-CNT
ELSE
CONTINUE
END-IF.
|
|
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Sudhanshu: Sambhaji didn't ask -- how long can the strings be? The solution posted only works for 40-character strings such as you had in your first post. Are the strings coming from a file or a terminal or ? And where are the masked results going -- to a file, a terminal, or ? Can you have multiple occurrences of the TRANSACTION NOT FOUND in a single string / record ? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
I suspect this:
Code: |
MOVE 'Transaction Not Found' |
may need to be:
Code: |
MOVE ' Transaction Not Found ' |
.
Also, there may be a requirement that "*" replace positions with a value (up to the trailing spaces) rather than replacing all positions with "*"? |
|
Back to top |
|
|
|