1

我对内部表的标题行有疑问。我分配了一些值in_table1,然后尝试在下面的代码块中添加一条带有APPEND命令的记录。in_table2但我看不到我附加到的记录in_table2。这是因为标题行in_table2吗?如果是,我怎样才能看到记录?

*&---------------------------------------------------------------------*
*& Report  ZTEST_LOOP
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZTEST_STRUCT_DATA_TYPE.

***** define structure data types

TYPES: BEGIN OF adres_bilgileri, " this is a struct with a set of types
  sokak type c length 30,
  cadde type c length 30,
  sehir type c length 15,
  ev_no type n length 4,
  end of adres_bilgileri.

  types: BEGIN OF personel_bilgileri,
    ad type c LENGTH 20,
    soyad type c LENGTH 20,
    tel_no type n LENGTH 12,
    adres TYPE adres_bilgileri," ********************!!!!!!!!!!!!!!!!!!!!!!
    END OF personel_bilgileri.

TYPES personel_bilgi_tablosu TYPE STANDARD TABLE OF personel_bilgileri WITH key TABLE_LINE.
  data: in_table1 type personel_bilgileri,
        in_table2 type personel_bilgi_tablosu WITH HEADER LINE.
        "adres1 type adres_bilgileri.


 in_table1-ad = 'Latife'.
 in_table1-soyad = 'A'.
 in_table1-adres-sokak = 'Hasanpaşa'. """"""""""""adresten sokak bilgisine geçiş
 in_table1-adres-ev_no = 10.

 append in_table1 to in_table2.

  WRITE / :  'Records in in_table2:', in_table2. 
4

1 回答 1

2

首先,您不应该再使用带有标题的内部表。

其次,如果你真的必须这样做,这里有一些解决方案。

在您的情况下,标题in_table2当然是空的。您必须遍历表格才能将其打印出来。比如像这样。

LOOP AT in_table2.   "here in_table2 means table (an internal table)
  WRITE / in_table2. "here in_table2 means the header of the table (a structure)
ENDLOOP.

由于这种混淆,不应完全使用带有标题的内部表。看起来你完全被这种方式弄糊涂了。的含义in_table2是模棱两可的,取决于上下文。

更好地使用字段符号进行循环和追加。

FIELD-SYMBOLS: <fs_for_loop> LIKE LINE OF in_table2[].
LOOP AT in_table2[] ASSIGNING <fs_for_loop>.
  WRITE / <fs_for_loop>.
ENDLOOP.
于 2014-07-17T08:19:16.607 回答