Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

*&---------------------------------------------------------------------*

*& Report ZP34


*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZP34.
types : begin of ty_emp,
empno type i,
empname(20) type c,
empdesign(20) type c,
end of ty_emp.

*data t_emp1 type SORTED TABLE OF ty_emp. "syntax error


* data t_emp1 type SORTED TABLE OF ty_emp with NON-UNIQUE key empno. " supports
data : t_emp1 type SORTED TABLE OF ty_emp with UNIQUE key empno empname,
wa_emp type ty_emp.

clear wa_emp.
wa_emp-empno = 1.
wa_emp-empname = 'Faiyaz'.
wa_emp-empdesign = 'MD'.
APPEND wa_emp to t_emp1.

clear wa_emp.
wa_emp-empno = 2.
wa_emp-empname = 'Riyaz'.
wa_emp-empdesign = 'CEO'.
APPEND wa_emp to t_emp1.

clear wa_emp.
wa_emp-empno = 4.
wa_emp-empname = 'FARAZ'.
wa_emp-empdesign = 'Director'.
APPEND wa_emp to t_emp1.

clear wa_emp.
wa_emp-empno = 7.
wa_emp-empname = 'Shahid'.
wa_emp-empdesign = 'Legal'.
APPEND wa_emp to t_emp1.

write : / 'Data in internal sorted table t_emp1..'.


loop at t_emp1 into wa_emp.
write : / wa_emp-empno,wa_emp-empname,wa_emp-empdesign.
ENDLOOP.

uline.
clear wa_emp.
wa_emp-empno = 6.
wa_emp-empname = 'Afjal'.
wa_emp-empdesign = 'CIO'.
*APPEND wa_emp to t_emp1. " runtime error
insert wa_emp into table t_emp1.

write : / 'Data in internal sorted table t_emp1 after insert..'.


loop at t_emp1 into wa_emp.
write : / wa_emp-empno,wa_emp-empname,wa_emp-empdesign.
ENDLOOP.

uline.
clear wa_emp.
wa_emp-empno = 2.
wa_emp-empname = 'Ajay'.
wa_emp-empdesign = 'Manager'.
*APPEND wa_emp to t_emp1. " runtime error
insert wa_emp into table t_emp1. " duplicate not insert ignore

write : / 'Data in internal sorted table t_emp1 after insert..'.


loop at t_emp1 into wa_emp.
write : / wa_emp-empno,wa_emp-empname,wa_emp-empdesign.
ENDLOOP.

You might also like