Skip to Content
0
Jul 02, 2007 at 08:11 PM

How can I "x-out" all but the last 4 digits of a value?

11 Views

Good day, everyone!

I searched on this topic this morning, came up with nothing, and decided to try to tackle it myself. After 5 1/2 hours, I'm throwing in the towel and need some help.

I'm writing out a simple report, and part of the output is an Account Number. I have it stored in a character field with length 10. The Account Number may be 7characters in length, while at other times it may be 9. It varies because the Account Number is coming from various bank sources, so each one has its own "standard."

For security reasons, I would like to "x-out" all but the last 4 digits of each Account Number. For example:

If the Account Number is 1234567, the report should show it as XXX4567. If the Account Number is 987654321, the report should show it as XXXXX4321. The end user viewing the report can tell the account by the last 4 digits being displayed.

I've tried all sorts of ways to get this to work, but I'm having trouble. A lot of it is getting hung up on the length of the field. I keep getting a length of 10, which I understand because the field is defined as character length 10. But I'm trying to figure out the "true" length of the field.

Does anyone have a quick, simple little ABAP routine that will handle this?

Thanks so much, and points will be awarded for all helpful answers!

Dave