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

Declaring variable dynamic of decimal format

Hi SDN Community,

Can you possibly provide a sample of how to declare a variable to be dynamic.

the situation is that using the TABLE CLASS INTERFACE,

the numbers from I_VALUE come in as long decimal places. eg. 20.58498497

i wish to have a declaration to then use this further in the code.

for example

DATA: ROUNDEDNUMBER type i DECIMALS 2.

but i want instead of 2, to have this dynamic,

the dynamic value is populated by I_NUMERIC_PRECISION which is derived from the settings of the Bex query.

hence my anticipated result is 20.6 (which has been rounded as well)

I have seen Field symbols achieve this?

Thank you.

Simon

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Aug 14, 2009 at 07:32 AM

    TRY THIS :

    DEC_NO IS THE VARIABLE WITH THE MAX 14 DECIMALS.

    GET YOUR NUMBER IN DEC_NO AND THEN ASSIGN IT TO THE FIELD SYMBOL.

    DATA: DEC_NO TYPE P DECIMALS 14.

    ASSIGN DEC_NO TO <FS_DEC>.

    USE <FS_DEC> IN YOUR FURTHER CODE.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Naresh

      Thank you for your reply.

      Can you possibly put the full snippet of ABAP code that will achieve this.

      I only am an amateur ABAP'er, and work on your expertise syntax.

      Thank you.

      Simon

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2009 at 12:19 AM

    Answer:

    write i_display_value to lv_replace_value

    no-sign decimals i_numerical_precision.

    condense lv_replace_value no-gaps.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 25, 2014 at 11:39 AM

    Hi all,

    I had the same issue und solved it in this way:

    DATA: lv_decim TYPE numc1 VALUE 0.

    DATA: lr_packed TYPE REF TO data.

    FIELD-SYMBOLS: <fs_packed> TYPE ANY.

    CREATE DATA lr_packed TYPE p DECIMALS lv_decim.
    ASSIGN lr_packed->* TO <fs_packed>.

    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.