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

Masking Logic


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Jul 14, 2010 3:32 pm
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
Reply with quote

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

Global Moderator


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

PostPosted: Wed Jul 14, 2010 3:49 pm
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: 2146
Location: At my coffee table

PostPosted: Wed Jul 14, 2010 6:40 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Masking variable size field - min 10 ... DFSORT/ICETOOL 4
No new posts Finding faulty logic Subscript out of... COBOL Programming 5
This topic is locked: you cannot edit posts or make replies. Need assistance in job scheduling logic. Mainframe Interview Questions 2
No new posts Rexx Logic error while adding seperat... CLIST & REXX 3
No new posts PL/1 Callback address logic in z/OS C... PL/I & Assembler 1
Search our Forums:

Back to Top