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: 

Memory Import/Export VS Function Group's Tops.

Former Member
0 Kudos

I have a customized FM (Main FM) that will triggered by standard process. Inside this Main FM will call 8 others child FM with condition. There are 8 customized tables involved, the current design was select * for all 8 tables (less than 100 records for every tables) in the main FM and then export to memory, in child FM then will import the table back from memory. A selected 'X' field is export to the memory at the same time, every time when the main FM get triggered, it will check on this field, if = 'X' then will skip the whole selections again. I am thinking to declare the internal tables in TOPS (since they are belongs to the same function group) rather than using memory export and Import. Any suggestion?

Edited by: eugenecctan on Mar 22, 2011 3:03 PM

Edited by: eugenecctan on Mar 22, 2011 3:06 PM

10 REPLIES 10

Former Member
0 Kudos

Using the TOP include to share data via global variable would be a preferable option (my view) as against using EXPORT/ IMPORT because mainly you can trace/ track the use of the global variable as against EXPORT/ IMPORT. Also, EXPORT/ IMPORT would be ideally used when you cannot transfer data by any other means - last resort.

Just be careful to clear the global variables at the appropriate point the code to ensure no inconsistency.

0 Kudos

that was my initial thought, but then if i were declare in tops, I will be using only internal session memory rather than Abap memory using Export/Import. I had created a test program to call the main FM by looping the FM with Internal for 5 times, either by declaring internal tables using tops/ passing using export/import, all the 8 tables will be selected once only. But if i press F3 then rerun the program, the memory that hold the internal tables will still be available, but for TOPS, then i will have to reselect all the tables.

0 Kudos

To be honest - what you have mentioned seems like an advantage for using TOP than IMPORT/ EXPORT. If you press F3 and run the function module for a second time - containing any remnant data from a previous run would actually spoil your data/ control integrity - wouldn't it?

Now this holds true considering you want to share data between calls to various FMs within the same wrapper (parent) FM - i.e. single call of the FM right?

0 Kudos

>

> that was my initial thought, but then if i were declare in tops, I will be using only internal session memory rather than Abap memory using Export/Import. I had created a test program to call the main FM by looping the FM with Internal for 5 times, either by declaring internal tables using tops/ passing using export/import, all the 8 tables will be selected once only. But if i press F3 then rerun the program, the memory that hold the internal tables will still be available, but for TOPS, then i will have to reselect all the tables.

The reason behind this is the memory design. Whenever you call FM from some program, whole FG is placed in the same internal session and more specifically in so-called additional program group (for the sake of clarity calling program reside in so-called main program group ). This causes that all data from TOP FG are available as long as this internal session hasn't terminated (as long as main program group stays available in the memory). So whenever you call FM for the subsequent time, it will just pick data from its already loaded FG. When you terminate it (by leaving main program) the system terminates addit. program group too, flushing all data which it occupied. For more information refer [this|http://help.sap.com/abapdocu_70/en/] -> ABAP - memory organization -> Program groups in the internal session .

So, the solution you should go for really depends on the case you have. If you call FM accross several reports (in different internal sessions) you will need ABAP Memory, otherwise (if called from within one internal session) it is sufficient to use FG TOP data.

Regards

Marcin

Former Member
0 Kudos

A mugs game - 800 records. You could select them anew each time and it wouldn't make much difference.

Rob

0 Kudos

Yes, you are right, but why select so many times if we are able to select for once, and the main FM will be triggered very frequently. Or it will be better if I buffer all tables and select individually in the child FM. Just want to know the which is the best solution for my case.

Edited by: eugenecctan on Mar 23, 2011 4:31 AM

0 Kudos

As I told you, FG has its own roll area, so each FM shares the same. As long as main FM is called several times but from one internal session (from one program) you can use TOP FG are to buffer the tables the in main FM simply check


if tab1[] is initial.
  select * ...
endif.

if tab2[] is initial.
  select * ...
endif.

This way you avoid selecting data anew every time FM gets triggered.

Regards

Marcin

0 Kudos

I wasn't suggesting that you do the select multiple times; only that it won't make much difference. Some sort of buffering is better, but unless the FM is executed really frequently, more time will be spend programming this than will ever be saved during it's execution.

Programmers are generally paid more than the people who use the programs.

Rob

0 Kudos

I were using the same design. , but I don't see any difference in performance. So i decided to stop changing it since many testing and FM will get involved. Thanks for all the suggestion.

Former Member
0 Kudos

Please design/plan your code nicely, it will avoid unnecessary performance tuning in future.