12345678901234567890
TOM + 30 IBM
SREE + 40 CTS
TOM - 10 IBM
And the output should be like
Code:
12345678901234567890
TOM + 20 IBM
SREE + 40 CTS
It shouldn't be +20. spaces should be there b/w sign and number
Now i am using one code which will suppress Zeros with blank not with spaces.... See the code below... Is there any way to suppress Zero with spaces???
Please find the code which i am using
Code:
INREC OVERLAY=(9:9,4,SFF,TO=ZD,LENGTH=4)
SORT FIELDS=(1,6,CH,A,15,3,CH,A)
SUM FIELDS=(9,4,ZD)
OUTREC OVERLAY=(9:9,4,ZD,EDIT=(SIIT),SIGNS=(+,-))
swathykrishnan,
Can you have signs at different positions for the same person? For example from your sample input, Tom record in input has a sign at 9th position but the last Tom record has sign at 11th position. Is it possible? If yes where do you want sign in your expected output?
What is the LRECL/RECFM of the input file?
Also please use code tags when providing sample data to keep formatting as is.
quick and dirty just reproduced the record layout , no provision for greater that 3 digits numbers
modify accordingly, tested for an 80 byte record
I reformatted things using the code tags according to the sort statements
You must have been looking at the topic before
( yes the formatting was very poor also with a fixed font )
First of thanks a lot for your quick response Enrico and sqlcode...
@Enrico: thanks man.. your logic is superb...... that will do whatever i want....
@sqlcode: The position of the sign will be always fixed in Input file and RECFM=FB....
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
skrockzz,
Well, I'm not really sure what you want the output to look like for various cases, such as with three non-zero digits or one non-zero digit, but be aware that you can include embedded blanks in the EDIT mask by enclosing the pattern in apostrophes. For example:
Code:
EDIT=('S IIT')
If you used that in the code in your first post, SORTOUT would have:
Hi Frank...Thanks for your valuable input...
Let me explain my requirement....
i have to find sum of one field which have a fixed length including sign, say 5. Here the sign will be always in 1st column. and the numbers will be right aligned. When i add these numbers using the code posted by me its will keep sign just to the left of number.... but i have to keep sign in exact position as its in the input file... see the example below..
INput
Code:
MEERA + 2 IBM
MANJU + 24 CGI
MEERA + 98 IBM
MANJU - 22 CGI
SWATH + 23 IBM
Output should be
Code:
MEERA +100 IBM
MANJU + 2 CGI
SWATH + 23 IBM
I think your code will always embed one space in the output
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
have to find sum of one field which have a fixed length including sign, say 5.
Your input example actually has a fixed length of 4 for the sum field. Assuming that you really do have a fixed length of 5, you can use a DFSORT job like the following to do what you asked for:
Code:
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
MEERA + 2 IBM
MANJU + 24 CGI
MEERA + 98 IBM
MANJU - 22 CGI
SWATH + 23 IBM
AAAAA - 25 IBM
AAAAA - 125 IBM
BBBBB -1002 IBM
CCCCC +1002 IBM
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC OVERLAY=(81:7,5,SFF,TO=ZD,LENGTH=4)
SORT FIELDS=(1,5,CH,A,13,3,CH,A)
SUM FIELDS=(81,4,ZD)
OUTREC IFOUTLEN=80,
IFTHEN=(WHEN=(81,4,ZD,LT,0),
OVERLAY=(7:C'-',81,4,ZD,EDIT=(IIIT))),
IFTHEN=(WHEN=NONE,
OVERLAY=(7:C'+',81,4,ZD,EDIT=(IIIT)))
/*
SORTOUT would have:
Code:
AAAAA - 150 IBM
BBBBB -1002 IBM
CCCCC +1002 IBM
MANJU + 2 CGI
MEERA + 100 IBM
SWATH + 23 IBM
I wonder why it is so difficult to extract from people such simple info ...
position/column where to stick the sign
position/column and length of the edited numeric thing
my attempt was simply decoding the initial info
column 9 for the sign 3 positions for the numeric thing
thank you Frank.... that logic is good one.....
@Kolusu.. your code(Section,Trailer) is completely new to me... anyway i will try that also and will let you know....
@Enrico: your understanding was also correct... that code also will work
This is my first post in this forum.... thanks for your overwhelming support..... i didn't expect such talented quick responses from a public forum.... but this one is really superb..... thanks a lot..... is this owned by IBM?
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
This Help Board is NOT owned or endorsed by IBM. But Kolusu and I are IBM DFSORT developers who participate in it.
BTW, Kolusu's solution is a clever one. Note that the separate SIGNS trick could be used with the SUM solution as well eliminating the need for the IFTHENs.
DFSORT has so many ways to do things that it's difficult to always think of the easiest one, even for me and I invented a lot of the functions.