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 variables from memory?

Former Member
0 Kudos

Hi Experts,

I am stuck in a point where I need your help.               

There is one FM 'ALE_INTERNALORDER_SAVEREPLICA'. If you look into FM, the message type and idoc type are both hardcoded inside it. The values are not passed globally, but declared locally.

Inside the FM, the code looks like this:

Message Type = 'INTERNAL_ORDER'.

Idoc Type = 'INTERNAL_ORDER01'.

Now, when I call a subroutine from the FM,  and suppose this values are not passed in the subroutine, we wont be able to change the hard coded values, since they are not accessible inside the subroutine.

But when I come out of the subroutine to the main FM body, the values are activated again. So this means they are stored somewhere in the memory. How can we access that memory?

I know we can access the global memory with the help of field symbols... but I am not quite sure of above...

Thanks,

Ajay

4 REPLIES 4

Former Member
0 Kudos

Hi Ajay,

You can use GET / SET parameters to access global SAP memory.

Eg

data: w_var(10).

var = 'test1'

set parameter id 'ABC' value w_var.

you set the parameter ABC to the value test1 in the global memory.

You can then access this value in any program by getting it out of the memory :

Eg

data: w_var(10).

get parameter id 'ABC' value w_var.

Likewise,  you can pass parameters from program to program. Also the F1 help for the set/get parameter statement should help.

Thanks

Vivek

0 Kudos

Hi Vivek,

A standard program is in question here. Moreover, its not the global memory I need access to...

As i explained earlier... some variables are hard-coded locally in a FM 'ALE_INTERNALORDER_SAVEREPLICA'.

Now after this hard-coding, a subroutine is called. These values are NOT passed to the subroutine. So obviously, this is inaccessible to that subroutine. I want access to those variables inside the subroutine...

As we all know, when I come out of the subroutine to the FM souce code body in debugging, the values are activated again... which obviously means they are be stored in some memory location.

How can we access that memory? Hope I am clear this time...

Thanks,

Ajay

0 Kudos

Hi,

Below is a piece of sample code for reaching up into the callstack.

This is the general way of doing it, but it may not work in your particular case. I believe the variables need to be defined as globals in the main (function group) program.

types: ty_fkkop_tab type standard table of fkkop.
field-symbols: <FS_FKKOP> type ty_fkkop_tab.

assign ('(SAPLFKB0)I_FKKOP[]') to <FS_FKKOP>.
if sy-subrc = 0.
...
endif.

cheers

Paul Bakker

0 Kudos

I confirm as "idoc_control" is local to the FM, you should not be able to assign a FS on it. (Scope of variables)

from ASSIGN - dynamic_dobj

For internal use only, the name in name can also have the form "(PROG)DOBJ", where "PROG" is the name of an ABAP program and "DOBJ" the name of a global data object of this program. If the program "PROG" is loaded into the same internal session as the current program when the ASSIGN statement is executed, then the data object "DOBJ" is searched for in this program and the field symbol points to this data object if the assignment was successful.

Regards,

Raymond