I have a question about internal tables' header line.
I assigned some values into in_table1
and then try to add a record with APPEND
command into in_table2
in the following block of code.
But I cannot see the record that I have appended into in_table2
.
Is this because of the header line of in_table2
?
If yes, how can I see the records anyway?
*&---------------------------------------------------------------------*
*& 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.
First of all, you should not use internal tables with header anymore.
Second of all, if you really have to do it, here is some solution.
The header in_table2
is of course empty in your case. You have to loop through the table to print it out. For example like this.
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.
Internal tables with headers should not be used exactly because of this confusion. Looks like you got confused exactly in such way. The meaning of in_table2
is ambiguous and depends on the context.
Better use field symbols for looping and appending.
FIELD-SYMBOLS: <fs_for_loop> LIKE LINE OF in_table2[].
LOOP AT in_table2[] ASSIGNING <fs_for_loop>.
WRITE / <fs_for_loop>.
ENDLOOP.