View previous topic :: View next topic
|
Author |
Message |
bbharathiraj Warnings : 1 New User
Joined: 26 Oct 2006 Posts: 50 Location: Chennai
|
|
|
|
Hi,
Good day every one. I would appreciate if some one assist to do the below.
I have a input file with the below layout.
Comp-Num pic s9(3). Position 4,3
BEGINING PIC S9(13)V99 COMP-3. Position 47,8
EARNED PIC S9(13)V99 COMP-3. Position 55,8
ADJUSTED PIC S9(13)V99 COMP-3. Position 63,8
REDEEMED PIC S9(13)V99 COMP-3. Position 71,8
TRAN-OUT PIC S9(13)V99 COMP-3. Position 79,8
TRAN-IN PIC S9(13)V99 COMP-3. Position 87,8
FORFEITED PIC S9(13)V99 COMP-3. Position 95,8
LAPSED PIC S9(13)V99 COMP-3. Position 103,8
AVAILABLE PIC S9(13)V99 COMP-3. Position 111,8
I want to remove all the decimal part in all COMP-3 field for particular company 400 thru sort with out changing the field length.
For example, if the BEGINING having the value 100.50 and the AVAILABLE having the value of 13434.44 in input file
then the output should have BEGINING as 100 and AVAILABLE should have the value of 13434 in the output file.
Please note that the length should not be changed.
Output file should be matched with the input file layout. So after removing the decimal part we should be able to match all
the field with S9(13)V99 COMP-3.
Also this is the VSAM file |
|
Back to top |
|
|
technut
New User
Joined: 27 Dec 2007 Posts: 73 Location: India
|
|
|
|
You could convert the COMP-3 variable to alphanumeric variable and then use UNSTRING DELIMITED BY '.' |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
|
|
|
|
Quote: |
You could convert the COMP-3 variable to alphanumeric variable and then use UNSTRING DELIMITED BY '.' |
UNSTRING in DFSORT?
I assume you want to round all the amounts down, so 13434.44 becomes 13434.00, and not 134.34.
You might convert the field to ZD during INREC processing, appending to end of the record, and overlay the last two characters of that field with zeroes. Then in OUTREC processing, convert that work field to PD, overlaying the original field and remove the work field?
Garry. |
|
Back to top |
|
|
nelson.pandian
Active User
Joined: 09 Apr 2008 Posts: 133 Location: Phoenix, AZ
|
|
|
|
Quote: |
For example, if the BEGINING having the value 100.50 and the AVAILABLE having the value of 13434.44 in input file
then the output should have BEGINING as 100 and AVAILABLE should have the value of 13434 in the output file.
Please note that the length should not be changed.
Output file should be matched with the input file layout. So after removing the decimal part we should be able to match all
the field with S9(13)V99 COMP-3.
|
After removing the decimal if you match with the same file layout, it will again show the decimal part.
(i.e) After removing the decimal part 13434.44 to 13434, if match the resulted value with the same input structure it will look like 134.34 . Do you want this as the result. If not give your requirement more clear, with an example of INPUT and OUTPUT, and the rules clearly. |
|
Back to top |
|
|
technut
New User
Joined: 27 Dec 2007 Posts: 73 Location: India
|
|
|
|
I meant doing this through Cobol(UNSTRING in COBOL). Requestor did not say that he wants this to be done through DFSORT only. Did not notice that post was in DFSORT. |
|
Back to top |
|
|
bbharathiraj Warnings : 1 New User
Joined: 26 Oct 2006 Posts: 50 Location: Chennai
|
|
|
|
After removing the decimal if you match with the same file layout, it will again show the decimal part
Yes. You are right. Thanks to highlight this.
So I suppose to change to change decimal part to 00.
I have tried with outrec. But it didn't give expected result. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
100.50 as an 8-byte PD value looks like this in hex:
000000000010050C
13434.44 as an 8-byte PD values looks like this in hex:
000000001343444C
If you want the output values to look like this:
000000000010000C
000000001343400C
You can use DFSORT control statements like the following:
Code: |
OPTION COPY
INREC OVERLAY=(47:(47,8,PD,DIV,+100),MUL,+100,TO=PD,LENGTH=8,
55:(55,8,PD,DIV,+100),MUL,+100,TO=PD,LENGTH=8,
63:(63,8,PD,DIV,+100),MUL,+100,TO=PD,LENGTH=8,
...)
|
I assumed all of your values are positive. If they can be positive or negative, let me know and I'll show you how to handle that. |
|
Back to top |
|
|
bbharathiraj Warnings : 1 New User
Joined: 26 Oct 2006 Posts: 50 Location: Chennai
|
|
|
|
Hi Frank,
Yes. The value can be negative or positive.
Could you please provide me to handle this?
Thanks a lot |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
I take it back. It does work for both positive and negative values as coded. |
|
Back to top |
|
|
|