我有一个关于内部表的标题行问题。我给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.
首先,你不应该再使用带有header的内部表。
其次,如果你真的必须这样做,这里有一些解决方案。
标题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.