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: 

How to access global constants in User Exit?

Former Member
0 Kudos

Hi All,

I'm working on user exit ZXV50QU01 and I need to access some global constants defined in LV50QTOP.

I know that the function module who calls this user exit can access those global constants. But when I try to use them in ZXV50QU01, I got syntax error "Field ... is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement". If I use "INCLUDE LV50QTOP." in the user exit, I got another syntax error "REPORT or PROGRAM statement already exists".

Could any one tell me how to get access to those global constants in the user exit? (The constants I want to access are of type c.)

Thanks in advance!

S.L.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Sena,

Exits are function modules called form SAP code. When function modules are called they are called in seperate ABAP memory and the main program exists in different abap memory.

So we cannot directly access the variables/constants which exists in different memory area.

However, there is an indirect way to access those constants using Field symbols in ZXV50QU01.

The way to do it is, using debugger, identify the memory location (which means in which program the variable/constant is declared).

Once identified, you can access the variable/constant like this (program_name)variable.

I am using an example of  (SAPLCATS)CATSD-PERNR

where SAPLCATS is a main program and CATSD is a structure declared in main program.

What you need to do is,

Assign this to a temporary charecter variable let say

DATA: mem_char(40) value '(SAPLCATS)CATSD-PERNR'

Then declare a field symbols of the same type as the fild you need to access in my case in pernr

Field-Symbols: <FS> type pernr.

Then ASSIGN (mem_char) TO <FS>.

If subrc = 0. the <FS> will contain the value.

I hope this answers your question.

ZXV50QU01 is used in an exit EXIT_SAPLV50Q_001.

2 REPLIES 2

former_member184672
Participant
0 Kudos

Hi Sena,

          You can make use of field symbols to access the global data fields in your user exit include.

For instance, if you need to access the constant 'proctype_pick' in the program LV50QTOP you can use the following code:

DATA: fieldname(25) TYPE c VALUE '(LV50QTOP)proctype_pick'.

FIELD-SYMBOLS: <fs> TYPE ANY.

ASSIGN (fieldname) TO <fs>.

At this point you will have the field symbol <fs> pointing to the global constant in the master program. You may copy the value into a local variable inside your user exit and continue the processing.

Thanks & Regards,

Sarath.

Former Member
0 Kudos

Hi Sena,

Exits are function modules called form SAP code. When function modules are called they are called in seperate ABAP memory and the main program exists in different abap memory.

So we cannot directly access the variables/constants which exists in different memory area.

However, there is an indirect way to access those constants using Field symbols in ZXV50QU01.

The way to do it is, using debugger, identify the memory location (which means in which program the variable/constant is declared).

Once identified, you can access the variable/constant like this (program_name)variable.

I am using an example of  (SAPLCATS)CATSD-PERNR

where SAPLCATS is a main program and CATSD is a structure declared in main program.

What you need to do is,

Assign this to a temporary charecter variable let say

DATA: mem_char(40) value '(SAPLCATS)CATSD-PERNR'

Then declare a field symbols of the same type as the fild you need to access in my case in pernr

Field-Symbols: <FS> type pernr.

Then ASSIGN (mem_char) TO <FS>.

If subrc = 0. the <FS> will contain the value.

I hope this answers your question.

ZXV50QU01 is used in an exit EXIT_SAPLV50Q_001.