0% found this document useful (0 votes)
11 views12 pages

Inc

Uploaded by

tntkrishna0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views12 pages

Inc

Uploaded by

tntkrishna0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 12

form check_db_table .

if sy-subrc eq
0."----------------------------------------------------------------------Check if
the database table exists and is accessible
" Read the table lt_final into work area wa_final with key act_year matching
the current year
read table lt_final into wa_final with key act_year = sy-datum+0(4).
if sy-subrc eq 0.
clear flag.
" Check if the action month and the current month are within the specified
ranges
if ( wa_final-act_month between '04' and '09' and sy-datum+4(2) between '04'
and '09' ).
flag = 1.
elseif ( wa_final-act_month between '10' and '12' or wa_final-act_month
between '01' and '03' and
sy-datum+4(2) between '01' and '03' or sy-datum+4(2) between '10'
and '12' ).
flag = 1.
elseif ( wa_final-act_month between '04' and '09' and sy-datum+4(2) between
'01' and '03' or sy-datum+4(2) between '10' and '12' ).
flag = 2.
elseif ( wa_final-act_month between '10' and '12' or wa_final-act_month
between '01' and '03' and sy-datum+4(2) between '04' and '09' ).
flag = 2.
endif.
endif.
elseif sy-subrc ne 0.
data(lv_check_year) = wa_final-act_year - sy-datum+0(4).
if lv_check_year eq 1.
flag = 2.
endif.
flag = 0.
endif.
endform.

form get_data .
case flag.
when '0'.
refresh lt_final.
clear wa_final.

wa_final-act_year = sy-datum+0(4).
wa_final-act_month = sy-datum+4(2).

select pernr begda persg ename


from pa0001
into table lt_pa0001
where pernr eq p_emp_no and
begda gt '20130701' and
endda eq '99991231'.

read table lt_pa0001 into wa_pa0001 index 1.


wa_final-emp_type = wa_pa0001-persg.
wa_final-act_emp = wa_pa0001-pernr.
wa_final-ename = wa_pa0001-ename.
case wa_pa0001-persg.
when 'A' or 'D'."Grant leaves for Regular and Deputation Employee
wa_final-grant_el = '15'.
wa_final-grant_hpl = '10'.
when 'B' or 'F'."Grant leaves for Contractual employee group
wa_final-grant_el = '2'.
wa_final-grant_hpl = '0'.
endcase.

select single gbdat


from pa0002
into wa_final-gbdat
where pernr eq wa_pa0001-pernr.

select single dat01


from pa0041
into wa_final-doj
where pernr eq wa_pa0001-pernr.

refresh lt_pa2006.
select pernr begda ktart anzhl kverb"Retrieve quota data for the employee
from zleave_act
into table lt_pa2006
where pernr = p_emp_no and
ktart in ( '14' , '3' , '16', '50', '54' ).

if sy-subrc eq 0.

clear: lv_quota_16, lv_quota_14.

loop at lt_pa2006 into wa_pa2006.

case wa_pa2006-ktart.
when '16'."----------------------------------------------------------
Calculate and update open balance for EL
lv_quota_16 = wa_pa2006-anzhl - wa_pa2006-kverb.
when '14'."----------------------------------------------------------
Calculate and update open balance for EL
lv_quota_14 = wa_pa2006-anzhl - wa_pa2006-kverb.
when '03'."----------------------------------------------------------
Calculate and update open balance for HPL
wa_final-open_bl_hpl = wa_pa2006-anzhl - wa_pa2006-kverb.
when '50' or '54'.
wa_final-open_bl_el = wa_final-open_bl_el + ( wa_pa2006-anzhl -
wa_pa2006-kverb ).
endcase.

endloop.

if wa_pa0001-persg eq 'A' or wa_pa0001-persg eq 'D'.

if lv_quota_16 is not initial."----------------------------------------


Check if quota for 16 type leaves is available
wa_final-open_bl_el = lv_quota_16 + lv_quota_14."--------------------
Calculate and update open balance for EL based on available quotas
else.
wa_final-open_bl_el = lv_quota_14."----------------------------------
If quota for 16 type leaves is not available, update open balance for EL with only
quota for 14 type leaves
endif.

endif.
x = wa_final-open_bl_el.
y = wa_final-open_bl_hpl.
endif.

perform encash using p_emp_no.


perform availed using p_emp_no.

lv_avail_hpl5 = lv_avail_hpl5 * 2.
wa_final-avail_hpl = wa_final-avail_hpl + lv_avail_hpl3 + lv_avail_hpl5.

if wa_final-grant_el =
'15'."----------------------------------------------------------Check if grant_el
equals '15'
lv_lapse_el = x + wa_final-grant_el." -----------------------------
Calculate lapse_el based on specific conditions when grant_el equals '15'
wa_final-open_bl_el = wa_final-open_bl_el + wa_final-
grant_el."----------------------added after requirement
wa_final-open_bl_hpl = wa_final-open_bl_hpl + wa_final-grant_hpl .
else.
perform get_contract_el.
count = count * 2.
lv_lapse_el_c = wa_final-open_bl_el + wa_final-grant_el.
wa_final-open_bl_el = wa_final-open_bl_el + count.
endif.
wa_final-close_el = wa_final-open_bl_el - wa_final-encash_el - wa_final-
avail_el.
wa_final-close_hpl = y.
if lv_lapse_el gt '300'.
wa_final-lapse_el = x - 300.
elseif lv_lapse_el_c gt '45'.
wa_final-lapse_el = wa_final-close_el - 45 .
endif.

wa_final-trans_date = sy-datum.
wa_final-user_id = sy-uname.
append wa_final to lt_final.

when '1'.
refresh lt_final.
clear wa_final.

select single emp_type act_emp open_bl_el open_bl_hpl grant_el grant_hpl


from zleave_actuarial
into ( wa_final-emp_type , wa_final-act_emp , wa_final-open_bl_el ,
wa_final-open_bl_hpl , wa_final-grant_el , wa_final-grant_hpl )
where act_emp eq p_emp_no.

wa_final-act_year = sy-datum+0(4).
wa_final-act_month = sy-datum+4(2).
select single gbdat
from pa0002
into wa_final-gbdat
where pernr eq p_emp_no.

select single dat01


from pa0041
into wa_final-doj
where pernr eq p_emp_no.
perform encash using p_emp_no.
perform availed using p_emp_no.

lv_avail_hpl5 = lv_avail_hpl5 * 2.
wa_final-avail_hpl = wa_final-avail_hpl + lv_avail_hpl3 + lv_avail_hpl5.

if wa_final-grant_el = '15'." Check if grant_el equals '15'


lv_lapse_el = x + wa_final-grant_el." Calculate lapse_el based on specific
conditions when grant_el equals '15'
else.
perform get_contract_el.
count = count * 2.
lv_lapse_el_c = wa_final-open_bl_el + wa_final-grant_el.
wa_final-open_bl_el = wa_final-open_bl_el + count.
endif.
wa_final-close_el = wa_final-open_bl_el - wa_final-encash_el - wa_final-
avail_el.
wa_final-close_hpl = wa_final-open_bl_hpl - wa_final-avail_hpl..
if lv_lapse_el gt '300'.
wa_final-lapse_el = wa_final-close_el - 300.
elseif lv_lapse_el_c gt '45'.
wa_final-lapse_el = wa_final-close_el - 45 .
endif.

wa_final-trans_date = sy-datum.
wa_final-user_id = sy-uname.
append wa_final to lt_final.

when '2'.

refresh lt_final.
clear wa_final.

select single emp_type act_emp close_el close_hpl


from zleave_actuarial
into ( wa_final-emp_type , wa_final-act_emp , wa_final-open_bl_el ,
wa_final-open_bl_hpl )
where act_emp eq p_emp_no.

wa_final-act_year = sy-datum+0(4).
wa_final-act_month = sy-datum+4(2).

case wa_final-emp_type.
when 'A' or 'D'."Grant leaves for Regular and Deputation Employee
wa_final-grant_el = '15'.
wa_final-grant_hpl = '10'.
when 'B' or 'F'."Grant leaves for Contractual employee group
wa_final-grant_el = '2'.
wa_final-grant_hpl = '0'.
endcase.

select single gbdat


from pa0002
into wa_final-gbdat
where pernr eq p_emp_no.

select single dat01


from pa0041
into wa_final-doj
where pernr eq p_emp_no.

x = wa_final-open_bl_el.
y = wa_final-open_bl_hpl.

perform encash using p_emp_no.


perform availed using p_emp_no.

lv_avail_hpl5 = lv_avail_hpl5 * 2.
wa_final-avail_hpl = wa_final-avail_hpl + lv_avail_hpl3 + lv_avail_hpl5.

if wa_final-grant_el = '15'." Check if grant_el equals '15'


lv_lapse_el = wa_final-open_bl_el + wa_final-grant_el." Calculate lapse_el
based on specific conditions when grant_el equals '15'
wa_final-open_bl_el = wa_final-open_bl_el + wa_final-
grant_el."----------------------added after requirement
wa_final-open_bl_hpl = wa_final-open_bl_hpl + wa_final-grant_hpl .
else.
lv_lapse_el_c = wa_final-open_bl_el + wa_final-grant_el.
endif.
wa_final-close_el = wa_final-open_bl_el - wa_final-encash_el - wa_final-
avail_el.
wa_final-close_hpl = y.
if lv_lapse_el gt '300'.
wa_final-lapse_el = wa_final-close_el - 300.
elseif lv_lapse_el_c gt '45'.
wa_final-lapse_el = wa_final-close_el - 45 .
endif.

wa_final-trans_date = sy-datum.
wa_final-user_id = sy-uname.
append wa_final to lt_final.

endcase.
endform.

form encash using lv_emp_no.


refresh lt_pa0416.
clear wa_pa0416.
select subty numbr"------------------------------Select the field 'numbr' from
table PA0416 and store the results in internal table lt_pa0416
from pa0416
into table lt_pa0416
where pernr = p_emp_no and
( begda between lv_f_date and sy-datum ) and
subty in ( '1000', '1001' , '1002', '1003' ).
if sy-subrc eq 0.
loop at lt_pa0416 into wa_pa0416."---------------Add the value of 'numbr' from
the current line to the 'encash_el' field of final structure
if wa_pa0416-subty eq '1001'.
wa_final-open_bl_hpl = wa_final-open_bl_hpl + wa_pa0416-numbr.
wa_final-avail_hpl = wa_pa0416-numbr.
elseif wa_pa0416-subty eq '1000' or wa_pa0416-subty eq '1003'.
wa_final-encash_el = wa_final-encash_el + wa_pa0416-numbr.
endif.
endloop.
endif.
endform.
form availed using lv_emp_no.
refresh lt_pa2001.
clear : wa_pa2001, lv_avail_hpl3, lv_avail_hpl5.
select pernr subty kaltg
from pa2001
into table lt_pa2001
where pernr = p_emp_no and
( begda between lv_f_date and sy-datum ) and
subty in ('1002', '1003', '1005', '1092', '1050', '1093').
if sy-subrc eq 0.
clear lv_counter.
loop at lt_pa2001 into wa_pa2001.
if ( wa_final-emp_type eq 'A' or wa_final-emp_type eq 'D' )."-----------
Check if employee group is 'A' or 'D' (Regular or Deputation)
* if ( wa_pa2001-subty eq '1002' or wa_pa2001-subty eq
'1092' )."-----------------------------------------Check if subtype is '1002' (EL)
* wa_final-avail_el = wa_final-avail_el + wa_pa2001-kaltg.
* elseif wa_pa2001-subty eq '1003'.
* lv_avail_hpl3 = lv_avail_hpl3 + wa_pa2001-kaltg. "edit
* elseif wa_pa2001-subty eq '1005'.
* lv_avail_hpl5 = lv_avail_hpl5 + wa_pa2001-kaltg. "edit
* endif.
case wa_pa2001-subty.
when '1002' or '1092'.
wa_final-avail_el = wa_final-avail_el + wa_pa2001-kaltg.
when '1003'.
lv_avail_hpl3 = lv_avail_hpl3 + wa_pa2001-kaltg.
when '1005'.
lv_avail_hpl5 = lv_avail_hpl5 + wa_pa2001-kaltg.
endcase.
elseif wa_final-emp_type eq 'B' or wa_final-emp_type eq 'F'.
if wa_pa2001-subty eq '1050' or wa_pa2001-subty eq '1093' .
wa_final-avail_el = wa_final-avail_el + wa_pa2001-kaltg.
endif.
endif.
endloop.
endif.
endform.

form fieldcatalog.
refresh lt_fcat2.
clear wa_fcat2.

wa_fcat2-col_pos = '01'.
wa_fcat2-fieldname = 'ACT_YEAR'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'Act Year'.
append wa_fcat2 to lt_fcat2.

wa_fcat2-col_pos = '02'.
wa_fcat2-fieldname = 'ACT_MONTH'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'Month'.
append wa_fcat2 to lt_fcat2.

wa_fcat2-col_pos = '03'.
wa_fcat2-fieldname = 'EMP_TYPE'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'Employee Type'.
append wa_fcat2 to lt_fcat2.

wa_fcat2-col_pos = '04'.
wa_fcat2-fieldname = 'ACT_EMP'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'Employee No'.
append wa_fcat2 to lt_fcat2.

wa_fcat2-col_pos = '05'.
wa_fcat2-fieldname = 'ENAME'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'Name'.
append wa_fcat2 to lt_fcat2.
clear wa_fcat2.

wa_fcat2-col_pos = '06'.
wa_fcat2-fieldname = 'GBDAT'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'DOB'.
append wa_fcat2 to lt_fcat2.
clear wa_fcat2.

wa_fcat2-col_pos = '07'.
wa_fcat2-fieldname = 'DOJ'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'DOJ'.
append wa_fcat2 to lt_fcat2.
clear wa_fcat2.

wa_fcat2-col_pos = '08'.
wa_fcat2-fieldname = 'OPEN_BL_EL'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'Opening EL Balance'.
append wa_fcat2 to lt_fcat2.
clear wa_fcat2.

wa_fcat2-col_pos = '09'.
wa_fcat2-fieldname = 'GRANT_EL'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'Lv. Credit'.
append wa_fcat2 to lt_fcat2.
clear wa_fcat2.

wa_fcat2-col_pos = '10'.
wa_fcat2-fieldname = 'AVAIL_EL'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'Lv. Availed'.
append wa_fcat2 to lt_fcat2.
clear wa_fcat2.

wa_fcat2-col_pos = '11'.
wa_fcat2-fieldname = 'ENCASH_EL'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'Lv. Encash'.
append wa_fcat2 to lt_fcat2.
clear wa_fcat2.

wa_fcat2-col_pos = '12'.
wa_fcat2-fieldname = 'LAPSE_EL'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'Lv Lapsed'.
append wa_fcat2 to lt_fcat2.
clear wa_fcat2.

wa_fcat2-col_pos = '13'.
wa_fcat2-fieldname = 'CLOSE_EL'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'Closing Balance'.
append wa_fcat2 to lt_fcat2.
clear wa_fcat2.

wa_fcat2-col_pos = '14'.
wa_fcat2-fieldname = 'OPEN_BL_HPL'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'Opening HPL Balance'.
append wa_fcat2 to lt_fcat2.
clear wa_fcat2.

wa_fcat2-col_pos = '15'.
wa_fcat2-fieldname = 'GRANT_HPL'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'Lv Credit'.
append wa_fcat2 to lt_fcat2.
clear wa_fcat2.

wa_fcat2-col_pos = '16'.
wa_fcat2-fieldname = 'AVAIL_HPL'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'Lv Availed'.
append wa_fcat2 to lt_fcat2.
clear wa_fcat2.

wa_fcat2-col_pos = '17'.
wa_fcat2-fieldname = 'CLOSE_HPL'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_l = 'Closing HPL'.
append wa_fcat2 to lt_fcat2.
clear wa_fcat2.

wa_fcat2-col_pos = '18'.
wa_fcat2-fieldname = 'TRANS_DATE'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'Trans Date'.
append wa_fcat2 to lt_fcat2.
clear wa_fcat2.

wa_fcat2-col_pos = '19'.
wa_fcat2-fieldname = 'USER_ID'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'User ID'.
append wa_fcat2 to lt_fcat2.
clear wa_fcat2.
endform.

form display_alv.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = lt_fcat2
tables
t_outtab = lt_final
exceptions
program_error = 1
others = 2.
endform.

form preparedropdown.
refresh lt_value.
clear wa_value.
wa_value-key = 'K1'.
wa_value-text = 'Regular'.
append wa_value to lt_value.

clear wa_value.
wa_value-key = 'K2'.
wa_value-text = 'Deputanist'.
append wa_value to lt_value.

clear wa_value.
wa_value-key = 'K3'.
wa_value-text = 'Contract'.
append wa_value to lt_value.

endform.

form displaydropdown .
call function 'VRM_SET_VALUES'
exporting
id = 'p_emp_ty'
values = lt_value
exceptions
id_illegal_name = 1
others = 2.
endform.

form f_add_buttons_and_text .
clear sscrfields.
"local variable declataions
data : lv_functxt type smp_dyntxt.

"Buttons for change on selection screen


clear : lv_functxt.
lv_functxt-text = 'SUBMIT'(007).
sscrfields-functxt_01 = lv_functxt.

"Buttons for disply on selection screen


clear : lv_functxt.
lv_functxt-text = 'APPROVED'(006).
sscrfields-functxt_02 = lv_functxt.

clear : lv_functxt.
lv_functxt-text = 'DISPLAY'(006).
sscrfields-functxt_03 = lv_functxt.
endform.

form prepare_date .
if p_month between '04' and '09'.
concatenate p_year '04' '01' into lv_f_date.
concatenate p_year '09' '01' into lv_date.
call function 'HR_JP_MONTH_BEGIN_END_DATE'
exporting
iv_date = lv_date
importing
ev_month_begin_date = lv_date
ev_month_end_date = lv_e_date.
elseif p_month between '10' and '03'.
concatenate p_year '10' '01' into lv_f_date." First day of October
p_year = p_year + 1.
concatenate p_year '03' '01' into lv_date." First day of March of next year
call function 'HR_JP_MONTH_BEGIN_END_DATE'
exporting
iv_date = lv_date
importing
ev_month_begin_date = lv_date
ev_month_end_date = lv_e_date.
endif.
endform.

form upload_data .
loop at lt_final into wa_final.
if flag eq 0.
* zleave_actuarial-act_year = wa_final-act_year.
* zleave_actuarial-act_month = wa_final-act_month.
* zleave_actuarial-emp_type = wa_final-emp_type.
* zleave_actuarial-open_bl_el = wa_final-open_bl_el.
* zleave_actuarial-open_bl_hpl = wa_final-open_bl_hpl.
* zleave_actuarial-grant_el = wa_final-grant_el.
* zleave_actuarial-grant_hpl = wa_final-grant_hpl.
* zleave_actuarial-encash_el = wa_final-encash_el.
* zleave_actuarial-avail_el = wa_final-avail_el.
* zleave_actuarial-avail_hpl = wa_final-avail_hpl.
* zleave_actuarial-lapse_el = wa_final-lapse_el.
* zleave_actuarial-close_el = wa_final-close_el.
* zleave_actuarial-close_hpl = wa_final-close_hpl.
* zleave_actuarial-trans_date = wa_final-trans_date.
* zleave_actuarial-user_id = wa_final-user_id.
* zleave_actuarial-act_emp = wa_final-act_emp.
move-corresponding wa_final to zleave_actuarial.
insert zleave_actuarial.
else.
update zleave_actuarial
set act_year = wa_final-act_year
act_month = wa_final-act_month
emp_type = wa_final-emp_type
open_bl_el = wa_final-open_bl_el
open_bl_hpl = wa_final-open_bl_hpl
grant_el = wa_final-grant_el
grant_hpl = wa_final-grant_hpl
encash_el = wa_final-encash_el
avail_el = wa_final-avail_el
avail_hpl = wa_final-avail_hpl
lapse_el = wa_final-lapse_el
close_el = wa_final-close_el
close_hpl = wa_final-close_hpl
trans_date = wa_final-trans_date
user_id = wa_final-user_id
where act_emp = wa_final-act_emp.
endif.
if sy-subrc eq 0.
message 'Submitted Successfully' type 'S'.
else.
message 'Update Failed' type 'E'.
endif.
endloop.
endform.

form gen_info .
if sy-subrc eq 0.
select single ename
from pa0001
into wa_final-ename
where pernr eq p_emp_no.

select single gbdat


from pa0002
into wa_final-gbdat
where pernr eq p_emp_no.

select single dat01


from pa0041
into wa_final-doj
where pernr eq p_emp_no.

modify lt_final from wa_final transporting ename gbdat doj where act_emp =
p_emp_no.
else.
message 'The employee is not submitted yet...' type 'E'.
endif.
endform.

form get_db_data .
refresh lt_final.
clear lt_final.
select *
from zleave_actuarial
into corresponding fields of table lt_final
where act_emp eq p_emp_no.
endform.

form dis_usr_data .
if sy-subrc eq 0.
read table lt_final into wa_final with key act_emp = p_emp_no.
if sy-subrc eq 0.
refresh lt_dis_msg.
lt_dis_msg-approve_info = 'User ID :-' && wa_final-user_id.
append lt_dis_msg.
lt_dis_msg-approve_info = 'Date :-' && wa_final-trans_date+6(2) && '.' &&
wa_final-trans_date+4(2) && '.' && wa_final-trans_date(4).
append lt_dis_msg.
call function 'POPUP_WITH_TABLE_DISPLAY_OK'
exporting
endpos_col = 60
endpos_row = 4
startpos_col = 1
startpos_row = 1
titletext = 'HELLO'
tables
valuetab = lt_dis_msg
exceptions
break_off = 1
others = 2.
endif.
else.
message 'The employee is not approved yet...' type 'E'.
endif.
endform.

form get_contract_el .
if sy-datum+4(2) between '04' and '09'.
clear count.
count = 1.
count = count + sy-datum+4(2) - 4.
elseif sy-datum+4(2) between '10' and '12'.
clear count.
count = 1.
count = count + sy-datum+4(2) - 10.
elseif sy-datum+4(2) between '01' and '03'.
clear count.
count = 3.
count = count + sy-datum+4(2).
endif.
endform.

You might also like