IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Formatting Names Upper to Lower Excluding the first Char


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
shajeeth

New User


Joined: 25 May 2005
Posts: 20

PostPosted: Wed Dec 10, 2014 10:17 pm
Reply with quote

Hi,

I have a requirement to format the case of Names in a particular position in an FB file and write to output file.
The total length of the file being 507 bytes, FB File

The layout would be as follows:

1. Customer Number X(10)
2. Customer ID X(18)
3. Email ID X(100)
4. Title X(30)
5. Customer Name X(200)
6. Customer Address X(149)

The sample of the input file would be quite similar to this:

Code:
X123456775|1234567890123456|xyz@gmail.com                   |MR        |JOHN WESLEY SAM       |14,MAINSTREET LONDON|

X123456775|12345678906565|abc@gmail.com                   |MR        |DEL-RAFAEL          |1,STREET NEWYORK|

X11111111|123456786456346354|mno@gmail.com                   |MR        |O'KEEFE          |16,STREET MANCHESTER|

X222222222|123456786456336452634|mno@gmail.com                   |MR        |SAMSON         |19,STREET MUMBAI     |

X3333333|1234567864565555555|fgc@gmail.com                   |MR        |SURESH MENON       |19,STREET TRIVANDUM     |

My requirement is to write an output file with the Customer names to have a upper case on the first letter of each word and remaining as lower case. If there single apostophe then the first character after apostophe needs to upper and the character before it needs to be upper too.

The expected Output could be as below:

Code:
X123456775|1234567890123456|xyz@gmail.com                   |MR        |John Wesley  Sam     |14,MAINSTREET LONDON|

X123456775|12345678906565|abc@gmail.com                   |MR        |Del-Rafael          |1,STREET NEWYORK|

X11111111|123456786456346354|mno@gmail.com                   |MR        |O'Keefe          |16,STREET MANCHESTER|

X222222222|123456786456336452634|678@gmail.com                   |MR        |Samson         |19,STREET MUMBAI     |

X3333333|1234567864565555555|fgc@gmail.com                   |MR        |Suresh Menon       |19,STREET TRIVANDUM     |

There will be no space before the names and the character between the names would be either space,- or ', no other character is expected.

The limitation being that this should be done using DFSORT, i have been trying PARSE,BUILD and OVERLAY from the forum, however i am not able to reach at the solution

Multiple sort steps are fine, Any suggestions/build for this would be helpful.

Thanks!

Let me know in case if you have any queries.

Code'd
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Dec 10, 2014 10:40 pm
Reply with quote

did you check the sort smart tricks to see if there is something there at
www-01.ibm.com/support/docview.wss?uid=isg3T7000094

the first idea that comes to mind is
to translate everything to lower case
then change
" a" to " A"
...
...
...
" z" to " Z"

might not be the smartest one but it should work
Back to top
View user's profile Send private message
shajeeth

New User


Joined: 25 May 2005
Posts: 20

PostPosted: Wed Dec 10, 2014 10:58 pm
Reply with quote

enrico-sorichetti wrote:
did you check the sort smart tricks to see if there is something there at
www-01.ibm.com/support/docview.wss?uid=isg3T7000094

the first idea that comes to mind is
to translate everything to lower case
then change
" a" to " A"
...
...
...
" z" to " Z"

might not be the smartest one but it should work


I did check the DFSORT tricks document before i posted on the forum, didnot find a solution for the requirement.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Dec 11, 2014 12:02 am
Reply with quote

Quote:
then change
" a" to " A"
...
...
...
" z" to " Z"

Maybe extenting it to
Quote:

" a" to " A"
...
...
...
...
" z" to " Z"
"'a" to "'A"
...
...
...
...
"'z" to "'Z"
would give you what you want.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Dec 11, 2014 12:40 am
Reply with quote

Since the name field is 200 bytes long, so with a theoretical maximum of 100 name elements, plus the need to deal with the apostrophe and the hyphen and then to put everything back together and give it a squeeze, enrico's idea (and noting Craq's extension) is not a bad way to do it. Should be able to all fit in one FINDREP.

IFTHEN=(WHEN=INIT with OVERLAY to change to lower-case position 160 for a length of 199 (leaving the first as upper-case or blank) and then another IFTHEN=(WHEN=INIT with a big FINDREP from 159 for a length of 200.

You may or may not want to consider the names MacMillan and McMillan.
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Thu Dec 11, 2014 12:13 pm
Reply with quote

Hi ,

I don't know if this is an efficient way to do it, But you can try this example, but please note that this is based on SYNCSORT.

Code:
//STEP01   EXEC PGM=SORT                               
//SORTIN   DD *                                         
JOHN WESLEY SAM                                         
DEL-RAFAEL                                             
O'KEEFE                                                 
SAMSON                                                 
SURESH MENON                                           
//SORTOUT  DD SYSOUT=*                                 
//SYSOUT   DD SYSOUT=*                                 
//SYSIN    DD *                                         
   OPTION COPY                                         
   INREC  IFTHEN=(WHEN=INIT,                           
                  OVERLAY=(2:2,30,TRAN=UTOL)),         
          IFTHEN=(WHEN=(02,1,CH,EQ,L(C' ',C'-',C'''')),
                  OVERLAY=(03:03,1,TRAN=LTOU),HIT=NEXT),
          IFTHEN=(WHEN=(03,1,CH,EQ,L(C' ',C'-',C'''')),
                  OVERLAY=(04:04,1,TRAN=LTOU),HIT=NEXT),
          IFTHEN=(WHEN=(04,1,CH,EQ,L(C' ',C'-',C'''')),
                  OVERLAY=(05:05,1,TRAN=LTOU),HIT=NEXT),
          IFTHEN=(WHEN=(05,1,CH,EQ,L(C' ',C'-',C'''')),
                  OVERLAY=(06:06,1,TRAN=LTOU),HIT=NEXT),
          IFTHEN=(WHEN=(06,1,CH,EQ,L(C' ',C'-',C'''')),
                  OVERLAY=(07:07,1,TRAN=LTOU),HIT=NEXT),
          IFTHEN=(WHEN=(07,1,CH,EQ,L(C' ',C'-',C'''')),
                  OVERLAY=(08:08,1,TRAN=LTOU),HIT=NEXT),
          IFTHEN=(WHEN=(08,1,CH,EQ,L(C' ',C'-',C'''')),
                  OVERLAY=(09:09,1,TRAN=LTOU),HIT=NEXT),
          IFTHEN=(WHEN=(09,1,CH,EQ,L(C' ',C'-',C'''')), 
                  OVERLAY=(10:10,1,TRAN=LTOU),HIT=NEXT),
          IFTHEN=(WHEN=(10,1,CH,EQ,L(C' ',C'-',C'''')), 
                  OVERLAY=(11:11,1,TRAN=LTOU),HIT=NEXT),
          IFTHEN=(WHEN=(11,1,CH,EQ,L(C' ',C'-',C'''')), 
                  OVERLAY=(12:12,1,TRAN=LTOU),HIT=NEXT),
          IFTHEN=(WHEN=(12,1,CH,EQ,L(C' ',C'-',C'''')), 
                  OVERLAY=(13:13,1,TRAN=LTOU),HIT=NEXT),
          IFTHEN=(WHEN=(13,1,CH,EQ,L(C' ',C'-',C'''')), 
                  OVERLAY=(14:14,1,TRAN=LTOU),HIT=NEXT),
          IFTHEN=(WHEN=(14,1,CH,EQ,L(C' ',C'-',C'''')), 
                  OVERLAY=(15:15,1,TRAN=LTOU),HIT=NEXT),
          IFTHEN=(WHEN=(15,1,CH,EQ,L(C' ',C'-',C'''')), 
                  OVERLAY=(16:16,1,TRAN=LTOU),HIT=NEXT) 


Output:
Code:
John Wesley Sam 
Del-Rafael       
O'Keefe         
Samson           
Suresh Menon     
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Thu Dec 11, 2014 12:25 pm
Reply with quote

or may be you can try what Bill has suggested:

Code:
   OPTION COPY                                 
   INREC  IFTHEN=(WHEN=INIT,                   
                  OVERLAY=(2:2,30,TRAN=UTOL))   
   OUTREC FINDREP=(INOUT=(X'4081',X'40C1',     
                          X'6081',X'60C1',     
                          X'7D81',X'7DC1'))     


Create the findrep for all the 26 chars.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Dec 11, 2014 12:36 pm
Reply with quote

Nicely worked Mistah Kurtz. For DFSORT the L becomes a test with SS.

For a 200-byte field, there will be 200 tests per record, and probably well over 150 LTOUs. The work can probably be reduced by using AND and testing that the next byte is non-blank. This will only do the number of LTOUs necessary. Being a "one ahead" process, you need to stop one byte before the end.

SORT has no looping structures. So this code is a loop, but "flattened out".

FINDREP does its own looping, but we have to hand-code the conversion.

shajeeth,

Put the AND in and test both. Let us know if one is more rapid than the other.
Back to top
View user's profile Send private message
shajeeth

New User


Joined: 25 May 2005
Posts: 20

PostPosted: Thu Dec 11, 2014 7:42 pm
Reply with quote

Bill Woodger wrote:
Nicely worked Mistah Kurtz. For DFSORT the L becomes a test with SS.

For a 200-byte field, there will be 200 tests per record, and probably well over 150 LTOUs. The work can probably be reduced by using AND and testing that the next byte is non-blank. This will only do the number of LTOUs necessary. Being a "one ahead" process, you need to stop one byte before the end.

SORT has no looping structures. So this code is a loop, but "flattened out".

FINDREP does its own looping, but we have to hand-code the conversion.

shajeeth,

Put the AND in and test both. Let us know if one is more rapid than the other.


Thanks for the valuable suggestions!! I thought i would split the 200 bytes into 20 bytes each assuming each part of name will not be more than twenty bytes(used one of the older post from Frank Yaeger). Used PARSE and BUILD to create the output...

Code:
 OPTION COPY                                                 
 INREC IFTHEN=(WHEN=INIT,                                   
    PARSE=(%01=(ENDBEFR=C' ',FIXLEN=20,ABSPOS=165),         
           %02=(ENDBEFR=C' ',FIXLEN=20),                     
           %03=(ENDBEFR=C' ',FIXLEN=20),                     
           %04=(ENDBEFR=C' ',FIXLEN=20),                     
           %05=(ENDBEFR=C' ',FIXLEN=20),                     
           %06=(ENDBEFR=C' ',FIXLEN=20),                     
           %07=(ENDBEFR=C' ',FIXLEN=20),                     
           %08=(ENDBEFR=C' ',FIXLEN=20),                     
           %09=(ENDBEFR=C' ',FIXLEN=20),                     
           %10=(FIXLEN=20)),                                 
  BUILD=(1,164,%01,TRAN=UTOL,%02,TRAN=UTOL,%03,TRAN=UTOL, - 
 %04,TRAN=UTOL,%05,TRAN=UTOL,%06,TRAN=UTOL,%07,TRAN=UTOL,  -
%08,TRAN=UTOL,%09,TRAN=UTOL,%10,TRAN=UTOL,365,143)),       
   IFTHEN=(WHEN=INIT,                                           
      OVERLAY=(165:165,1,TRAN=LTOU,                             
             185:185,1,TRAN=LTOU,                               
             205:205,1,TRAN=LTOU,                               
             225:225,1,TRAN=LTOU,                               
             245:245,1,TRAN=LTOU,                               
             265:265,1,TRAN=LTOU,                               
             285:285,1,TRAN=LTOU,                               
             305:305,1,TRAN=LTOU,                               
             325:325,1,TRAN=LTOU,                               
             345:345,1,TRAN=LTOU)),                             
   IFTHEN=(WHEN=INIT,                                           
   BUILD=(1,164,165,200,SQZ=(SHIFT=LEFT,MID=C' ',LENGTH=200),  -
          365,143)),                             


This works perfectly fine when there i need to consider space between the words, however when there is a - or apostophe, it wont work as expected.

I know this wont give me the desired solution, however i am not sure if i can customise this accordingly for hyphen and apostophe..

Bill,

i wanted to avoid each character formatting, however i guess i may need to start looking at that option as suggested by others..

Mistah,

We use DFSORT here, will try yours, but i guess i may need to do this for 200 characters..

Code'd
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Dec 11, 2014 9:14 pm
Reply with quote

Is this a once-off exercise?

If so, you can work out the maxima - elements, length of elements and characters in total.

1) Change everything except first character of maximum-needed length to lower-case.
FINDREP, 26 for each, for blank-letter, hyphen-letter, apostrophe-letter.

2) Change everything except first character, then look byte-by-byte (hard-coded) to identify blank, hyphen and and apostrophe then change next character to upper-case. (watch the last character).

3) The PARSE approach. Need to know the number of elements (maximum) and need three sets of PARSE/SQZ, each of which will be executed (nothing to say you can't have "Rupert O'Neill-Smith".

You can make a slight saving on the PARSE code you have shown. Once you know the fixed positions (at the moment the place where the first character is returned to upper-case) instead only covert the start+1,length-1 bytes to lower-case (no other case-conversion), leaving the first untouched.

I think the PARSE route would be the most complex for your requirement.
Back to top
View user's profile Send private message
shajeeth

New User


Joined: 25 May 2005
Posts: 20

PostPosted: Thu Dec 11, 2014 10:54 pm
Reply with quote

Bill Woodger wrote:
Is this a once-off exercise?

If so, you can work out the maxima - elements, length of elements and characters in total.

1) Change everything except first character of maximum-needed length to lower-case.
FINDREP, 26 for each, for blank-letter, hyphen-letter, apostrophe-letter.

2) Change everything except first character, then look byte-by-byte (hard-coded) to identify blank, hyphen and and apostrophe then change next character to upper-case. (watch the last character).

3) The PARSE approach. Need to know the number of elements (maximum) and need three sets of PARSE/SQZ, each of which will be executed (nothing to say you can't have "Rupert O'Neill-Smith".

You can make a slight saving on the PARSE code you have shown. Once you know the fixed positions (at the moment the place where the first character is returned to upper-case) instead only covert the start+1,length-1 bytes to lower-case (no other case-conversion), leaving the first untouched.

I think the PARSE route would be the most complex for your requirement.


This is not going to be a one off exercise, this JCL is to be run daily!

Looks like Parsing is not giving me desired results, finally i have decided to try the byte by byte conversion as suggested by all here..

Since there is a potential chance of more special characters to be included, i have started to build based below
Code:

OPTION COPY                                                 
INREC IFTHEN=(WHEN=INIT,                                     
  OVERLAY=(166:166,199,TRAN=UTOL)),                         
  IFTHEN=(WHEN=(166,1,CH,EQ,C' ',OR,166,1,CH,EQ,C'-',OR,   -
               166,1,CH,EQ,C''''),                           
      OVERLAY=(167:167,1,TRAN=LTOU),HIT=NEXT),               
  IFTHEN=(WHEN=(167,1,CH,EQ,C' ',OR,167,1,CH,EQ,C'-',OR,   -
               167,1,CH,EQ,C''''),                           
      OVERLAY=(168:168,1,TRAN=LTOU),HIT=NEXT),               

....

FTHEN=(WHEN=(364,1,CH,EQ,C' ',OR,364,1,CH,EQ,C'-',OR,   -
               364,1,CH,EQ,C''''),                           
      OVERLAY=(365:365,1,TRAN=LTOU))


Any suggestions to change the coding/optimize are welcome.

Thanks for all your help!

Code'd, again
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Dec 11, 2014 11:36 pm
Reply with quote

Please use the Code tags when posting anything which needs spacing preserved.

Look at mistah kurtz's second example with FINDREP. That's three values to change lowercase a to uppercase A for your three scenarios. You just need another 25 triples, and you're set (change the positions, operate on the entire 200 bytes after UTOL for the last 199 bytes).

I think this is going to be your best shot. You don't need to code in hex literals, you can use character (C' a',C' A',C'-a',C'-A',C'''a',C'''A'....) if you prefer.

You can use SORT, Rexx, ISPF editor to knock together the FINDREP you need easily.

Another way to do the IFTHEN if you insist on that is with a big bunch of CHANGEs.

Code 20 IFTHENs. Code the FINDREP. Run on expected daily amount of data. If the IFTHENs look good, double them and repeat. If the IFTHENs give you better performance for the whole 200, then you have a possibility.
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Fri Dec 12, 2014 12:47 pm
Reply with quote

Here is an example of the first approach outlined by Bill, using FINDREP.

Code:
//STEP01   EXEC PGM=SORT                                               
//SORTIN   DD *                                                         
JOHN WESLEY SAM                                                         
DEL-RAFAEL                                                             
O'KEEFE                                                                 
SAMSON                                                                 
SURESH MENON                                                           
RUPERT O'NEILL-SMITH                                                   
//SORTOUT  DD SYSOUT=*                                                 
//SYSOUT   DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
   OPTION COPY                                                         
   INREC  IFTHEN=(WHEN=INIT,                                           
                  OVERLAY=(2:2,30,TRAN=UTOL))                           
   OUTREC FINDREP=(INOUT=(C' a',C' A',C'-a',C'-A',C'''a',C'''A',       
                          C' b',C' B',C'-b',C'-B',C'''b',C'''B',       
                          C' c',C' C',C'-c',C'-C',C'''c',C'''C',       
                          C' d',C' D',C'-d',C'-D',C'''d',C'''D',       
                          C' e',C' E',C'-e',C'-E',C'''e',C'''E',       
                          C' f',C' F',C'-f',C'-F',C'''f',C'''F',       
                          C' g',C' G',C'-g',C'-G',C'''g',C'''G',       
                          C' h',C' H',C'-h',C'-H',C'''h',C'''H',       
                          C' i',C' I',C'-i',C'-I',C'''i',C'''I',       
                          C' j',C' J',C'-j',C'-J',C'''j',C'''J',       
                          C' k',C' K',C'-k',C'-K',C'''k',C'''K',       
                          C' l',C' L',C'-l',C'-L',C'''l',C'''L',       
                          C' m',C' M',C'-m',C'-M',C'''m',C'''M',       
                          C' n',C' N',C'-n',C'-N',C'''n',C'''N',       
                          C' o',C' O',C'-o',C'-O',C'''o',C'''O',       
                          C' p',C' P',C'-p',C'-P',C'''p',C'''P',       
                          C' q',C' Q',C'-q',C'-Q',C'''q',C'''Q',       
                          C' r',C' R',C'-r',C'-R',C'''r',C'''R',       
                          C' s',C' S',C'-s',C'-S',C'''s',C'''S',       
                          C' t',C' T',C'-t',C'-T',C'''t',C'''T',       
                          C' u',C' U',C'-u',C'-U',C'''u',C'''U',       
                          C' v',C' V',C'-v',C'-V',C'''v',C'''V',       
                          C' w',C' W',C'-w',C'-W',C'''w',C'''W',       
                          C' x',C' X',C'-x',C'-X',C'''x',C'''X',       
                          C' y',C' Y',C'-y',C'-Y',C'''y',C'''Y',       
                          C' z',C' Z',C'-z',C'-Z',C'''z',C'''Z'))       


Output:
Code:
John Wesley Sam     
Del-Rafael         
O'Keefe             
Samson             
Suresh Menon       
Rupert O'Neill-Smith
Back to top
View user's profile Send private message
shajeeth

New User


Joined: 25 May 2005
Posts: 20

PostPosted: Fri Dec 12, 2014 4:28 pm
Reply with quote

Thanks for all your help, it has worked and the case has changed accordingly. Thanks!!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
No new posts Need help on formatting a report DFSORT/ICETOOL 14
No new posts Rexx formatting CLIST & REXX 2
No new posts Capturing COBOL job and program names... All Other Mainframe Topics 2
Search our Forums:

Back to Top