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
 

 

How to reformat a field in a delimited file with VB recs ?

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

New User


Joined: 01 Jul 2012
Posts: 1
Location: USA

PostPosted: Sat Jul 14, 2012 8:20 am    Post subject: How to reformat a field in a delimited file with VB recs ?
Reply with quote

There is a file where (see attachment) a field in all records needs to have leading zeros suppressed, for example:

004102109 needs to be 4102109. I am able to make this work as long as the fields are located in the same position. Unfortunately in my file the data is delimited and not always in the same location, although it is always right after the 6th delimiter (|~|). Do you know how to position the sort to the location based on the number of delimiters and then do the suppression?

Code below will work if the exact position is known for a particular record (see attachment for record details):

Code:
SORT FIELDS=COPY                                       
 SUM FIELDS=(64,09,ZD)                                 
 OUTFIL IFTHEN=(WHEN=(53,5,CH,EQ,C'CHBRX'),             
  OVERLAY=(64:64,9,ZD,M10,LENGTH=9,64:64,9,             
     SQZ=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"')),HIT=NEXT), 
       IFTHEN=(WHEN=(53,5,CH,EQ,C'CHBRX'),             
         OVERLAY=(64:64,9,                             
           SQZ=(SHIFT=LEFT,PAIR=QUOTE)),HIT=NEXT),     
         IFTHEN=(WHEN=(53,5,CH,EQ,C'CHBRX'),           
            FINDREP=(IN=C'"',OUT=C''))


Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8                                       1       2                 3                               
2930078510~00001|~|R|~|00001|~|20111127010101|~|CHBRX|~||~|3192431|~|CHBRX~02220 <<<<<<< I was able to suppress the zeros because I new the exact column for this record
2930078510~00001|~|R|~|00002|~|20111127010101|~|CHBRX|~||~|3192431|~|CHBRX~02220
2844321610~00001|~|P|~|00001|~|20111127010101|~|HANRX|~|66638|~|004158481|~|HANR <<<<<< this needs to be suppressed as well but it begins in another column
2844321610~00001|~|P|~|00002|~|20111127010101|~|HANRX|~|66638|~|004158481|~|HANR
2157690610~00001|~|R|~|00001|~|20111127010101|~|NALC|~|GROUP|~|000294922|~|NALC~
2157690610~00001|~|R|~|00002|~|20111127010101|~|NALC|~|GROUP|~|000294922|~|NALC~
2324411610~00001|~|R|~|00001|~|20111127010101|~|NALC|~|GROUP|~|000294922|~|NALC~


Code that works based on looking at a fixed column is below. Note that the variable length of the record was taken into account by adding 4 bytes to the position. 'CHBRX' starts in column 49 on the layout but 4 was addded to make the location 53 as used in the code:

Your post has been Code'd and the attachment inlined.

Please use the Code tags to preserve spacing where necessary and post file examples in the Code tags, not as attachments.
Back to top
View user's profile Send private message

Pandora-Box

Moderator


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

PostPosted: Sat Jul 14, 2012 11:20 am    Post subject:
Reply with quote

Hi,

I not able to view the attachment from mobile

But looking at your sort card I would suggest you to make use of PARSE

Read the manuals and search forum for samples on PARSE

After parsing you should be able to reformat

Also is that you wanted to remove leading Zeroes or first two bytes?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Sat Jul 14, 2012 2:07 pm    Post subject: Reply to: How to reformat a field in a delimited file with V
Reply with quote

Why do you have SUM with a COPY operation?

Presumably the extra four bytes are because you have a variable-length record?

There are many PARSE examples in the forum.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Sat Jul 14, 2012 2:39 pm    Post subject:
Reply with quote

in case you don't understand Bill's comment about SUM with a COPY operation,
you are invited to read the manual concerning the SUM Control Statement
which you have obviously overlooked.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Sun Jul 15, 2012 1:53 pm    Post subject: Reply to: How to reformat a field in a delimited file with V
Reply with quote

Just wondering now why you want to replace the leading zeros. Wherever the file is going they will still be treated as zero, therefore numerically equivalent to the zero-suppressed value...
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
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts How to generate a new unique Input fi... for1ranjith CLIST & REXX 11 Sat Jul 01, 2017 12:09 pm


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