|
View previous topic :: View next topic
|
| Author |
Message |
santhoshm
New User
Joined: 13 Jun 2007 Posts: 32 Location: chennai
|
|
|
|
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 |
|
 |
knickraj Warnings : 1 New User

Joined: 11 Jun 2007 Posts: 50 Location: Euro
|
|
|
|
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 |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
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 |
|
 |
santhoshm
New User
Joined: 13 Jun 2007 Posts: 32 Location: chennai
|
|
|
|
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 |
|
 |
santhoshm
New User
Joined: 13 Jun 2007 Posts: 32 Location: chennai
|
|
|
|
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 |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
| Quote: |
| In the above example '002760' should changed to '00000002760' |
and it was too hard to say so from the beginning  |
|
| Back to top |
|
 |
santhoshm
New User
Joined: 13 Jun 2007 Posts: 32 Location: chennai
|
|
|
|
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 |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
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..
>> <<
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|