Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
SORT to remove $ and decimal point and adjust the position.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: SORT to remove $ and decimal point and adjust the position.
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    Post subject:
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: 1703
Location: Australia

PostPosted: Sat Nov 03, 2012 2:23 pm    Post subject:
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    Post subject: Reply to: SORT to remove $ and decimal point and adjust the
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    Post subject: Reply to: SORT to remove $ and decimal point and adjust the
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10373
Location: italy

PostPosted: Sat Nov 03, 2012 4:43 pm    Post subject: Reply to: SORT to remove $ and decimal point and adjust the
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    Post subject: Reply to: SORT to remove $ and decimal point and adjust the
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10373
Location: italy

PostPosted: Sat Nov 03, 2012 5:35 pm    Post subject: Reply to: SORT to remove $ and decimal point and adjust the
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Sat Nov 03, 2012 6:18 pm    Post subject: Reply to: SORT to remove $ and decimal point and adjust the
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

Site Director


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

PostPosted: Sun Nov 04, 2012 6:14 am    Post subject:
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    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 Extract record for change in combinat... Trinadh DFSORT/ICETOOL 6 Thu Nov 23, 2017 3:32 pm
No new posts JOINKEYS Paired and Unpaired Sort on ... MFwhiz DFSORT/ICETOOL 7 Tue Nov 07, 2017 2:46 am
No new posts Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts How to insert a value on specific pos... Poha Eater DFSORT/ICETOOL 9 Sun Oct 01, 2017 3:04 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us