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

Access to local class, error in code check

Former Member
0 Likes
3,442

Hi experts,

I got a report with the following includes


INCLUDE ztest_top. "top include

INCLUDE ztest_c01. "local class

INCLUDE ztest_e01. "events

INCLUDE ztest_f01. "functions

In my top include, I define a reference variable of my local class lcl_test defined in the c01 include. Therefore I need the

CLASS lcl_test DEFINITION DEFERRED.

line in my top include.

So far so good.

In my f01 include I got a form (called from e01 include), where I create my object. If I check my code now, I get an error(!) message saying

components of classes declared using  "CLASS LCL_TEST DEFINITION DEFERRED" can only be accessed after you have defined the class (CLASS LCL_TEST DEFINITION)

Althought it's an error message, I can activate the program and run it without getting any errors. If I check it again afterwards, the errors show up again.

I don't really get this, the class definition and the implementation are in the c01 include, so the form in the f01 should know the class, shouldn't it?

Can anyone explain this to me?

Thanks in advance!

Regards,

Tobi

1 ACCEPTED SOLUTION
Read only

MarcinPciak
Active Contributor
0 Likes
2,329

Hi Tobias,

I cheked it in some quick example program. It seems that I received this message too, until I activated all the includes. This caused the error gone.

Regards

Marcin

7 REPLIES 7
Read only

MarcinPciak
Active Contributor
0 Likes
2,330

Hi Tobias,

I cheked it in some quick example program. It seems that I received this message too, until I activated all the includes. This caused the error gone.

Regards

Marcin

Read only

0 Likes
2,329

Hi Marcin,

thanks for your answer.

All my includes are activated as well, but when I code check again, the error reappears. This looks like a compiler error to me.

Regards,

Tobi

Read only

0 Likes
2,329

Hi Tobias,

Its not a compiler problem . Goto main program of the Function Group you created and check for syntax error .

You will not get the error message . If you check for syntax error anywhere outside, you will get error message .

Regards,

S.Sivakumar

Read only

0 Likes
2,329

Hello S.Sivakumar,

I don't really understand what you mean? Could you explain?

I only get the error when i code check the f01 include.`

Regards,

Tobi

Read only

0 Likes
2,329

Hi Tobias,

Just go to main program of the Function group and check code . No error occurs .

The fact is when you check the code inside an include , the declaration part of the class which u are accessing inside the include is not available . So because of that u r getting the error message .

Regards,

S.Sivakumar

Read only

0 Likes
2,329

Hi S.Sivakumar,

thanks for the reply.

Why should the declaration part not be available? All data defined in the top include is available as well.

If I replace my "definition deferred" command in the top include with "INCLUDE ztest_c01.", I get no error message when code checking the f01 as well? Where is the difference if I include the c01 in the main programm or in the top include? In both cases, the creation of the object happens after the declaration?!

Still don't get it...

Regards,

Tobi

Read only

former_member183804
Active Contributor
0 Likes
2,329

Hello Thomas,

as far as I know the ABAP editors do a kind of simulation when you perform a syntax-check within an include. The simulation works like this way the top include is combined with the current include into a temp. program which gets fed to the compiler. Cllass definition deferred in the top include does not work out in such a scenario. By moving the class definition statement into the TOP Include the true behavior should come closer to the expected one.

Best Regards

Klaus