2007 May 12 6:04 AM
Hello everyone!
I am required to produced a CSV file and the last record should have a "hash total" which works like this:
For example, we have 3 records:
Record_1: 100.02
Record_2: 101.01
Record_3: 200.15
The hash total would be calculated like this:
10002 + 10101 + 20015 = 40118
The hash total is 40118 which should be outputted as: "000000000040118"
I already tried saving the numbers into a TYPE N variable but it rounds off the decimals.
Any help will be greatly appreciated! Thanks a lot!
2007 May 12 6:38 AM
Hi
decalare a varaible
data: v_num (10) type c.
first calculate the sum.
and move that sum to this field v_num.
and use the conversion fun modules
CONVERSION_EXIT_ALPHA_OUTPUT
CONVERSION_EXIT_ALPHA_INPUT
pass the same number as input and output you will get the output as '0000040118'.
Reward points if useful
Regards
Anji
Hello everyone!
I am required to produced a CSV file and the last record should have a "hash total" which works like this:
For example, we have 3 records:
Record_1: 100.02
Record_2: 101.01
Record_3: 200.15
The hash total would be calculated like this:
10002 + 10101 + 20015 = 40118
The hash total is 40118 which should be outputted as: "000000000040118"
I already tried saving the numbers into a TYPE N variable but it rounds off the decimals.
Any help will be greatly appreciated! Thanks a lot!
2007 May 12 6:29 AM
Hi,
Create a dataelement with type C, and domain with conversion exit(ALPHA) with required length.
Use this reference as calculated hash value.and passthis value to converion_exit_alpha_ input.you will get the leading zeros and value will not be rounded.
Hope this helps you
Regards,
2007 May 12 6:38 AM
Hi
decalare a varaible
data: v_num (10) type c.
first calculate the sum.
and move that sum to this field v_num.
and use the conversion fun modules
CONVERSION_EXIT_ALPHA_OUTPUT
CONVERSION_EXIT_ALPHA_INPUT
pass the same number as input and output you will get the output as '0000040118'.
Reward points if useful
Regards
Anji
2007 May 12 6:46 AM
Hi, Anji!
Thanks for the reply.
However, I am relatively new in ABAP so I do not know what do I need to include and how to include it to access CONVERSION_EXIT_ALPHA_OUTPUT and CONVERSION_EXIT_ALPHA_INPUT ...
Thanks for the help! _
2007 May 12 7:10 AM
data : begin of itab occurs 0,
val(10),
end of itab.
data : total(15).
itab-val = '100.02'.
append itab.
itab-val = '101.01'.
append itab.
itab-val = '200.15'.
append itab.
loop at itab.
replace all occurrences of '.' in itab-val with ''.
condense itab-val.
total = total + itab-val.
*modify itab.
endloop.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = total
IMPORTING
OUTPUT = total
.
write : / total.
regards
shiba dutta
2007 May 12 7:26 AM
Thanks a lot for your help!
I also tried another method:
hash_total = amt_total.
REPLACE '.' WITH '' INTO hash_total.
CONDENSE hash_total NO-GAPS.
Where has_total is type string.
It also produces the same output I need.
Which you think is better or more efficient? Thanks!
2007 May 12 9:02 AM
in my reply i used the addition between two characters field but if you can avoid it then it will be better .. i think you can use your method it will be good enough...
regards
shiba dutta
2007 May 15 10:20 AM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |