cancel
Showing results for 
Search instead for 
Did you mean: 

Reuse Global TYPES Declaration in Program

Former Member
0 Kudos

Hello,

Is there any way to access the global types inside our exit?.

Eg : In Program MV45AZZ, global types has been declared as GY_XXX.

I need to reuse this global types inside my exit.

data : lt_table type table of ( 'SAPMV45A'(gy_xxx) ).

is there any way to reuse the types from top include?

Regards,

Karthick

Accepted Solutions (0)

Answers (3)

Answers (3)

You are generally able to access things (like types or data declarations) within their scope. And "User-exit subroutines" like MV45AFZZ (if that is the one you mean) are in the scope of the main SAPMV45A. (In this case, you can use it just like you would expect: DATA: lt_table TYPE TABLE OF gy_xxx).

However if you leave the scope in your exit, like calling another program och a class where you implement the logic for your exit, then you can not.

Or if the data type you want is not on the main program level of SAPMV45A, you may not be in the scope of that data type.


Please tell us which type you want to use, where it is declared, and where you want to use it in your implementation.

iftah_peretz
Active Contributor

Hey,

I'm not sure I understand your problem. If you are writing code in a program that is aware of INCLUDE some_top_globals (let's assume it contains GY_XXX type) then you can use that GY_XXX type, if you are not in such program, then you can just write

INCLUDE some_top_globals.
"Your code from here onwards is aware of GY_XXX type

If I'm off point from what you meant please let me know and I'll try and adjust the answer.

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

"if you are not in such program, then you can just write"

No, you shouldn't reuse includes

https://help.sap.com/http.svc/rc/abapdocu_752_index_htm/7.52/en-US/index.htm?file=abenmultiple_use_i...

iftah_peretz
Active Contributor
0 Kudos

Hey Horst, the link you provided (https://help.sap.com/http.svc/rc/abapdocu_752_index_htm/7.52/en-US/index.htm?file=abenmultiple_use_i...) is broken.

To clarify -"if you are not in such program, then you can just write" - I meant that if you are in a program completely different and want to reuse some code from another program then you can use INCLUDE statement in such a way where you do not use include programs more than once.

0 Kudos

Hi! Horst must have gotten an internal URL. This should be a working one:

https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abenmultiple_use_include_guidl.htm

iftah_peretz
Active Contributor
0 Kudos

Thanks!

And as I said (better written and coherent):

"Do not use include programs more than once

Use an include program for the modularization of exactly one master program. It must not be integrated into multiple different master programs. Also, an include program should only be integrated once within a master program"

Sandra_Rossi
Active Contributor
0 Kudos

You may declare the type in a new interface pool ZIF_name, and rename GY_XXX to ZIF_name=>GY_XXX everywhere it's used in SAPMV45A.