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: 

Declaring variable dynamic of decimal format

Former Member
0 Kudos

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

4 REPLIES 4

Former Member
0 Kudos

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.

0 Kudos

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

Former Member
0 Kudos

Answer:

write i_display_value to lv_replace_value

no-sign decimals i_numerical_precision.

condense lv_replace_value no-gaps.

martin_boerger
Newcomer
0 Kudos

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>.