0% found this document useful (0 votes)
5 views

Abap 1

Uploaded by

tntkrishna0
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Abap 1

Uploaded by

tntkrishna0
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 10

REPORT ZPRG_LEAVE_ACTUARIAL_DEMO1.

*----------------------------------------------------------------------*
* PROGRAM NAME : ZPRG_LEAVE_ACTUARIAL *
* PACKAGE : *
* PROGRAM TITLE : *
*
* LAST REQUEST NUMBER :
* PROGRAM TITLE :LEAVE ACTUAIAL REPORT
* MODULE :HR
* PROGRAM TYPE :EXECUTABLE
* INPUT :SELECTION SCREEN
* OUTPUT :ALV REPORT
* TEAM LEAD :PRITEE BISHT
* CREATED BY :KRISHNA
* FUNCTIONAL CONSULTENT :VIKASH
* CREATION DATE :09-APRIL-2024
* LOCAL FILE NAME :
* RECORDING NAME :
* FORM NAME :
*-----------------------------------------------------------------------
* DESCRIPTION :LEAVE ACTUARIAL REPORT
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
tables ZLEAVE_ACTUARIAL.

INCLUDE ZPRG_LEAVE_ACTUARIAL_TOP_DEMO1.
*&---------------------------------------------------------------------*
*& include zprg_leave_actuarial_top
*& decalaration of structure
*&---------------------------------------------------------------------*

types: begin of t_pa0001,


pernr type pa0001-pernr, " personnel number
begda type pa0001-begda, " start date
persg type pa0001-persg, " employee group
ename type pa0001-ename, " formatted name of employee or applicant
end of t_pa0001.

types: begin of t_pa2006,


pernr type pa2006-pernr,
begda type pa2006-begda,
ktart type pa2006-ktart,
anzhl type pa2006-anzhl, " number of employee time quota
kverb type pa2006-kverb,
end of t_pa2006.

types: begin of t_pa0416,


numbr type pa0416-numbr, " quota number compensated
end of t_pa0416.

types: begin of t_pa2001,


pernr type pa2001-pernr,
subty type pa2001-subty,
kaltg type pa2001-kaltg,
end of t_pa2001.

types: begin of t_pa0002,


gbdat type pa0002-gbdat, " date of birth
end of t_pa0002.

types: begin of t_pa0041,


dar01 type pa0041-dar01, " date type
end of t_pa0041.

types: begin of t_final,


act_year type zleave_actuarial-act_year, " actuarial year
act_month type zleave_actuarial-act_month, " actuarial month
emp_type type zleave_actuarial-emp_type, " employee type
act_emp type zleave_actuarial-act_emp, " personnel number
open_bl_el type zleave_actuarial-open_bl_el, " number of leaves
open_bl_hpl type zleave_actuarial-open_bl_hpl, " number of leaves
grant_el type zleave_actuarial-grant_el, " number of leaves
grant_hpl type zleave_actuarial-grant_hpl, " number of leaves
encash_el type zleave_actuarial-encash_el, " number of leaves
avail_el type zleave_actuarial-avail_el, " number of leaves
avail_hpl type zleave_actuarial-avail_hpl, " number of leaves
lapse_el type zleave_actuarial-lapse_el, " number of leaves
close_el type zleave_actuarial-close_el, " number of leaves
close_hpl type zleave_actuarial-close_hpl, " number of leaves
trans_date type zleave_actuarial-trans_date, " field of type dats
user_id type zleave_actuarial-user_id, " user id
end of t_final.

*----------------------------------------------------------------------*
* decalaration of internal tables and work area
*----------------------------------------------------------------------*
data: lt_pa0001 type table of t_pa0001,
wa_pa0001 type t_pa0001.

data: lt_pa2006 type table of t_pa2006,


wa_pa2006 type t_pa2006.

data: lt_pa0416 type table of t_pa0416,


wa_pa0416 type t_pa0416.

data: lt_pa2001 type table of t_pa2001,


wa_pa2001 type t_pa2001.

data: lt_pa0002 type table of t_pa0002,


wa_pa0002 type t_pa0002.

data: lt_pa0041 type table of t_pa0041,


wa_pa0041 type t_pa0041.

data: lt_final type table of t_final,


wa_final type t_final.

data: lv_day(2) type c value '01',


lv_str_begda(8) type c,
lv_end_begda(8) type c,
lv_endda(8) type c value '99991231'.

data: lv_counter(2) type c.

data : lt_fcat type slis_t_fieldcat_alv,


wa_fcat type slis_fieldcat_alv.
data : lt_fcat2 type slis_t_fieldcat_alv,
wa_fcat2 type slis_fieldcat_alv.

data : ls_slis_formname type slis_formname.

data : lv_quota_16 type c length 10.


data : lv_quota_14 type c length 10.
data : lv_lapse_el type zleave_actuarial-lapse_el.
data : lv_lapse_el_c type zleave_actuarial-lapse_el.
INCLUDE ZPRG_LEAVE_ACTUARIAL_SCR_DEMO1.
*&---------------------------------------------------------------------*
*& Include ZPRG_LEAVE_ACTUARIAL_SEL_SCR
*&---------------------------------------------------------------------*

select-options so_year for zleave_actuarial-act_year default '2024' obligatory no-


extension no intervals.
select-options so_month for zleave_actuarial-act_month obligatory no-extension no
intervals.

*if so_month-low eq 12.


* concatenate so_year-low so_month-low lv_day into lv_begda.
* so_year-low = so_year-low + 1.
* append so_year.
* so_month-low = '01'.
* append so_month.
* concatenate so_year-low so_month-low lv_day into lv_end_begda.
* refresh lt_date.
* clear wa_date.
* wa_date-sign = 'I'.
* wa_date-option = 'EQ'.
*concatenate so_year-low so_month-low lv_day into lv_begda.
* append wa_date to lt_date.
* so_year-low = so_year-low + 1.
* append so_year.
* so_month-low = '01'.
* append so_month.
* wa_date-high = sy-datum.
*else.
* refresh lt_date.
* clear wa_date.
* wa_date-sign = 'I'.
* wa_date-option = 'BT'.
* concatenate so_year-low so_month-low lv_day into wa_date-low.
* so_month-low = so_month-low + 1.
* append so_month.
* wa_date-high = sy-datum.
* append wa_date to lt_date.
*endif.
*concatenate so_year-low so_month-low lv_day into wa_date-low.
*
*data flag type i value 5.
*do flag times.
* so_month-low = so_month-low + 1.
* append so_month.
* flag = flag - 1.
* if so_month-low eq '12'.
* so_month-low = '00'.
* do flag times.
* so_month-low = so_month-low + 1.
* append so_month.
* flag = flag - 1.
* if flag eq 0.
* so_year-low = so_year-low + 1.
* append so_year.
* exit.
* endif.
* enddo.
* endif.
* if flag eq 0.
* exit.
* endif.
*enddo.
*concatenate so_year-low so_month-low lv_day into wa_date-high.
*append wa_date to lt_date.

if so_month-low ge '01' and


so_month-low le '09'.
so_month-low = '04'.
append so_month.
concatenate so_year-low so_month-low lv_day into lv_str_begda.
so_month-low = so_month-low + 6.
append so_month.
concatenate so_year-low so_month-low lv_day into lv_end_begda.
else.
so_month-low = '10'.
append so_month.
concatenate so_year-low so_month-low lv_day into lv_str_begda.
so_month-low = '03'.
append so_month.
so_year-low = so_year-low + 1.
append so_year.
concatenate so_year-low so_month-low lv_day into lv_end_begda.
endif.
INCLUDE ZPRG_LEAVE_ACTUARIAL_SUB_DEMO1.
"----------------------------------------------------------------------*
" Start of Form: GET_DATA
" Description: Retrieves data based on selection criteria
"----------------------------------------------------------------------*

form get_data."--------------------------------------------------------" Retrieve


employee data

select pernr, begda "Retrieve quota data for the employee


from pa2006
into table @data(lt_temp_pa2006)
where endda eq '99991231' and
begda ge @lv_str_begda and
begda lt @lv_end_begda and
ktart in ( '14' , '3' , '16' ).
if sy-subrc eq 0.
select pernr begda persg ename
from pa0001
into table lt_pa0001
for all entries in lt_temp_pa2006
where pernr eq lt_temp_pa2006-pernr and
begda ge lv_str_begda and
begda lt lv_end_begda and
persg in ( 'A', 'D', 'C' ).
delete adjacent duplicates from lt_pa0001 comparing pernr.
endif.

endform.

form fieldcatalog .

wa_fcat-col_pos = '01'.
wa_fcat-fieldname = 'PERNR'.
wa_fcat-tabname = 'lt_pa0001'.
wa_fcat-seltext_m = 'Employee No'.
append wa_fcat to lt_fcat.
clear wa_fcat.

wa_fcat-col_pos = '02'.
wa_fcat-fieldname = 'BEGDA'.
wa_fcat-tabname = 'lt_pa0001'.
wa_fcat-seltext_m = 'Date'.
append wa_fcat to lt_fcat.
clear wa_fcat.

wa_fcat-col_pos = '03'.
wa_fcat-fieldname = 'PERSG'.
wa_fcat-tabname = 'lt_pa0001'.
wa_fcat-seltext_m = 'Employee Type'.
append wa_fcat to lt_fcat.
clear wa_fcat.

wa_fcat-col_pos = '04'.
wa_fcat-fieldname = 'ENAME'.
wa_fcat-tabname = 'lt_pa0001'.
wa_fcat-seltext_m = 'Employee Name'.
append wa_fcat to lt_fcat.
clear wa_fcat.

endform.

form display_alv .
ls_slis_formname = 'USER_COMMAND_POP'.
sort lt_pa0001 by pernr.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = sy-repid
i_callback_user_command = ls_slis_formname
it_fieldcat = lt_fcat
tables
t_outtab = lt_pa0001
exceptions
program_error = 1
others = 2.
endform.

form user_command_pop using vl_ucomm like sy-ucomm


i_selfield type slis_selfield.

read table lt_pa0001 into wa_pa0001 index i_selfield-tabindex.


if sy-subrc eq 0.
refresh lt_final.
clear wa_final.
"Extract year from the start date and assign it to the 'act_year' field of
final structure
wa_final-act_year = wa_pa0001-begda+0(4).
"Extract month from the start date and assign it to the 'act_month' field of
final structure
wa_final-act_month = wa_pa0001-begda+4(2).
" Assign employee type from PA0001 table to the 'emp_type' field of final
structure
wa_final-emp_type = wa_pa0001-persg.
" Assign personnel number from PA0001 table to the 'act_emp' field of final
structure
wa_final-act_emp = wa_pa0001-pernr.

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 'C'."Grant leaves for Contractual employee group
wa_final-grant_el = '2'.
wa_final-grant_hpl = 'N/A'.
endcase.

refresh lt_pa2006.
select pernr begda ktart anzhl kverb"Retrieve quota data for the employee
from pa2006
into table lt_pa2006
where pernr = wa_pa0001-pernr and
* begda ge lv_str_begda and
* begda lt lv_end_begda and
ktart in ( '14' , '3' , '16' ).

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.
endcase.
endloop.

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.

refresh lt_pa0416.
select 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 = wa_pa0001-pernr and
* begda ge lv_str_begda and
* begda lt lv_end_begda and
subty = '1000'.
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
wa_final-encash_el = wa_final-encash_el + wa_pa0416-numbr.
endloop.
endif.

refresh lt_pa2001.
select pernr subty kaltg
from pa2001
into table lt_pa2001
where pernr = wa_pa0001-pernr and
* begda ge lv_str_begda and
* begda lt lv_end_begda and
subty in ('1002', '1003').
if sy-subrc eq 0.
loop at lt_pa2001 into wa_pa2001.
if wa_pa0001-persg eq 'A' or
wa_pa0001-persg eq 'D'.
if wa_pa2001-subty eq '1002'.
if lv_counter ne 'A2'.
wa_final-avail_el = wa_final-avail_el + ( wa_final-grant_el -
wa_pa2001-kaltg ).
lv_counter = 'A2'.
elseif lv_counter eq 'A2'.
wa_final-avail_el = wa_final-avail_el + wa_pa2001-kaltg .
endif.
elseif wa_pa2001-subty eq '1003'.
if lv_counter ne 'A3'.
wa_final-avail_hpl = wa_final-avail_hpl + ( wa_final-grant_hpl
- wa_pa2001-kaltg ).
lv_counter = 'A3'.
elseif lv_counter eq 'A3'.
wa_final-avail_hpl = wa_final-avail_hpl + wa_pa2001-kaltg .
endif.
endif.
elseif wa_pa0001-persg eq 'C'.
if wa_pa2001-subty eq '1002'.
if lv_counter ne 'C2'.
wa_final-avail_el = wa_final-avail_el + ( wa_final-grant_el -
wa_pa2001-kaltg ).
lv_counter = 'C2'.
elseif lv_counter eq 'C2'.
wa_final-avail_el = wa_final-avail_el + wa_pa2001-kaltg .
endif.
elseif wa_pa2001-subty eq '1003'.
if lv_counter ne 'C3'.
wa_final-avail_hpl = wa_final-avail_hpl + ( wa_final-grant_hpl
- wa_pa2001-kaltg ).
lv_counter = 'C3'.
elseif lv_counter eq 'C3'.
wa_final-avail_hpl = wa_final-avail_hpl + wa_pa2001-kaltg .
endif.
endif.
endif.
endloop.
endif.

endif.

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'
else.
lv_lapse_el_c = wa_final-open_bl_el + wa_final-grant_el.
endif.
if lv_lapse_el gt '300'.
wa_final-lapse_el = lv_lapse_el.
elseif lv_lapse_el_c gt '45'.
wa_final-lapse_el = lv_lapse_el_c.
endif.
wa_final-close_el = wa_final-grant_el + wa_final-open_bl_el - wa_final-
avail_el - wa_final-encash_el .
wa_final-close_hpl = ( wa_final-grant_hpl + wa_final-open_bl_hpl ) -
wa_final-avail_hpl .

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

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 = 'Acturial Year'.
append wa_fcat2 to lt_fcat2.
clear wa_fcat2.

wa_fcat2-col_pos = '02'.
wa_fcat2-fieldname = 'ACT_MONTH'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'Acturial Month'.
append wa_fcat2 to lt_fcat2.
clear wa_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.
clear wa_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.
clear wa_fcat2.

wa_fcat2-col_pos = '05'.
wa_fcat2-fieldname = 'OPEN_BL_EL'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'Open BL EL'.
append wa_fcat2 to lt_fcat2.
clear wa_fcat2.

wa_fcat2-col_pos = '06'.
wa_fcat2-fieldname = 'OPEN_BL_HPL'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'Open BL HPL'.
append wa_fcat2 to lt_fcat2.
clear wa_fcat2.

wa_fcat2-col_pos = '07'.
wa_fcat2-fieldname = 'GRANT_EL'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'Grant EL'.
append wa_fcat2 to lt_fcat2.
clear wa_fcat2.

wa_fcat2-col_pos = '08'.
wa_fcat2-fieldname = 'GRANT_HPL'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'Grant HPL'.
append wa_fcat2 to lt_fcat2.
clear wa_fcat2.

wa_fcat2-col_pos = '09'.
wa_fcat2-fieldname = 'ENCASH_EL'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'Encash EL'.
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 = 'Avail EL'.
append wa_fcat2 to lt_fcat2.
clear wa_fcat2.

wa_fcat2-col_pos = '11'.
wa_fcat2-fieldname = 'AVAIL_HPL'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'Avail HPL'.
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 = 'Lapse EL'.
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 = 'Close EL'.
append wa_fcat2 to lt_fcat2.
clear wa_fcat2.

wa_fcat2-col_pos = '14'.
wa_fcat2-fieldname = 'CLOSE_HPL'.
wa_fcat2-tabname = 'lt_final'.
wa_fcat2-seltext_m = 'Close HPL'.
append wa_fcat2 to lt_fcat2.
clear wa_fcat2.

wa_fcat2-col_pos = '15'.
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 = '16'.
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.

call function 'REUSE_ALV_GRID_DISPLAY'


exporting
it_fieldcat = lt_fcat2
tables
t_outtab = lt_final
exceptions
program_error = 1
others = 2.
endform.

at selection-screen output.
loop at screen.
if screen-name eq 'SO_YEAR-LOW'.
screen-input = '0'.
modify screen.
endif.
endloop.

start-of-selection.
perform get_data.
perform fieldcatalog.
perform display_alv.

You might also like