Application Development and Automation 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: 
Read only

How to dynamic for declaration variable?

Former Member
0 Likes
377

This is my problems

I will by PLMK-STELLEN data to determine decimals

Example:

IF PLMK-STELLEN = 3

then data: l_amt1 type p decimals 3.

IF PLMK-STELLEN = 2

then data: l_amt1 type p decimals 2.

For this case, how can i do, please help.

Thanks a lot!!

2 REPLIES 2
Read only

Former Member
0 Likes
350

You should use dynamic declaration.

TYPES:

p3 TYPE p DECIMALS 3,

p2 TYPE p DECIMALS 2.

DATA dref TYPE REF TO data.

FIELD-SYMBOLS <l_amt1> TYPE ANY.

IF PLMK-STELLEN = 3

CREATE DATA dref TYPE p3.

ELSEif IF PLMK-STELLEN = 2.

CREATE DATA dref TYPE p2.

ENDIF.

ASSIGN dref TO <l_amt1>.

Hope it helps.

Read only

Former Member
0 Likes
350

Hi,

See the following code.

DATA: FLD(8) TYPE P DECIMALS 2,

DEC TYPE I.

DESCRIBE FIELD FLD DECIMALS DEC.

Here DEC will have the value 2.

Hope this will Help,

Cheers,

Ram