Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Parse only a part of the record using dfsort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Giri Bangalore

New User


Joined: 09 Mar 2014
Posts: 2
Location: India

PostPosted: Mon Mar 10, 2014 11:53 pm    Post subject: Parse only a part of the record using dfsort
Reply with quote

Hi,

I have a requirement to add a new field at the end of each record. The requirement is as follows



input file
empid |name |city |dob |firstname
00001 |mark.tracey |New York |01-01-2001 |
00002 |carm.shaw.vander |Boston |07-03-2000 |
00003 |rebekah |Boston |06-01-2000 |
00004 |debby |st.lucas |05-08-1999 |
00005 |.tim.moody |stamford |06-06-2002 |

Output file
empid |name |city |dob |firstname
00001 |mark.tracey |New York |01-01-2001 |tracey
00002 |carm.shaw.vander |Boston |07-03-2000 |shaw
00003 |rebekah varsell |Boston |06-01-2000 |rebeka
00004 |debby |st.lucas |05-08-1999 |debby
00005 |.tim.moody |stamford |06-06-2002 |tim

Please note that the first name can be a max of 20 characters but only the first 6 characters should be part of the new field. The criteria is to get the string after the first dot if present, the full name should be considered if there are no dots at all in the name field.

I tried it with a simple inrec parse with the dot '.' as the delimiter, but am getting the city name when there is no "." in the name field. Is it possible to have it done in dfsort.

Thanks in advance,
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Tue Mar 11, 2014 12:44 am    Post subject: Reply to: Parse only a part of the record using dfsort
Reply with quote

most probably a double parse might do it ...

parse all the | separated fields
and parse again the first one
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Tue Mar 11, 2014 12:54 am    Post subject:
Reply with quote

Untested

Try SQZ=(SHIFT=LEFT)
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Mar 11, 2014 2:27 am    Post subject:
Reply with quote

Giri Bangalore,

Your input does NOT match the output shown. for ex:

Input :

Code:

00003 |rebekah |Boston |06-01-2000 |


Output :

Code:

00003 |rebekah varsell |Boston |06-01-2000 |rebeka


1. How did you end up with extra name? Is that a typo?

2.Do you really have the header ? or did you include it to just show us the contents? Do you need it in the output?

Code:

empid |name |city |dob |


3. What is the LRECL and RECFM of the input file?

4. Does all the records have a delimiter "|" at the end ? or do we need to populate it along with the extracted first name?

Enrico was on the right track that you need to parse the name field twice as you have mixed bag of strings.

Pandora , You need PARSE to extract the first name and then use SQZ , but you also need to remember that it will eliminate the embedded blanks in between too. so you need to use MID and FINDREP to variably attach the first name at the end of each record.
Back to top
View user's profile Send private message
Giri Bangalore

New User


Joined: 09 Mar 2014
Posts: 2
Location: India

PostPosted: Tue Mar 11, 2014 9:41 am    Post subject: Reply to: Parse only a part of the record using dfsort
Reply with quote

Thanks everybody for all the suggestions.

Hi Skolusu, here are my responses

1. Yes, it was a typo. The record in the input file also should have the name rebekah varsell.

2. The headers are actually present in the input file. It is an existing report that we send to business.

3. The LRECL is 100 and the Record format is FB.

4. Yes, all the records have the delimiter | at the end.

I will try Enrico's suggestion today and let you know if I am successfull.

Regards,
Giri Bangalore
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Mar 11, 2014 9:56 pm    Post subject:
Reply with quote

Hello and welcome to the forum,

Though this is does not answer your question, why pass the entire file creating another when the needed output might be created as the "input" file is created?
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Tue Mar 11, 2014 10:03 pm    Post subject:
Reply with quote

Quote:
Pandora , You need PARSE to extract the first name and then use SQZ , but you also need to remember that it will eliminate the embedded blanks in between too. so you need to use MID and FINDREP to variably attach the first name at the end of each record.


Yes Kolusu I was aware SQZ will eliminate the space inbetween but he could try if he won't have space looking at coded data looks he wont need the SQZ.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Mar 12, 2014 12:17 am    Post subject:
Reply with quote

Giri Bangalore,

Code:

//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD *                                                 
EMPID |NAME |CITY |DOB |                                         
00001 |MARK.TRACEY |NEW YORK |01-01-2001 |                       
00002 |CARM.SHAW.VANDER |BOSTON |07-03-2000 |                   
00003 |REBEKAH VARSELL |BOSTON |06-01-2000 |                     
00004 |DEBBY |ST.LUCAS |05-08-1999 |                             
00005 |.TIM.MOODY |STAMFORD |06-06-2002 |                       
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                 
  OPTION COPY                                                   
  INREC IFTHEN=(WHEN=INIT,                                       
  PARSE=(%01=(ABSPOS=8,FIXLEN=20,ENDBEFR=C'|',ENDBEFR=C' ')),   
  OVERLAY=(101:C'@',%01)),                                       
  IFTHEN=(WHEN=(102,20,SS,EQ,C'.'),                             
  PARSE=(%02=(ABSPOS=102,FIXLEN=20,STARTAFT=C'.',ENDBEFR=C'.')),
  OVERLAY=(101:C'@',%02))                                       
                                                                 
  OUTREC IFTHEN=(WHEN=INIT,                                     
  BUILD=(1,121,SQZ=(SHIFT=LEFT,MID=C' ',LENGTH=120))),           
  IFTHEN=(WHEN=INIT,                                             
  FINDREP=(INOUT=(C'| @NAME',C'|FIRSTNAME',C'| @',C'|')))       
                                                                 
//*


Output from the above
Code:

EMPID |NAME |CITY |DOB |FIRSTNAME                     
00001 |MARK.TRACEY |NEW YORK |01-01-2001 |TRACEY       
00002 |CARM.SHAW.VANDER |BOSTON |07-03-2000 |SHAW     
00003 |REBEKAH VARSELL |BOSTON |06-01-2000 |REBEKAH   
00004 |DEBBY |ST.LUCAS |05-08-1999 |DEBBY             
00005 |.TIM.MOODY |STAMFORD |06-06-2002 |TIM           
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts How to get the remainder and quotient... vnktrrd DFSORT/ICETOOL 2 Mon Oct 31, 2016 10:59 am
No new posts sort with previous record anatol DFSORT/ICETOOL 9 Thu Oct 06, 2016 2:36 am
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm
No new posts Change date (DD/MM/YY) in 2nd record ... uday kiran DFSORT/ICETOOL 12 Wed Sep 07, 2016 10:57 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us