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

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


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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

Global Moderator


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

PostPosted: Sat Jul 14, 2012 11:20 am
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

Moderator Emeritus


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

PostPosted: Sat Jul 14, 2012 2:07 pm
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: 6966
Location: porcelain throne

PostPosted: Sat Jul 14, 2012 2:39 pm
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

Moderator Emeritus


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

PostPosted: Sun Jul 15, 2012 1:53 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top