I am trying to add a new record to my internal table and this code is giving me an error, but I am doing exactly the same thing as in my SAP book. What am I doing wrong?
TYPES : BEGIN OF personel_bilgileri,
Ad TYPE c LENGTH 20,
Soyad TYPE c LENGTH 20,
Telefon_no Type n LENGTH 12,
END OF personel_bilgileri.
TYPES personel_bilgi_tablo_tipi TYPE STANDARD TABLE OF
personel_bilgileri WITH NON-UNIQUE KEY ad soyad.
DATA : personel_bilgi_kaydi TYPE personel_bilgileri,
personel_bilgi_tablosu TYPE personel_bilgi_tablo_tipi.
personel_bilgi_kaydi-ad = 'Murat'.
personel_bilgi_kaydi-soyad = 'Sahin'.
personel_bilgi_kaydi-telefon_no = '5556677'.
APPEND personel_bilgi_kaydi TO personel_bilgileri.
personel_bilgi_kaydi-ad = 'Ayse'.
personel_bilgi_kaydi-soyad = 'Bil'.
personel_bilgi_kaydi-telefon_no = '5556611'.
APPEND personel_bilgi_kaydi TO personel_bilgileri.
personel_bilgi_kaydi-ad = 'Mehmet'.
personel_bilgi_kaydi-soyad = 'Kalan'.
personel_bilgi_kaydi-telefon_no = '5556622'.
APPEND personel_bilgi_kaydi TO personel_bilgileri.
Actually, I don’t know which adding record method I should use. I mean there is too many ways to do this operation. Which method will be the true one?
I am getting this error:
The field Personel_bilgileri is unknown, but there are following fields similar names...
Moreover, I can do this with LOOP AT, but I didn’t understand the usage of LOOP AT. What does it do?
In your code sample, you first defined
PERSONEL_BILGILERIas aTYPE, thenPERSONEL_BILGI_TABLO_TIPIas a internal tableTYPEofPERSONEL_BILGILERI.Up to that point, no variables are declared yet. Only data types.
Then:
PERSONEL_BILGI_KAYDIis defined of typePERSONEL_BILGILERI. This is a structure that you use as a work area (which is fine).PERSONEL_BILGI_TABLOSUis defined of typePERSONEL_BILGI_TABLO_TIPI. SoPERSONEL_BILGI_TABLOSUis your internal table.When you APPEND your work area, you have to append to an internal table, not a data type. try with
PERSONEL_BILGI_TABLOSUinstead of your typePERSONEL_BILGI: