05-19-2008 10:41 PM
Hi all,
I'm getting this requirement, not sure if it makes any sense or not, but I really appreciate if you can give me an idea about this.
For example I read the cluster and get this amount $99999.99
They want me to show it in the output file under this format
000009999999000 (15 bytes in length)
So my question is is there any function module to do this? or any suggestion? Thanks and points will be surely rewarded!
05-20-2008 4:27 AM
Check if below example satisfies original requirement:
DATA: p_dec(8) TYPE p DECIMALS 5 VALUE '99999.99',
p_text(15) TYPE c,
p_num(15) TYPE n.
p_text = p_dec.
p_num = p_text.
WRITE:/ p_dec,
/ p_num.
05-19-2008 10:44 PM
Hi Ben
Use the function module CONVERSION_EXIT_ALPHA_INPUT to convert 256 to 0000000256. You can put this FM in a subroutine
05-20-2008 12:06 AM
Hi Jack, I tried the module function named 'conversion_exit_alpha_input'
But it turned out 0000000000000009 instead of 0000000000009999 as I thought
Here's my test code on that FM, if there's something wrong please let me know, thanks!
REPORT Ztest.
data: numtest type n.
data: test(15) TYPE n.
numtest = 9999.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = numtest
IMPORTING
OUTPUT = test.
write test.
05-20-2008 12:17 AM
Hi Ben,
The code should be in the following way
data: numtest(15) type n.
data: test(15) TYPE n.
numtest = 9999.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = numtest
IMPORTING
OUTPUT = test.
write test.
The output is coming perfectly as 000000000009999.
Regards
Abhishek
05-20-2008 12:30 AM
Great! thanks Abhishek, I will confirm with them if they want this format, in the mean time still looking for a solution for this format. Thanks again!
05-19-2008 10:48 PM
Hello Ben Boman,
No FM's available. You need to do make use of string manupulation functions.
Do the following logic :
1) seperate the value into two field value ( one before decimal poing and another after decimal value).
2) then count the string value and add zeros according to your requirement and concatenate both values.
Hope this helps.
Thanks,
Greetson
05-19-2008 11:12 PM
Thanks for your prompt responses,
@jack, It's very useful, I will check with my client if they want that instead of the original requirement.
@greetson, thanks for your solution, I'm thinking about this case your solution may not work, if I have an amount of $500, so, if I put it in the variable that's 15 byte long, something like this 000000000500000 how do I (or they) know that it's 500 or 50000 dollars.
And by the way, it really depends on the amount so the numbers of begin and ending zero are not fix.
05-20-2008 4:27 AM
Check if below example satisfies original requirement:
DATA: p_dec(8) TYPE p DECIMALS 5 VALUE '99999.99',
p_text(15) TYPE c,
p_num(15) TYPE n.
p_text = p_dec.
p_num = p_text.
WRITE:/ p_dec,
/ p_num.
05-20-2008 11:20 PM
Dear Eswar, It works, I marked this as right answer You're amazing, thanks!
Edited by: Ben Boman on May 21, 2008 12:33 AM