Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
Masking Logic

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL
Author Message
Meenakshi Selvaraj

New User


Joined: 30 Oct 2009
Posts: 14
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
References
Bill O'Boyle

Senior Member


Joined: 14 Jan 2008
Posts: 1260
Location: South Carolina, 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: 14
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

Senior Member


Joined: 20 Oct 2006
Posts: 4457
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: 2216
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
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL All times are GMT + 6 Hours
Page 1 of 1