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

SORT to remove $ and decimal point and adjust the position.


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

New User


Joined: 13 Jun 2007
Posts: 32
Location: chennai

PostPosted: Sat Nov 03, 2012 12:32 pm
Reply with quote

Hi,

I have an input file with the follwoing data
Code:
idno|firstname|lastname|amount1|amount2|amount3|...
0001|sarath|kumar|     $27.60|     $322.60|      $21111.32|...
0002|vinay  |kumar|     $28.32|     $211.31|   $2123212.31|..


Each amount field in above input file is of 11 bytes.
I will need output as below one..
Code:
0001|sarath|kumar|       2760|        32260|         2111132|...
0002|vinay  |kumar|       2832|        21131|      212321231|..


i.e. I wil not require $ and . in the output file and the amount fields should of length 11 bytes.

I have used below sort card
Code:
SORT FIELDS=COPY
 INREC IFTHEN=(WHEN=INIT,FINDREP=(IN=C'$',OUT=C'0')),
 IFTHEN=(WHEN=INIT,FINDREP=(IN=C'.0',OUT=C'0')),
 IFTHEN=(WHEN=INIT,FINDREP=(IN=C'.1',OUT=C'1')),
 IFTHEN=(WHEN=INIT,FINDREP=(IN=C'.2',OUT=C'2')),
 IFTHEN=(WHEN=INIT,FINDREP=(IN=C'.3',OUT=C'3')),
 IFTHEN=(WHEN=INIT,FINDREP=(IN=C'.4',OUT=C'4')),
 IFTHEN=(WHEN=INIT,FINDREP=(IN=C'.5',OUT=C'5')),
 IFTHEN=(WHEN=INIT,FINDREP=(IN=C'.6',OUT=C'6')),
 IFTHEN=(WHEN=INIT,FINDREP=(IN=C'.7',OUT=C'7')),
 IFTHEN=(WHEN=INIT,FINDREP=(IN=C'.8',OUT=C'8')),
 IFTHEN=(WHEN=INIT,FINDREP=(IN=C'.9',OUT=C'9'))


I am getting the amount fields but one poistion less. i.e. INput file has amount field of 11 bytes including '&' and '.'. I must have the same bytes of 11 after removing the above characters using SORT. Can someone help?

thanks

Code'd
Back to top
View user's profile Send private message
knickraj
Warnings : 1

New User


Joined: 11 Jun 2007
Posts: 50
Location: Euro

PostPosted: Sat Nov 03, 2012 1:30 pm
Reply with quote

try this, not tested

Code:
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,FINDREP=(IN=C'$',OUT=C'00')),
IFTHEN=(WHEN=INIT,FINDREP=(IN=C'.',OUT=C''))


this would make
$27.60 to 002760
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Sat Nov 03, 2012 2:23 pm
Reply with quote

Hi,

are the amounts in a fixed position ? if so, you can use this
Code:
//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTOUT  DD SYSOUT=*                                           
//SORTIN   DD *                                                 
0001|SARATH|KUMAR|     $27.60|    $322.60|  $21111.32|...       
0002|VINAY |KUMAR|     $28.32|    $211.31|$2123212.31|..         
/*                                                             
//SYSIN    DD *                                                 
 SORT FIELDS=COPY                                               
 OUTREC OVERLAY=(19:19,11,UFF,                                   
              EDIT=(IIIIIIIIIIT),                               
                 31:31,11,UFF,                                   
              EDIT=(IIIIIIIIIIT),                               
                 43:43,11,UFF,                                   
              EDIT=(IIIIIIIIIIT))                               
/*



Gerry
Back to top
View user's profile Send private message
santhoshm

New User


Joined: 13 Jun 2007
Posts: 32
Location: chennai

PostPosted: Sat Nov 03, 2012 4:35 pm
Reply with quote

Thanks all,
The below code worked..

Code:
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,FINDREP=(IN=C'.',OUT=C'')),
IFTHEN=(WHEN=INIT,FINDREP=(IN=C'$',OUT=C'00')


Code'd for what it was worth
Back to top
View user's profile Send private message
santhoshm

New User


Joined: 13 Jun 2007
Posts: 32
Location: chennai

PostPosted: Sat Nov 03, 2012 4:39 pm
Reply with quote

Can we add zeroes to the field '002760'
i.e. I will need to have 11 bytes.

In the above example '002760' should changed to '00000002760'
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sat Nov 03, 2012 4:43 pm
Reply with quote

Quote:
In the above example '002760' should changed to '00000002760'


and it was too hard to say so from the beginning icon_evil.gif
Back to top
View user's profile Send private message
santhoshm

New User


Joined: 13 Jun 2007
Posts: 32
Location: chennai

PostPosted: Sat Nov 03, 2012 5:24 pm
Reply with quote

This has worked for adding zeroes..
Code:
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,FINDREP=(IN=C'.',OUT=C'')),
IFTHEN=(WHEN=INIT,FINDREP=(IN=C'|$',OUT=C'|00'),
IFTHEN=(WHEN=INIT,FINDREP=(IN=C'| $',OUT=C'|000'),
IFTHEN=(WHEN=INIT,FINDREP=(IN=C'|  $',OUT=C'|0000'),
IFTHEN=(WHEN=INIT,FINDREP=(IN=C'|   $',OUT=C'|00000'),
IFTHEN=(WHEN=INIT,FINDREP=(IN=C'|    $',OUT=C'|000000'),
IFTHEN=(WHEN=INIT,FINDREP=(IN=C'|     $',OUT=C'|0000000'),
IFTHEN=(WHEN=INIT,FINDREP=(IN=C'|      $',OUT=C'|00000000'),
IFTHEN=(WHEN=INIT,FINDREP=(IN=C'|       $',OUT=C'|000000000'),


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: Sat Nov 03, 2012 5:35 pm
Reply with quote

if You had used the code tags, the sort control cards would have been more readable

- the code tags preserve multiple blanks

without ( five spaces between >> and <<

..12345..
>> <<

Code:
..12345..
>>     <<
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 Nov 03, 2012 6:18 pm
Reply with quote

santhoshm,

If your data is known to be "good" you are going about this in a very long way. Look at Gerry's solution, and change the mask to include leading zeros.

To continue with the FINDREP, you should limit it to operating on your fields, and to only do one change. It is searching your entire record, and possibly having undesired effects elsewhere. Even if you know it can't trash anything, you'll forget that by the time you copy it to do something else. Both the initial FINDREPs could be done as one statement.

Since the positions are fixed, you'd expend less resources with a simple IFTHEN=(WHEN=(logexp to do the leading zeros "by hand".
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sun Nov 04, 2012 6:14 am
Reply with quote

Hello,

Suggest you run your "solution" and the one provided by Gerry (But only for 1 field) for comparison.

I predict that Gerry's solution will use far less cpu time then the FINDREP solution.

The larger the input file, the more cpu saved.
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 Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
Search our Forums:

Back to Top