Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cobol parsing

Status
Not open for further replies.

rubby

Programmer
Joined
Aug 25, 2002
Messages
1
Location
US
How do I count through a text field one character at a time? I've looked at reference modification and things like that, but nothing seems to work so far. I need to be able to store the position of specific characters and count them one at a time so that I know which characters to overwrite. Example of the problem: finding credit card numbers in a text field. Must replace these numbers (unformatted: could be 16 digits together or with delimiters such as dashes, etc) with zeros. Suggestions? Examples?
 
What I would do is setup a counter field to then check each position one by one. For example:

MOVE 1 TO START-POS.
MOVE 1 TO NEW-POINTER.
PERFORM UNTIL START-POS >= 16
IF TEXT-FIELD (START-POS:1) >= 0
AND TEXT-FIELD (START-POS:1) <= 9
STRING TEXT-FIELD (START-POS:1) DELIMITED BY SIZE
INTO NEW-TEXT-FIELD
WITH POINTER NEW-POINTER
END-STRING
END-IF
ADD 1 TO START-POS
END-PERFORM.

This will then read your original field (TEXT-FIELD), strip out any characters other than the numbers 0-9, and place this new value into a new field (NEW-TEXT-FIELD).

Hope this helps!
 
Hi rubby,

Not sure I understand.

Do you want to zero out a cc#?
You said &quot;Must replace these numbers ... with zeros&quot;.

Do you have a large field w/multiple cc#s in it?
Or do you want to find the #s of a cc#, but ignore the dashes, etc.
You said &quot;...finding credit card numbers in a text field&quot;.

How many types of delimiters do you have?
You said &quot;delimiters such as dashes, etc&quot;.

Maybe showing us some real data and talking from that might help.

Regards, Jack.
If they can be anything, you may have a problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top