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: 

Access global data of report in global class methods?

arpita_churi3
Active Participant
0 Kudos


Hi all,

I have defined one global class in SE24 and i am using methods of this class in report program.

Can i access global data of my report program in class methods directly without declaring it as IMPORT

parameter?

Thanks,

Apita

8 REPLIES 8

arpita_churi3
Active Participant
0 Kudos

Hi Rajkumar,

Thanks for your reply.

But I am using ABAP OOPS to develop this report.

Or I have to declare it as IMPORT parameters in method?

Regards,

Arpita

Former Member
0 Kudos

Hi Arpita,

As per my understanding you can't use the global variables. But you can use the field symbol concept to get the program variables in your global class. But again you have to modify the method. you can use the syntax :

ASSIGN (PROGRAM(VARIABLE)) TO <FIeld symbol>.

Rather I would suggest you to create two Function Module - one is SET FM and another GET FM under same function group.

through the custom program you pass all the program variables to the global variables in the function group and you can call the GET FM in your class method to retrieve the same and use.

Whenever you want to pass the additional variable and just change in the respective FM calls. You no need to change the import / export parameters of the method, as your class is global.

Regards,

Abhi

0 Kudos

Hi Abhi,

   Thanks for your reply.

If I will call FM inside the method,

Do in need to pass IMPORT parameters to FM  as IMPORT parameters

to method also bcoz I am going to call FM inside method?

Regards,

Arpita

Private_Member_7726
Active Contributor
0 Kudos

Hi,

No, and you shouldn't even try Why, what's the difficulty in passing parameters?

cheers

Janis

0 Kudos

Hi Janis,

I have defined one global class in SE24 and i am using methods of this class in report program.

I have selection screen in report program containing Select-options and Parameters.

Can i  use this selection screen parameters and select-options of my report program in  method implementation in report program without declaring it as IMPORT parameters of method?

Hope u understand the scenario.

Regards,

Arpita

0 Kudos

Hi,

Well, now you did confuse me: first you asked about using global data of a report program in global class (created in SE24), and the answer is: no, you can't directly access the global data of another program in a method of global class (yes, you should pass them via importing parameters), and you shouldn't even consider using indirect means of doing so via special form of ASSIGN statement reserved for internal use by SAP. The ASSIGN will not work if someone reuses the global class elsewhere in the system without loading your report. Don't ever program such atrocious dependencies in global class...

And now you ask about the use "in method implementation in report program"..? Just to be sure - you can't program the implementation of a global class method in a report program.

You can program a local class inheriting from a global class and redefine/re-implement methods of such global super-class in a report program. Global data of report program, including the selection screen, would be directly accessible to such local class. It would still not be a good idea to use this access:


Conversely, within an encapsulated unit, that is, within a class, you should avoid accessing more global data directly. Within methods, you should generally modify attributes of the class only. Write access to global data outside the class is not recommended. Accessing data in this way should only be done using specially marked methods, if at all. The use of methods of a class should not evoke any side effects outside the class itself.

cheers

Jānis

Message was edited by: Jānis B

0 Kudos

Hi Arpita,

It wont be good design as class is global it should be independent.

Create local class and inherit the the global class and redefine it according to program as global variable available in local class

Thanks & Regards,

Arun

rosenberg_eitan
Active Contributor
0 Kudos

Hi.

Any attribute that have public visibility in your class is accessible from your program .

So you can use those as "parameters" .

Saying that it is exactly like using global variables which I hate .

So please use method call .

You can define the parameter types of your class in the class itself .

See Y_R_EITAN_TEST_31_02_CL in


http://scn.sap.com/community/abap/blog/2013/10/15/deeper-dive-into-deep-structure--part-2
http://scn.sap.com/community/abap/blog/2013/10/09/deeper-dive-into-deep-structure

Regards.