AS/400 Code Samples - AS/400 - STRIP_HYFN - GSS Strip out the hyphens from SSN. Author: George Pearson Company: Green Springs Software, Inc. www.green-springs.com Purpose: Example Program to Strip out characters from a string This example reads a formatted Social Security Number (with hyphens) and returns a string of 9 digits. This is an example program only. Components: STRIP_HYFN QPGLESRC Program Parameters: *None ¹*--------------------------------------------------------------------------------------------* ¹* G r e e n S p r i n g s S o f t w a r e , I n c Ashland, Oregon * ¹*--------------------------------------------------------------------------------------------* ¹* Object Name: STRIP_HYFN * ¹* Description: Strip out the Hyphens from SSN. * ¹* Narrative : This program reads a formatted Social Security Number * ¹* (nnn-nn-nnnn) and strips out the hyphens, leaving only * ¹* the 9 digits. This example can be used as the basis for * ¹* stripping characters from phone numbers, Zip+5, etc. * ¹* Creation : 04/28/2003 * ¹* Author : George Pearson, Green Springs Software, Inc. * ¹* george@green-springs.com www.green-springs.com * ¹*--------------------------------------------------------------------------------------------* ¹*--------------------------------------------------------------------------------------------* ¹* This simple example of an IBM RPG-ILE program doing String * ¹* Processing. This is only an example, as it does nothing with the stripped out * ¹* digits. You will need to capture the value of @new_prss and use it in your code. * ¹* Input = nnn-nn-nnnn Output = nnnnnnnnn * ¹*--------------------------------------------------------------------------------------------* FPRPMS IF E DISK * éWorking Varibles * ¹---------------- d @Loc s 3 0 d @New_prss s 9 c dou *InLR = *On c read prrms LR c if *InLR = *Off c eval @Loc = %scan('-' : prss) c dow @Loc <> 0 c eval prss = %subst(prss :1:@Loc - 1) c + %subst(prss : @Loc + 1:11 - @Loc) c eval @Loc = %scan('-' : prss) c EndDO c eval @new_prss = prss c EndIF c EndDO ã*---------------- End Of Source STRIP_HYFN -------------------------------------------------*