04-28-2011 7:37 PM
Hello,
I need to obtain the size in bytes the a internal table before the send to server, I use the DESCRIBE sentence but is not allowed me to obtain this value, that sentence I need to use.
Thanks in advance,
DL
04-29-2011 10:02 AM
If you are on release 620, have a look at class CL_ABAP_MEMORY_UTILITES method GET_MEMORY_SIZE_OF_OBJECT. It will tell you how much memory is allocated and how much is actually used. Here is some sample code:
TABLES: sflight.
DATA: isflight TYPE TABLE OF sflight.
SELECT-OPTIONS: carrid FOR sflight-carrid.
SELECT * FROM sflight INTO TABLE isflight
WHERE carrid IN carrid.
DATA: size1 TYPE abap_msize,
size2 TYPE abap_msize,
size3 TYPE abap_msize,
size4 TYPE abap_msize,
flag1 TYPE char128,
size5 TYPE abap_msize,
size6 TYPE abap_msize,
flag2 TYPE char128,
flag3 TYPE char128.
TRY.
CALL METHOD cl_abap_memory_utilities=>get_memory_size_of_object
EXPORTING
object = isflight
IMPORTING
bound_size_alloc = size1
bound_size_used = size2
referenced_size_alloc = size3
referenced_size_used = size4
is_part_of_non_trivial_szk = flag1
szk_size_alloc = size5
szk_size_used = size6
low_mem = flag2
is_in_shared_memory = flag3.
ENDTRY.
WRITE: / 'Size of Bound and Allocated Memory:', size1.
WRITE: / 'Size of Bound and Used Memory:', size2.
WRITE: / 'Size of Referenced and Allocated Memory:', size3.
WRITE: / 'Size of Referenced and Used Memory:', size4.
WRITE: / 'Strongly Connected Component of Object:', flag1.
WRITE: / 'Size of Allocated Memory of SCC:', size5.
WRITE: / 'Size of Used Memory of SCC:', size6.
WRITE: / 'Flag, whether only bound_size_* are filled due to mem.short.:', flag2.
WRITE: / 'Flag, whether ONJECT is in the shared memory:', flag3.
If you aren't on 620 or don't need to be that precise, you might try the following:
DESCRIBE TABLE isflight LINES size1.
WRITE: / 'Number of Lines:', size1.
DATA: wa_sflight LIKE LINE OF isflight.
DESCRIBE FIELD wa_sflight LENGTH size2 IN BYTE MODE.
WRITE: / 'Size of one Line:', size2.
size3 = size1 * size2.
WRITE: / 'Total Size:', size3.
Please note that the addition IN BYTE MODE only works in 610 and higher. It isn't neccesary before that release. However it is important to get accurate resuls in an Unicode System.
04-29-2011 10:02 AM
If you are on release 620, have a look at class CL_ABAP_MEMORY_UTILITES method GET_MEMORY_SIZE_OF_OBJECT. It will tell you how much memory is allocated and how much is actually used. Here is some sample code:
TABLES: sflight.
DATA: isflight TYPE TABLE OF sflight.
SELECT-OPTIONS: carrid FOR sflight-carrid.
SELECT * FROM sflight INTO TABLE isflight
WHERE carrid IN carrid.
DATA: size1 TYPE abap_msize,
size2 TYPE abap_msize,
size3 TYPE abap_msize,
size4 TYPE abap_msize,
flag1 TYPE char128,
size5 TYPE abap_msize,
size6 TYPE abap_msize,
flag2 TYPE char128,
flag3 TYPE char128.
TRY.
CALL METHOD cl_abap_memory_utilities=>get_memory_size_of_object
EXPORTING
object = isflight
IMPORTING
bound_size_alloc = size1
bound_size_used = size2
referenced_size_alloc = size3
referenced_size_used = size4
is_part_of_non_trivial_szk = flag1
szk_size_alloc = size5
szk_size_used = size6
low_mem = flag2
is_in_shared_memory = flag3.
ENDTRY.
WRITE: / 'Size of Bound and Allocated Memory:', size1.
WRITE: / 'Size of Bound and Used Memory:', size2.
WRITE: / 'Size of Referenced and Allocated Memory:', size3.
WRITE: / 'Size of Referenced and Used Memory:', size4.
WRITE: / 'Strongly Connected Component of Object:', flag1.
WRITE: / 'Size of Allocated Memory of SCC:', size5.
WRITE: / 'Size of Used Memory of SCC:', size6.
WRITE: / 'Flag, whether only bound_size_* are filled due to mem.short.:', flag2.
WRITE: / 'Flag, whether ONJECT is in the shared memory:', flag3.
If you aren't on 620 or don't need to be that precise, you might try the following:
DESCRIBE TABLE isflight LINES size1.
WRITE: / 'Number of Lines:', size1.
DATA: wa_sflight LIKE LINE OF isflight.
DESCRIBE FIELD wa_sflight LENGTH size2 IN BYTE MODE.
WRITE: / 'Size of one Line:', size2.
size3 = size1 * size2.
WRITE: / 'Total Size:', size3.
Please note that the addition IN BYTE MODE only works in 610 and higher. It isn't neccesary before that release. However it is important to get accurate resuls in an Unicode System.