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 

Parsing the delimter file

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


Joined: 12 Apr 2007
Posts: 76
Topics: 41

PostPosted: Thu Mar 19, 2015 6:51 am    Post subject: Parsing the delimter file Reply with quote

Hi All,

Input file is pipe delimited VB file.
and output should contain '99999' after the 9th delimiter. Please suggest how to achieve through SORT/ICETOOL utility


Input file:

Code:
TPS1|GEDMUI|244709112|ERS-37164-2177914 |Y|2011-06-02| 24.310|657|632.690|N|TS1|A|
TPS1|GEDMUI|244709122|ERS-1177914 |Y|2011-04-02|24.310| 657.200|632.690|N|TS1|A|
TPS1|GE|244709132|ERS-164-317914 |Y|2011-06-22|24.310|657.10| 632.60|N|TS1|A|


Output file:
Code:
TPS1|GEDMUI|244709112|ERS-37164-2177914 |Y|2011-06-02| 24.310|657|632.690|99999|
TPS1|GEDMUI|244709122|ERS-1177914 |Y|2011-04-02|24.310|657.200| 632.690|99999|
TPS1|GE|244709132|ERS-164-317914 |Y|2011-06-22|24.310|657.10| 632.60|99999|
[/code]

Thanks
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12368
Topics: 75
Location: San Jose

PostPosted: Thu Mar 19, 2015 12:56 pm    Post subject: Reply with quote

nbdtrjk1,

Convert the delimiter '|' to a different delimiter using FINDREP 1 at a time. And then parse for the 8th delimiter and then build the desired record and use another FINDREP to replace changed delimiters back to the original delimiter.

I assumed that your first 8 fields have a length of 100 bytes. If it is greater then change the length in FIXLEN value. Also remember to add the 6 bytes to JFY length.

Code:

//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD DISP=SHR,DSN=Your Input file                 
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                 
  OPTION COPY                                                   
  INREC IFTHEN=(WHEN=INIT,FINDREP=(DO=1,INOUT=(C'|',C'~'))),     
        IFTHEN=(WHEN=INIT,FINDREP=(DO=1,INOUT=(C'|',C'!'))),     
        IFTHEN=(WHEN=INIT,FINDREP=(DO=1,INOUT=(C'|',C'@'))),     
        IFTHEN=(WHEN=INIT,FINDREP=(DO=1,INOUT=(C'|',C'#'))),     
        IFTHEN=(WHEN=INIT,FINDREP=(DO=1,INOUT=(C'|',C'$'))),     
        IFTHEN=(WHEN=INIT,FINDREP=(DO=1,INOUT=(C'|',C'%'))),     
        IFTHEN=(WHEN=INIT,FINDREP=(DO=1,INOUT=(C'|',C'¢'))),     
        IFTHEN=(WHEN=INIT,FINDREP=(DO=1,INOUT=(C'|',C'&'))),     
        IFTHEN=(WHEN=INIT,PARSE=(%01=(ENDAT=C'&',FIXLEN=100)),   
        BUILD=(%01,JFY=(SHIFT=LEFT,TRAIL=C'99999|',LENGTH=106))),
        IFTHEN=(WHEN=INIT,FINDREP=(OUT=C'|',                     
         IN=(C'~',C'!',C'@',C'#',C'$',C'%',C'%',C'¢',C'&')))     
                                                                 
                                                                 
//*

_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
William Collins
Supermod


Joined: 03 Jun 2012
Posts: 437
Topics: 0

PostPosted: Thu Mar 19, 2015 4:46 pm    Post subject: Reply with quote

A variation, with only one FINDREP to change from, and one to change back:

Code:
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,
                 FINDREP=(DO=8,
                          INOUT=(C'|',X'FF'))),
        IFTHEN=(WHEN=INIT,
                 PARSE=(%01=(ENDAT=C'|',FIXLEN=100)),
                 BUILD=(%01,
                        JFY=(SHIFT=LEFT,
                             TRAIL=C'99999|',
                             LENGTH=106))),
        IFTHEN=(WHEN=INIT,
                 FINDREP=(DO=8,
                          INOUT=(X'FF',C'|')))


Change eight pipes to X'FF' (delimited data, text only, so X'FF' won't appear as real data). PARSE a field finishing at what is now the first pipe, left-justify and follow with the closing value+pipe. Change the eight high-value delimiters back to pipes.
Back to top
View user's profile Send private message
nbdtrjk1
Beginner


Joined: 12 Apr 2007
Posts: 76
Topics: 41

PostPosted: Fri Mar 20, 2015 3:42 am    Post subject: Reply with quote

Given solutions are working fine. Thanks for your help !!
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