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

Mask unneccesary characters with *


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

New User


Joined: 23 Jul 2008
Posts: 27
Location: City of Joy

PostPosted: Mon Jul 13, 2009 11:38 am
Reply with quote

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
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Mon Jul 13, 2009 11:40 am
Reply with quote

How do you make the difference between the necessary and the unnecessary ??
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Mon Jul 13, 2009 11:45 am
Reply with quote

Hi Sudhanshu,

You have specified ur requirement. What is it that you want our help with ??
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Jul 13, 2009 12:14 pm
Reply with quote

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 icon_cool.gif
at least reading the quoted fragment - but, maybe as too often happens, he simply forgot to tell something
Back to top
View user's profile Send private message
Sudhanshu Shekhar

New User


Joined: 23 Jul 2008
Posts: 27
Location: City of Joy

PostPosted: Mon Jul 13, 2009 12:14 pm
Reply with quote

@ 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
View user's profile Send private message
Sudhanshu Shekhar

New User


Joined: 23 Jul 2008
Posts: 27
Location: City of Joy

PostPosted: Mon Jul 13, 2009 12:18 pm
Reply with quote

@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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Jul 13, 2009 12:27 pm
Reply with quote

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
View user's profile Send private message
Sudhanshu Shekhar

New User


Joined: 23 Jul 2008
Posts: 27
Location: City of Joy

PostPosted: Mon Jul 13, 2009 12:46 pm
Reply with quote

@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
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Mon Jul 13, 2009 7:57 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Mon Jul 13, 2009 8:26 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Jul 13, 2009 8:52 pm
Reply with quote

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
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 Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts Reading dataset in Python - New Line ... All Other Mainframe Topics 22
No new posts Count the number of characters in a f... CA Products 1
No new posts Want to mask Middle 8 Digits of Debit... COBOL Programming 3
No new posts Assembler: Set Program Mask for decim... PL/I & Assembler 4
Search our Forums:

Back to Top