Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

New field format

Former Member
0 Kudos

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!

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

8 REPLIES 8

former_member156446
Active Contributor
0 Kudos

Hi Ben

Use the function module CONVERSION_EXIT_ALPHA_INPUT to convert 256 to 0000000256. You can put this FM in a subroutine

0 Kudos

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.

0 Kudos

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

0 Kudos

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!

Former Member
0 Kudos

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

0 Kudos

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.

Former Member
0 Kudos

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.

0 Kudos

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