Skip to Content
author's profile photo Former Member
Former Member

New field format

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!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 20, 2008 at 03: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.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 19, 2008 at 09: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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 19, 2008 at 09: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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.