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 variable declaraed in the separate program?

Former Member

I want to access a global variable declared within a different program from another function module. If the program containing the variable has a running instance, is it possible to get the value of the variable inside the function module?

4 REPLIES 4

Former Member
0 Kudos

Hi kaushik,

1. Yes we can get it.

2. (programname)varname

3. in debug type as it is

(with brackets)

program = your original progranmae

varname = variable name

regards,

amit m.

Former Member

hi,

do it like this,

check the where used list and find main program where variable is used and then access it like

field-symbol <fs> type any.

data myfield_name(40) type c value '(Program_name)variable_name'.

assign (myfield_name) to <fs>.

now <fs> has the desired value of the variable.

regards,

andreas_mann3
Active Contributor
0 Kudos

Hi,

and have a look at the

Andreas

former_member223537
Active Contributor
0 Kudos

Hi,

You can use the following logic :

In the Program where the global variable exist, once the global variable gets a value, export the value to a memory ID

EXPORT <field name > to memory id <id key>.

e.g.

data : l_total type i.

export l_total to memory id z_1011_234.

Now in the FM, import the variable :

data : l_total type i.

import l_total from memory id z_1011_234.

Best regards,

Prashant