|
View previous topic :: View next topic
|
| Author |
Message |
hailashwin
New User

Joined: 16 Oct 2008 Posts: 74 Location: Boston
|
|
|
|
Hi,
I have a requirement where I would have to consolidate(add) a particular field(position 334,7) for every account number(position 16,9). The field to be summed up has the picture clause defined as PIC S9(11)V9(2) COMP-3. But after I sum it up I have to put the value into PIC S9(14)V9(4) COMP-3. The challenge I am facing is in the location of the decimal point when I use the sort card below. The value which has to be 495688.89 after summing appears as 4956.8889. The Input file has a LRECL=550, RECFM=FB.
Please help me resolve this issue.
| Code: |
//SYSIN DD *
SORT FIELDS=(16,9,CH,A)
SUM FIELDS=(334,7,PD)
OUTFIL BUILD=(16,9,X,334,7,PD,TO=PD,LENGTH=10)
|
Thanks,
Ashwin. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
hailashwin,
You have increased your decimals from 2 to 4. What value would you like to store? ex : 495688.89 what do you expect in S9(14)V9(4) COMP-3? is it 495688.0089 or 495688.8900 |
|
| Back to top |
|
 |
hailashwin
New User

Joined: 16 Oct 2008 Posts: 74 Location: Boston
|
|
|
|
Hi Kolusu,
I want the summed up value to be stored in S9(14)V9(4) COMP-3.
I will give you an example for a better understanding of what I am expecting. Here in the input file, the value that is seen is of PIC S9(11)V9(2) COMP-3. But when I write to the output file, I want the field to be in a S9(14)V9(4) COMP-3 which carries the total for each occurance of the 9 byte value.
Input:
| Code: |
AAAAAAAAA....25.25
BBBBBBBBB....10.40
AAAAAAAAA....11.67
AAAAAAAAA....12.87
BBBBBBBBB....11.11
CCCCCCCCC....89.99
|
Expected Output:
| Code: |
AAAAAAAAA 49.7900
BBBBBBBBB 21.5100
CCCCCCCCC 89.9900
|
Thanks,
Ashwin. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
hailashwin,
Unless I am missing something, isn't it a simple like multiplying the 7 byte pd field with +100 and making it a 10 byte field? Use the following control cards.
| Code: |
//SYSIN DD *
INREC BUILD=(16,9,X,334,7,PD,MUL,+100,PD,LENGTH=10)
SORT FIELDS=(01,9,CH,A)
SUM FIELDS=(11,10,PD)
//* |
The output is 20 byte file. If you do want to verify the summed values then you can use an OUTREC statement to see the pd value in edit format {S9(14)V9(4)} as shown below
| Code: |
OUTREC OVERLAY=(22:11,10,PD,EDIT=(STTTTTTTTTTTTTT.TTTT),SIGNS=(+,-))
|
|
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|