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 catch the Internal Table memory

Former Member
0 Kudos

hi all ,

How to know the internal table memory allocated during RUNTIME . Any system variable or any option is there?

Thanks

Jeeva

4 REPLIES 4

christian_wohlfahrt
Active Contributor
0 Kudos

Hi Jeeva,

in debugging, select in menu:

Goto - status display - memory use.

There you can see current memory consumption.

Regards,

Christian

Former Member
0 Kudos

Hi Jeeva,

To check up the memory consumption you can use while debugging mode GOTO -> Display consition -> Memory use

But i am not sure how to catch that in the program

Cheers ,

Raj

Former Member
0 Kudos

Hi,

Welcome to SDN. Seems like you have registered here just today. How do you find it ? Hope very good.

Now, coming to your requirement, if you are on 4.7, you can use the following code. Also refer to the class documentation.

data itab type spfli occurs 0.

data:
  BOUND_SIZE_ALLOC	       Type	ABAP_MSIZE,
  BOUND_SIZE_USED	       Type	ABAP_MSIZE,
  REFERENCED_SIZE_ALLOC	Type	ABAP_MSIZE,
  REFERENCED_SIZE_USED	Type	ABAP_MSIZE.

select * from spfli into table itab.

CALL METHOD cl_abap_memory_utilities=>get_memory_size_of_object
  EXPORTING
    object                     = itab
  IMPORTING
    BOUND_SIZE_ALLOC           = BOUND_SIZE_ALLOC
    BOUND_SIZE_USED            = BOUND_SIZE_USED
    REFERENCED_SIZE_ALLOC      = REFERENCED_SIZE_ALLOC
    REFERENCED_SIZE_USED       = REFERENCED_SIZE_USED.

write :
/ BOUND_SIZE_ALLOC,
/ BOUND_SIZE_USED,
/ REFERENCED_SIZE_ALLOC,
/ REFERENCED_SIZE_USED.

And reward the points if this is what youre looking for... Other wise get back, we'll see what can be done.

Regards,

Anand Mandalika.

Former Member
0 Kudos

Hi Jeeva,

If you are on older releases than 4.7 the following code will do the trick:

TYPES:
  BEGIN OF ty_struc,
    field1(20) TYPE c,
    field2     TYPE i,
    field3(8)  TYPE n,
  END   OF ty_struc.

DATA: it_struc  TYPE ty_struc OCCURS 0 WITH HEADER LINE,
      va_lines  TYPE i,
      va_length TYPE i,
      va_total  TYPE i.

it_struc-field1 = 'First field'.
it_struc-field2 = 1.
it_struc-field3 = '87654321'.
APPEND it_struc.

it_struc-field1 = 'Second field'.
it_struc-field2 = 2.
it_struc-field3 = '87654320'.
APPEND it_struc.

it_struc-field1 = 'Third field'.
it_struc-field2 = 3.
it_struc-field3 = '87654319'.
APPEND it_struc.

it_struc-field1 = 'Fourth field'.
it_struc-field2 = 4.
it_struc-field3 = '87654318'.
APPEND it_struc.

DESCRIBE TABLE it_struc[] LINES va_lines.
WRITE: /1  'Lines',
        12 va_lines.

DESCRIBE FIELD it_struc LENGTH va_length IN BYTE MODE.
WRITE: /1  'Length',
        12 va_length.

va_total = va_lines * va_length.
WRITE: /1  'Table size',
        12 va_total.

Regards,

Rob.