You are on page 1of 4

REPORT ZDEMO_PRG1.

*data ls_emp type zdemoemployee.

*types : begin of ty_emp,


* f1 type zdemoemployee-mandt,
* empno type zdemoemployee-empno,
* ename type zdemoemployee-ename,
* empdesig type zdemoemployee-empdesig,
* end of ty_emp.

types : begin of ty_emp.


include structure zdemoemployee.
types end of ty_emp.

data ls_emp type ty_emp.

data lv_flag type i.

types : begin of ty_f4values,


empno type zdemoemployee-empno,
ename type zdemoemployee-ename,
end of ty_f4values.

data lt_f4values type table of ty_f4values.

selection-SCREEN begin of block bk1


with FRAME title t1.
* PARAMETERS p_x type i.
* PARAMETERS p_empno type zemp_num. (or)
selection-screen BEGIN OF line.
SELECTION-SCREEN comment 7(15) lb1.
parameters p_empno type zdemoemployee-empno.
SELECTION-SCREEN end of LINE.

selection-SCREEN begin of LINE.


selection-screen COMMENT 7(15) lb2.
parameter p_ename type zdemoemployee-ename.
selection-SCREEN end of line.

selection-SCREEN begin of LINE.


selection-screen COMMENT 7(15) lb3.
parameter p_desig type zdemoemployee-empdesig.
selection-SCREEN end of line.
selection-SCREEN end of BLOCK bk1.

SELECTION-SCREEN begin of block bk2


with FRAME title t2.
SELECTION-SCREEN PUSHBUTTON 5(12) b1 USER-COMMAND p1.
SELECTION-SCREEN PUSHBUTTON 19(12) b2 USER-COMMAND p2.
SELECTION-SCREEN PUSHBUTTON 33(12) b3 USER-COMMAND p3.
selection-SCREEN skip 2.
SELECTION-SCREEN PUSHBUTTON /5(12) b4 USER-COMMAND p4.
SELECTION-SCREEN PUSHBUTTON 19(12) b5 USER-COMMAND p5.
SELECTION-SCREEN PUSHBUTTON 33(12) b6 USER-COMMAND p6.
SELECTION-SCREEN end of BLOCK bk2.

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.

at SELECTION-SCREEN on VALUE-REQUEST FOR p_empno.


perform getf4values.
if lt_f4values[] is not INITIAL.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
RETFIELD = 'EMPNO'
* DYNPPROG = 'ZDEMO_PRG1'
DYNPPROG = SY-REPID
* DYNPNR = '1000'
DYNPNR = sy-dynnr
DYNPROFIELD = 'P_EMPNO'
VALUE_ORG = 'S'
TABLES
VALUE_TAB = lt_f4values[].

endif.

at SELECTION-SCREEN on HELP-REQUEST FOR p_empno.


CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
TITEL = 'Custom F1 Help'
TXT1 = 'Employee Number'
TXT2 = 'TABLE : zdemoemployee, Field : empno'.

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

You might also like