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

can TYPE be used dynamically?

Former Member
0 Likes
536

for example:

paramters: p_type_name type c default 'C'.

data: char1 type 'p_type_name'.

can i do something like above?

thx

5 REPLIES 5
Read only

Former Member
0 Likes
515

Hello,

You may use like the following:

PARAMETERS: p_name type c default 'C'.

data: char1 like p_name.

Thanks,

Venu

Read only

Former Member
0 Likes
515

Hi Chao Liu,

u can not do it in that way...

but u can do below things...


types : p_type_name type c.

paramters: p_type_name1 type p_type_name default 'C'.

data: char1 type p_type_name.

Also use Tcode ABAPHELP and enter TYPE in the popup window and see the documentation for it...

Hope it will solve ur doubt

Reward points if useful...

Thanks & Regards

ilesh 24x7

Read only

Former Member
0 Likes
515

Hi,

You can do like this also.

DATA:t_name TYPE c.

PARAMETERS: p_type LIKE t_name DEFAULT 'C'.

DATA: char1 LIKE p_type.

Reward points if helpful.

Read only

former_member784222
Active Participant
0 Likes
515

Hi,

You can do this using CREATE DATA syntax.

Example:

data: p_type type c value 'C'.

data: obj type ref to data.

field-symbols: <fs> type any.

create data obj type (p_type). "defining type dynamically

assign obj->* to <Fs>.

<fs> = 'Z'.

write: <fs>.

Thanks and regards,

S. Chandra Mouli.

Read only

prasanth_kasturi
Active Contributor
0 Likes
515

hi,

use the following way

parameters: p_type_n type c default 'C'.

data: char1 like p_type_n value 'A'.

write char1.

o/p A

regards

prasanth