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

Internal table in ABAP memory

Former Member
0 Likes
3,313

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,596

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

20 REPLIES 20
Read only

Former Member
0 Likes
2,597

You can do that.

Use the EXPORT / IMPORT statements.

Regards,

Ravi

Read only

0 Likes
2,596

Yes, all you need to do is pass it thru memory.

data: itab type table of string.


export itab = itab to memory id 'ZTEST'.

import itab = itab from memory id 'ZTEST'.

Make sure that in both programs(exporting and importing) that you use the same internal table name and structure.

Regards

Rich Heilman

Read only

0 Likes
2,596

Hi Rich Heilman,

Am I getting a copy of the content of table?

or just a pointer to the table in memory.

Thanks.

Read only

0 Likes
2,596

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

Read only

0 Likes
2,596

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.

Read only

0 Likes
2,596

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

Read only

0 Likes
2,596

Hi Ravi,

So how can I refer to the table in memory without

getting a copy of it. Is it possible?

Thanks.

:-)Rose

Read only

0 Likes
2,596

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

Read only

0 Likes
2,596

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

Read only

0 Likes
2,596

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

Read only

0 Likes
2,596

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

Read only

0 Likes
2,596

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

Read only

0 Likes
2,596

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.

Read only

0 Likes
2,596

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.

Read only

0 Likes
2,596

I still think that you should create a structure in SE11 and pass the data back and forth between Function1 and Function2.

Regards,

Ravi

Read only

0 Likes
2,596

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

Read only

0 Likes
2,596

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

Read only

0 Likes
2,596

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.

Read only

0 Likes
2,596

Edit> Interface>Globalize Parameters. Not sure if this is enough to accomplish your requirement or not.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
2,596

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