Skip to Content

Restraining decimal points for selective values of a single field?

Hello everyone,

here is my sample code ...

" types: begin of ty_x,

(some fields)

.

.

.

.

menge type P decimals 3,

currkey type waers,

end of ty_x. (let us say this is my final output structure )

data: i_x type table of ty_x,

w_x type ty_x.

loop at it into wa.

.

.

.

if currkey is not maintained in TCURX table

then menge should be diaplayed with 3 decimal values

else.

menge should be diaplayed without decimal values

endif.

append w_x to i_x.

endloop.

reuse alv grid ( to display the output).

"

here what should be the type of menge so that i can get the output as i have mentioned in the if clause?

output example:

field1 field2 field3 field4 QUANTITY(MENGE) CURRENCYKEY

A A A A 123.456 USD

B B B B 11100.253 USD

C C C C 11100 KRW

D D D D 1255 JPY

i have tried to restrict the type to p with decimals 0. but that would reflect to all the values in the field quantity.
kindly help me with this..

Thanks in advance,

jyothi reddy.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Posted on Sep 10, 2013 at 11:25 AM

    Hi,

    instead of doing a MOVE ... TO i_x-menge, try to do a WRITE ... TO i_x-menge CURRENCY i_x-waers.

    regards

    Fred

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 10, 2013 at 11:35 AM

    Hi,

    • Declare one more field in the final output structure like MENGE1 TYPE p DECIMALS 2.
    • Move the values accordingly based on the condition and display the output.

    Thanks

    Gangadhar

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 10, 2013 at 12:40 PM

    This message was moderated.


    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 10, 2013 at 12:49 PM

    HI,

    If you displaying your output in ALV for these ideally you must pass the currency field parameter in the fieldcatalog.

    For your currency field use cfieldname in the fiedcatalog if you want to display for quantity fields pass

    qfieldname. The ALV by default takes care of the decimals to be displayed.

    You can find lots of example for this in BC ALV.

    If your requirement is different kindly ignore.

    Regards,

    Vasanth

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 10, 2013 at 01:02 PM

    Hi,

    Use a string in ALV field catalog to display menge. Based on your currency key condition, assign the value with decimals / without decimals to this field in ALV.

    -Ashwin

    Add a comment
    10|10000 characters needed characters exceeded

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.