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

ABAP Object Oriented issue

Former Member
0 Likes
593

Hello,

The codes below works fine from a stand alone ABAP program.

TYPES: BEGIN OF v_level_text,

level type /BI0/HPROD_HIER-tlevel,

text type /BI0/TPROD_HIER-txtlg,

END OF v_level_text.

DATA: i_level_text type table of v_level_text.

DATA: wa_level_text like line of i_level_text. ***** error is from this line *******

However, when put in a method, I get the error

E:Within classes and interfaces, you can only use "TYPE" to refer to ABAP Dictionary types, not "LIKE" or "STRUCTURE'.

When I changed 'LIKE' to 'TYPE', I get the error as below:

E:The type "I_LEVEL_TEXT" is unknown, but there is a type with the similar name "V_LEVEL_TEXT". "V_LEVEL_TEXT.

Please advise the correct way to rewrite this code so can work in OO.

Thanks,

Ravi

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
555

There is stricter typing check in ABAP OO programming... the following should not give syntax error,

DATA: wa_level_text TYPE V_level_text.

3 REPLIES 3
Read only

Former Member
0 Likes
556

There is stricter typing check in ABAP OO programming... the following should not give syntax error,

DATA: wa_level_text TYPE V_level_text.

Read only

Former Member
0 Likes
555

Hello,

Why don't you declare it as DATA: wa_level_text type v_level_text?

Thanks.

Ramya.

Read only

0 Likes
555

>

> Hello,

>

> Why don't you declare it as DATA: wa_level_text type v_level_text?

>

> Thanks.

> Ramya.

Quote!

Types: begin of lvt_testvariable,

......,

end of lv_testvariable.

DATA: lv_testvariable type lvt_testvariable.