Sıralı tablo kullanımı

types: begin of typ_lfa1,
lifnr type lfa1-lifnr,
name1 type lfa1-name1,
end of typ_lfa1.
data: gt_lfa1 type sorted table of typ_lfa1 with unique key lifnr
with header line.


*&---------------------------------------------------------------------*
*&      Form  READ_LFA1
*&---------------------------------------------------------------------*
form read_lfa1  using    piv_parnr type ihpa-parnr
changing pcs_lfa1  type typ_lfa1.
clear pcs_lfa1.
read table gt_lfa1 into pcs_lfa1 with table key lifnr = piv_parnr.
if sy-subrc ne 0.
select single *
into corresponding fields of pcs_lfa1
from lfa1
where lifnr eq piv_parnr.
check sy-subrc eq 0.
insert pcs_lfa1 into table gt_lfa1.
endif.
endform.                                                    " READ_LFA1