Professional Documents
Culture Documents
Zdemo PRG1
Zdemo PRG1
INITIALIZATION.
lb1 = 'Employee No'.
lb2 = 'Employee Name'.
lb3 = 'Designation'.
t1 = 'Employee'.
b1 = 'Search'.
b2 = 'Insert'.
b3 = 'Modify'.
b4 = 'Delete'.
b5 = 'Clear'.
b6 = 'Exit'.
t2 = 'DB Operations'.
at SELECTION-SCREEN OUTPUT.
if lv_flag eq 0.
perform invisibleblock1.
elseif lv_flag eq 2.
perform visibleblock1.
perform disableempno.
elseif lv_flag eq 3.
perform enableempno.
endif.
at SELECTION-SCREEN.
CASE sy-ucomm.
when 'P6'.
leave PROGRAM.
when 'P1'.
if p_empno is not INITIAL.
select single ename empdesig
from zdemoemployee
into (p_ename,p_desig)
where empno = p_empno.
if sy-subrc ne 0.
message 'Record not found' type 'I'.
lv_flag = 0.
else.
lv_flag = 2.
endif.
else.
message 'Please enter empno' type 'I'.
lv_flag = 0.
endif.
when 'P5'.
perform clearfields.
when 'P2'.
if p_empno is not INITIAL.
clear ls_emp.
ls_emp-empno = p_empno.
ls_emp-ename = p_ename.
ls_emp-empdesig = p_desig.
* insert zdemoemployee from ls_emp.
modify zdemoemployee from ls_emp.
if sy-subrc eq 0.
message 'Inserted/modified' type 'I'.
else.
message 'Not inserted' type 'I'.
endif.
else.
message 'Please enter empno' type 'I'.
endif.
when 'P3'.
if p_empno is not INITIAL.
update zdemoemployee
set ename = p_ename
empdesig = p_desig
where empno = p_empno.
if sy-subrc eq 0.
message 'modified successfully' type 'I'.
lv_flag = 3.
endif.
else.
message 'Please enter empno' type 'I'.
endif.
when 'P4'.
if p_empno is not INITIAL.
delete from zdemoemployee
where empno = p_empno.
if sy-subrc eq 0.
message 'Record deleted' type 'I'.
perform clearfields.
else.
message 'Record not found for deletion' type 'I'.
endif.
else.
message 'please enter empno' type 'I'.
endif.
endcase.
endif.
FORM CLEARFIELDS .
clear : p_empno,
p_ename,
p_desig.
ENDFORM. " CLEARFIELDS
FORM INVISIBLEBLOCK1 .
loop at SCREEN.
if screen-name = 'LB2' or
screen-name = 'P_ENAME' or
screen-name = 'LB3' or
screen-name = 'P_DESIG'.
screen-invisible = '1'.
screen-input = '0'. "for inputfields
modify screen.
endif.
endloop.
ENDFORM. " INVISIBLEBLOCK1
FORM VISIBLEBLOCK1.
loop at SCREEN.
if screen-name = 'LB2' or
screen-name = 'P_ENAME' or
screen-name = 'LB3' or
screen-name = 'P_DESIG'.
screen-invisible = '0'.
screen-input = '1'. "for inputfields
modify screen.
endif.
endloop.
ENDFORM. " VISIBLEBLOCK1
FORM DISABLEEMPNO .
loop at screen.
if screen-name = 'P_EMPNO'.
screen-input = '0'.
modify SCREEN.
endif.
endloop.
ENDFORM. " DISABLEEMPNO
FORM ENABLEEMPNO .
loop at SCREEN.
if screen-name = 'P_EMPNO'.
screen-input = '1'.
MODIFY SCREEN.
endif.
endloop.
perform clearfields.
ENDFORM. " ENABLEEMPNO
FORM GETF4VALUES .
select empno ename from zdemoemployee
into table lt_f4values.
ENDFORM. " GETF4VALUES