Application Development and Automation 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: 
Read only

Access a variable ?

Former Member
0 Likes
1,361

Hi,

My program is calling a function module.

Is there any way that i can access a variable of program

in function module without passing it in?

Regards,

Ankur

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,300

Hi Ankur,

you can use the export to memory and/or the set parameter statements to pass values to memory before calling the fm. In the fm you need to make sure the value will be read from memory using import from memory and/or get parameter statements.

regards

Siggi

10 REPLIES 10
Read only

Former Member
0 Likes
1,301

Hi Ankur,

you can use the export to memory and/or the set parameter statements to pass values to memory before calling the fm. In the fm you need to make sure the value will be read from memory using import from memory and/or get parameter statements.

regards

Siggi

Read only

0 Likes
1,300

Hi Siggi,

Actually its a standard program and it is regarding implementing a user exit.

Thanks & Regards,

Ankur

Read only

Former Member
0 Likes
1,300

Hi,

You can do a global assign if the variable is a global variable in your program i.e. declared in TOP include or at the top in a report program

For example,

FIELD-SYMBOLS: <fs_value> TYPE ANY.

ASSIGN ('(<your program name>)<your variable name>')

TO <fs_value>.

Hope this helps..

Sri

Message was edited by: Srikanth Pinnamaneni

Read only

Former Member
0 Likes
1,300

hi Ankur,

Try using memory id.

1. EXPORT obj1 ... objn TO MEMORY.

2. EXPORT obj1 ... objn TO DATABASE dbtab(ar) ID key.

3. EXPORT obj1 ... objn TO DATASET dsn(ar) ID key.

4. EXPORT obj1 ... objn TO SHARED BUFFER dbtab(ar) ID key.

EXPORT obj1 ... objn TO MEMORY.

Additions:

1. ... FROM g (for each field to be exported)

2. ... ID key

Exports the objects obj1 ... objn as a data cluster to ABAP/4

memory.

If you call a transaction, report or dialog module (with CALL

TRANSACTION, SUBMIT or CALL DIALOG), the contents of ABAP/4

memory are retained, even across several levels. The called

transaction can then retrieve the data from there using IMPORT

... FROM MEMORY. Each new EXPORT ... TO MEMORY statement

overwrites any old data in ABAP/4 memory - no data is appended.

If the processing leaves the deepest level of the call chain,

the ABAP/4 memory is released.

Regards,

Sailaja.

Dont forget to reward points, if answers helps you.

Read only

Former Member
0 Likes
1,300

Look at this weblog.

/people/brad.williams/blog/2005/04/25/userexits--how-do-i-access-inaccessible-data

Svetlin

Read only

0 Likes
1,300

Hi Svetlin,

That was a nice weblog.

Let me explain the issue in more detail.

The program actually is calling FM in a form and that it is the local variable of the form which i need in FM.

Thanks & Regards,

Ankur

Read only

0 Likes
1,300

Hi

I think you can't externally read it, because the system places the variable in memory only while it runs the routine.

So I believe you should modify the code of routine to export the data by IMPORT/EXPORT command.

Max

Read only

Former Member
0 Likes
1,300

Hi

Try to use this trick:

If the program of function group is SALPZ.... and field1 the field you want to read:

DATA: FIELD(30) VALUE '(SAPLZ....)FIELD1'.

FIELD-SYMBOLS: <FS_FIELD> TYPE ANY.

ASSING (FIELD) TO <FS_FIELD>.

max

Read only

Former Member
0 Likes
1,300

I think you can. Try the following piece of code :

data field_name(30) type c.

field_name = '(MP016800)EE_BENEFIT_DATA'.

<b><i>MP016800 is the source program which contains the declaration for the field you need. EE_BENEFIT_DATA is the structure defined in that program which contains the string of data I need. I know that the data resides in the first 8 characters of the structure</i></b>

assign (field_name) to <fs1>.

move <fs1> to l_ee.

l_pernr = l_ee(8).

You could do something similar.

Read only

Former Member
0 Likes
1,300

In the program where you are calling that function module export the data to a memory id by below command

Export variable to memory id 'MEMLOCATION'.

In the function module just import that data by below command

Import variable from memory id 'MEMLOCATION'.

Here variable should be of same type in both program and function module and also the memory id.

Cheers,

Satya