2006 Jul 10 1:41 PM
HI experts,
Is it possible to put the internal
table in the memory in such a way that
that I can access the content
of it in my function calls?
Thanks for your reply.
best regards,
rose
2006 Jul 10 1:43 PM
You can do that.
Use the EXPORT / IMPORT statements.
Regards,
Ravi
HI experts,
Is it possible to put the internal
table in the memory in such a way that
that I can access the content
of it in my function calls?
Thanks for your reply.
best regards,
rose
2006 Jul 10 1:43 PM
You can do that.
Use the EXPORT / IMPORT statements.
Regards,
Ravi
2006 Jul 10 1:45 PM
2006 Jul 10 1:53 PM
Hi Rich Heilman,
Am I getting a copy of the content of table?
or just a pointer to the table in memory.
Thanks.
2006 Jul 10 1:55 PM
You will be getting a COPY of the internal table.
You need to keep in mind that the function module will have to be called from the first program, else it will not be accessible.
Regards,
Ravi
Message was edited by: Ravikumar Allampallam
2006 Jul 10 2:00 PM
thanks Ravi, I think Sreeni's example is helpful.
I don't want to have a copy. I only want to have
a pointer.
Thanks Sreeni, I will try your sample code.
2006 Jul 10 2:11 PM
Even in Srini's example you are getting only a copy, its just he is assigning to a field symbols it might feel like you are getting a pointer.
Regards,
Ravi
2006 Jul 10 2:17 PM
Hi Ravi,
So how can I refer to the table in memory without
getting a copy of it. Is it possible?
Thanks.
:-)Rose
2006 Jul 10 2:24 PM
If you are calling a function module from a report / wherever, why can't you pass these values as CHANGING parameters, so that you get the reference of these tables.
As such if you are going to call this function in a different session you will not get the values, anyway, right?
So, In my view, just pass these tableas as paramters.
Regards,
Ravi
2006 Jul 10 2:25 PM
Ravi is right. You are still only getting a copy. In order to point directly, you handle it a little differently.
You won't need to export in the first program and in the second, you can access the table directly like this. Here we are simulating a function call with a PERFORM. So in your function module, you can use the code in program 2 to retreive the table from the calling program.
Program 1
report zrich_0001.
data: itab type table of string with header line.
field-symbols: <fs> type table.
itab = 'This is the line 1'. append itab.
itab = 'This is the line 2'. append itab.
perform simulate_function_call in program zrich_0002.
Program 2
report zrich_0002 .
*---------------------------------------------------------------------*
* FORM simulate_function_call *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form simulate_function_call.
field-symbols: <fs> type table.
data: wa type string.
data: pointer_tab(20) type c.
<b> pointer_tab = '(ZRICH_0001)ITAB[]'.
assign (pointer_tab) to <fs>.</b>
loop at <fs> into wa.
write:/ wa.
endloop.
endform.
Now you have a pointer to the original table, and not a copy.
Regards,
Rich Heilman
2006 Jul 10 2:30 PM
So if we substite a simple function module, it would look like this.
program 1.
report zrich_0001.
data: itab type table of string with header line.
field-symbols: <fs> type table.
itab = 'This is the line 1'. append itab.
itab = 'This is the line 2'. append itab.
<b>call function 'ZTEST'.</b>
The FM
function ztest.
*"----------------------------------------------------------------------
*"*"Local interface:
*"----------------------------------------------------------------------
field-symbols: <fs> type table.
data: wa type string.
data: pointer_tab(20) type c.
<b> pointer_tab = '(ZRICH_0001)ITAB[]'.
assign (pointer_tab) to <fs>.</b>
loop at <fs> into wa.
write:/ wa.
endloop.
endfunction.
Regards,
Rich Heilman
2006 Jul 10 2:33 PM
Rich,
While we are calling a function, isn't that simple to send the tables via the TABLES / CHANGING parameters rather than complicating it using the field symbols.
We are using a function module anyways.
What do you think?
Regards,
Ravi
2006 Jul 10 2:36 PM
Yes, absolutly Ravi, if it was me, I would just pass it thru the interface and be done with it. But he seems to want direct access to the original internal table for some reason. Not sure why, maybe there is a good reason for it. If not, then I would definitly agree that passing thru the interface would be a lot better.
Regards,
Rich Heilman
2006 Jul 10 2:42 PM
Hi Ravi and Rich, I did think about it before
posting this question. It's just that I am calling a function A which calls a function B and function B calling A again. More like of a "recursive"??.
And I thought that maybe it will be less confusing if
I will just access the table directly from memory to
get away from passing from one function to another,
the same table, which really is just reference table
for both functions. Am I confusing myself more or what.. :-).
But thank you very very much guys for your inputs.
2006 Jul 10 2:50 PM
and one more thing that i forgot to mention,
the structure of my table is defined in my program,
it does not exist in ABAP dictionary.
2006 Jul 10 2:52 PM
I still think that you should create a structure in SE11 and pass the data back and forth between Function1 and Function2.
Regards,
Ravi
2006 Jul 10 2:59 PM
Ravi, if these function modules were part of the same function group, could they not share the internal table? Meaning when the first is called, you have to pass the internal table, then in the same session, the second FM could act on the internal table which has been passed to some global part of the function group. This will take away all of the passing from Fm1 to Fm2 and Fm2 to Fm1.
Regards
Rich Heilman
2006 Jul 10 3:01 PM
Rich,
As long as all the calls are in the same session that will work. For whatever reasons if one of the calls in a different session, we will not able to predict the results.
So, to be on the safer side, my vote would for the parameters. However, if we are sure that we are going to use it in the same session, then I guess we can use it that way.
Regards,
Ravi
2006 Jul 10 3:16 PM
Hi Ravi and Rich, I actually have the same thought
as Rich, but I do not know how to make the passing
of table global in Function Group? How do I do it.
2006 Jul 10 3:23 PM
2006 Jul 10 1:54 PM
Hai
Program 1
report zImport_0001.
data: itab type table of string with header line.
field-symbols: <fs> type table.
itab = 'This is the line 1'. append itab.
itab = 'This is the line 2'. append itab.
assign itab[] to <fs>.
export <fs> to memory id 'ZSRITEST'.
submit zsri_0002 and return.
Program 2
REPORT zImport_0002 .
data: itab type table of string with header line.
field-symbols: <fs> type table.
data: wa type string.
assign itab[] to <fs>.
import <fs> from memory id 'ZSRITEST'.
loop at <fs> into wa.
write:/ wa.
endloop.
Thanks & regards
Sreeni
Message was edited by: Sreenivasulu Ponnadi
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |