ITPub博客

首页 > Linux操作系统 > Linux操作系统 > SAP ABAP clear refresh free difference

SAP ABAP clear refresh free difference

原创 Linux操作系统 作者:hekexi316 时间:2010-07-26 22:53:59 0 删除 编辑

summary

1, when Internal Tables  with header line

CLEAR itab[]. = refresh itab -->only clear body of table

CLEAR itab(Notice:no bracket) --> clear body and header

2.when Internal Tables  without header line

CLEAR itab[]. = refresh itab = CLEAR itab

you can test by the following sample code
========================================

Initializing Internal Tables  

Like all data objects, you can initialize internal tables with the

CLEAR itab.

The memory space required for the table is released, except for the initial memory requirement.

If you are using internal tables with header lines, remember that the header line and the body of the table have the same name. If you want to address the body of the table itself, not the header line, during initialization using CLEAR, you must place two square brackets ([]) after the table name.

CLEAR itab[].

To ensure that the table itself has been initialized, you can use the statement

REFRESH itab.

This always applies to the body of the table. With REFRESH, too, the initial memory requirement fort he table remains reserved. To release this memory space, use the statement

FREE itab.

You can use FREE to directly initialize an internal table and to release its entire memory space, including the initial memory requirement, without first using the REFRESH or CLEAR statements. Like REFRESH, FREEaccesses the table body, not the table work area. After a FREEstatement, the internal table still exists. It still occupies the amount of memory required for its header (currently 256 bytes). When you refill the table, the system has to allocate new memory space to the lines.

Example

SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L1S31 { font-style. italic; color: #808080; } .L1S32 { color: #3399FF; } .L1S33 { color: #4DA619; } .L1S52 { color: #0000FF; } REPORT  ZHKXTESTCLEAR.
DATA: BEGIN OF line,
         col1(1) TYPE c,
         col2(1) TYPE c,
      END OF line.

DATA itab LIKE TABLE OF line.
DATA itab2 LIKE TABLE OF line WITH HEADER LINE.

line-col1 = 'A'. line-col2 = 'B'.

APPEND line TO itab.
APPEND line TO itab2.


REFRESH itab.

IF itab IS INITIAL.
  WRITE 'itab is empty'.
  FREE itab.
ENDIF.


*===============================
LOOP AT itab2.
  WRITE: / itab2-col1.
ENDLOOP.
APPEND line TO itab2.
REFRESH itab2.
*clear itab2."uncomment to test
*clear itab2[]."uncomment to test
IF itab2 IS INITIAL.
  WRITE / 'itab2 is empty'.
  FREE itab2.
ENDIF.

The list output is:

itab is empty.

A

An internal table itab is filled and then initialized with REFRESH. The IF statement uses the expression itab IS INITIAL to find out whether itab is empty. If so, the memory is released.


http://help.sap.com/saphelp_NW70EHP1core/helpdata/en/fc/eb384e358411d1829f0000e829fbfe/content.htm

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/13895577/viewspace-669551/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-05-02

  • 博文量
    38
  • 访问量
    57870