MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Parse and Replace Characters

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
JD2008
Beginner


Joined: 11 Apr 2008
Posts: 2
Topics: 1

PostPosted: Fri Apr 11, 2008 3:58 pm    Post subject: Parse and Replace Characters Reply with quote

Greetings,

I am working on a file that has a last name field on positions 1 to 20 and a name suffix field on positions 21 to 24. The last name field may or may not contain suffixes such as JR, SR, II, III, etc. If the suffixes are present in the last name field, the suffix field itself is blank. In order to standardize the name fields, I would like to do the following:
    Convert the value of the name suffix field as follows:
    JR to J
    SR to S
    II to 2
    III to 3

    Search for the string of JR, SR, II, III, etc on the last name field. If those values are found, remove them from the last name field, convert the suffixes, and move them to the name suffix field. The values will be converted as follows:
    JR to J
    SR to S
    II to 2
    III to 3....

The input file has the following names:
Code:

----+----1----+----2----+
MOXLE               SR
MOXLE SR
DE LA PAZ           JR
DE LA PAZ II


I would like the output to appear as follows:
Code:

----+----1----+----2----+
MOXLE               S
MOXLE               S
DE LA PAZ           J
DE LA PAZ           2


Can I do the above with DFSORT/ICETOOL, or should I code a program instead?

Thanks,
JD
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Apr 14, 2008 2:25 pm    Post subject: Reply with quote

Here's a DFSORT job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/24)
//SORTOUT DD DSN=...  output file (FB/24)
//SYSIN    DD    *
  OPTION COPY
  INREC IFOUTLEN=24,
   IFTHEN=(WHEN=(1,24,SS,EQ,C' JR'),
    PARSE=(%01=(ENDBEFR=C' JR',FIXLEN=20)),
    BUILD=(%01,21:C'J')),
   IFTHEN=(WHEN=(1,24,SS,EQ,C' SR'),
    PARSE=(%02=(ENDBEFR=C' SR',FIXLEN=20)),
    BUILD=(%02,21:C'S')),
   IFTHEN=(WHEN=(1,24,SS,EQ,C' III'),
    PARSE=(%04=(ENDBEFR=C' III',FIXLEN=20)),
    BUILD=(%04,21:C'3')),
   IFTHEN=(WHEN=(1,24,SS,EQ,C' II'),
    PARSE=(%03=(ENDBEFR=C' II',FIXLEN=20)),
    BUILD=(%03,21:C'2'))
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
JD2008
Beginner


Joined: 11 Apr 2008
Posts: 2
Topics: 1

PostPosted: Mon Apr 14, 2008 2:46 pm    Post subject: Reply with quote

Very ingenious solution, Frank. I see how you treated the two fields as one, and used the substring function to look for the suffixes. You are certainly not only the guru, but also very creative with the functions.

Thank you for your help. This will help me streamline and speed up my process as this file has about 80 million records.

JD
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group