Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Masking Logic

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

New User


Joined: 30 Oct 2009
Posts: 36
Location: Chennai

PostPosted: Wed Jul 14, 2010 3:24 pm    Post subject: Masking Logic
Reply with quote

How to mask particular digits in a variable in cobol?

For example, i have account number say 16 digits number (9999999999999999). I need it as xxxxxxxxxxxxx999.

Account number may be of variable length also.
Example, (99999), I need it as xx999.

Let me know the logic how to get this format.
Back to top
View user's profile Send private message

Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2504
Location: Atlanta, Georgia, USA

PostPosted: Wed Jul 14, 2010 3:32 pm    Post subject: Reply to: Masking Logic
Reply with quote

Unless I'm missing something, I believe you answered your own question. Prefix the variable with as many X's as needed and suffix it with the last three digits.

Move the account-number to a display PIC X field and perform this editing.

Bill
Back to top
View user's profile Send private message
Meenakshi Selvaraj

New User


Joined: 30 Oct 2009
Posts: 36
Location: Chennai

PostPosted: Wed Jul 14, 2010 3:37 pm    Post subject: Reply to: Masking Logic
Reply with quote

Thanks Bill.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Wed Jul 14, 2010 3:49 pm    Post subject:
Reply with quote

Well, first, since replacement/insertion editing does not allow for the 'x' (or 'X') char, I would simply make my account display field a group item,
subdefined into number of x's and 999.

Code:
05  ACCOUNT-DISPLAY.
      10  FILLER                  PIC X(13).
           88  ACCT-LEN-6     VALUE '          XXX'.
           88  ACCT-LEN-7     VALUE '         XXXX'.
           88  ACCT-LEN-8     VALUE '        XXXXX'.
           88  ACCT-LEN-9     VALUE '       XXXXXX'.
           88  ACCT-LEN-10    VALUE '      XXXXXXX'.
           88  ACCT-LEN-11    VALUE '     XXXXXXXX'.
           88  ACCT-LEN-12    VALUE '    XXXXXXXXX'.
           88  ACCT-LEN-13    VALUE '   XXXXXXXXXX'.
           88  ACCT-LEN-14    VALUE '  XXXXXXXXXXX'.
           88  ACCT-LEN-15    VALUE ' XXXXXXXXXXXX'.
           88  ACCT-LEN-16    VALUE 'XXXXXXXXXXXXX'.
     10  DISPLAY-LAST-3    PIC 9(3).


MOVE ACCOUNT-NUMBER TO DISPLAY-LAST-3
EVALUATE LENGTH OF ACCOUNT-NUMBER
     WHEN 16
              SET ACCT-LEN-16  TO TRUE   
     WHEN 15
              SET ACCT-LEN-15  TO TRUE   
     WHEN 14
              SET ACCT-LEN-14  TO TRUE   
     WHEN 13
              SET ACCT-LEN-13  TO TRUE   
     WHEN 12
              SET ACCT-LEN-12  TO TRUE   
     WHEN 11
              SET ACCT-LEN-11  TO TRUE   
     WHEN 10
              SET ACCT-LEN-10  TO TRUE   
     WHEN 9
              SET ACCT-LEN-9    TO TRUE   
     WHEN 8
              SET ACCT-LEN-8    TO TRUE   
     WHEN 7
              SET ACCT-LEN-7    TO TRUE   
     WHEN OTHER
              SET ACCT-LEN-6    TO TRUE   
END-EVALUATE
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Wed Jul 14, 2010 6:40 pm    Post subject:
Reply with quote

You might also look at Representing zero suppression.

Code:
05  MASKED-ACCT-NUMBER   PIC *************999.
05  UNMASKED-ACCT-NUMBER PIC 9(16).
05  LAST3-ACCT-NUMBER    PIC 9(3).

MOVE UNMASKED-ACCT-NUMBER TO LAST4-ACCT-NUMBER.
MOVE LAST3-ACCT-NUMBER    TO MASKED-ACCT-NUMBER.
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 Need help in building a logic Benchwarmer All Other Mainframe Topics 4 Wed Feb 22, 2017 2:49 am
No new posts Masking Db2 data kishpra DB2 3 Fri Sep 02, 2016 9:23 pm
No new posts Wildcard logic in COBOL dudenithy COBOL Programming 13 Thu Sep 01, 2016 7:36 pm
No new posts Sort Logic to extract data scorp_rahul23 DFSORT/ICETOOL 13 Tue Mar 01, 2016 1:22 am
No new posts Need a logic to validate the data in ... sandeep kumar302 COBOL Programming 17 Mon Feb 01, 2016 3:30 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us