* Get the employees who takes unauthorised leave for more than 10 days or having
* more than 21 days leave
tables: pa2001,
pa0001,
pa0000.
type-pools: slis.
types: begin of ty_pa2001,
pernr like pa2001-pernr,
subty like pa2001-subty,
begda like pa2001-begda,
endda like pa2001-endda,
kaltg like pa2001-kaltg,
end of ty_pa2001.
types: begin of ty_pa0002,
pernr like pa0002-pernr,
vorna like pa0002-vorna,
nachn like pa0002-nachn,
end of ty_pa0002.
types: begin of ty_pa0000,
pernr like pa0000-pernr,
begda like pa0000-begda,
endda like pa0000-endda,
stat2 like pa0000-stat2,
end of ty_pa0000.
types: begin of ty_pa0001,
pernr like pa0001-pernr,
begda like pa0001-begda,
endda like pa0001-endda,
werks like pa0001-werks,
persg like pa0001-persg,
persk like pa0001-persk,
btrtl like pa0001-btrtl,
end of ty_pa0001.
types: begin of ty_final,
pernr like pa2001-pernr,
vorna like pa0002-vorna,
nachn like pa0002-nachn,
begda like pa2001-begda,
endda like pa2001-endda,
werks like pa0001-werks,
persg like pa0001-persg,
persk like pa0001-persk,
btrtl like pa0001-btrtl,
stat type char20,
kaltg like pa2001-kaltg,
tdays type i,
end of ty_final.
data: it_pa2001 type table of ty_pa2001 with header line,
it_tmp_pa2001 type table of ty_pa2001 with header line,
it_pa0002 type table of ty_pa0002 with header line,
it_pa0000 type table of ty_pa0000 with header line,
it_pa0001 type table of ty_pa0001 with header line,
it_final type table of ty_final with header line,
it_fieldcat type slis_t_fieldcat_alv,
wa_fieldcat type slis_fieldcat_alv,
it_layout type slis_layout_alv,
it_events type slis_t_event,
wa_events type slis_alv_event,
it_list type slis_t_listheader with header line.
data: v_days type i,
total_days type i.
selection-screen begin of block b1 with frame title text-001.
select-options: s_pernr for pa2001-pernr,
s_date for sy-datum ,
s_werks for pa0001-werks,
s_btrtl for pa0001-btrtl,
s_persg for pa0001-persg,
s_persk for pa0001-persk,
s_stat2 for pa0000-stat2 no intervals.
selection-screen end of block b1 .
at selection-screen output.
loop at screen.
if screen-name = 'S_DATE-LOW' or screen-name = 'S_DATE-HIGH'.
screen-required = '1'.
modify screen.
endif.
endloop.
start-of-selection.
select pernr
begda
endda
stat2 from pa0000
into table it_pa0000
where pernr in s_pernr
and stat2 in s_stat2.
if sy-subrc = 0.
select pernr
begda
endda
werks
persg
persk
btrtl
from pa0001
into table it_pa0001
for all entries in it_pa0000
where pernr = it_pa0000-pernr
and werks in s_werks
and persg in s_persg
and persk in s_persk
and btrtl in s_btrtl.
if sy-subrc = 0.
select pernr
subty
begda
endda
kaltg
from pa2001
into table it_pa2001
for all entries in it_pa0001
where pernr = it_pa0001-pernr
and begda le s_date-high
and endda ge s_date-low
and subty = '5110'.
if sy-subrc = 0.
select pernr
vorna
nachn
from pa0002
into table it_pa0002
for all entries in it_pa2001
where pernr = it_pa2001-pernr
and sprsl = 'EN'.
endif.
endif.
endif.
it_tmp_pa2001[] = it_pa2001[].
sort it_pa2001 by pernr ascending kaltg descending.
delete adjacent duplicates from it_pa2001 comparing pernr.
end-of-selection.
perform process_data.
perform build_fieldcat.
perform get_events.
perform top_of_page.
perform display_alv.
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCAT
*----------------------------------------------------------------------*
form build_fieldcat .
wa_fieldcat-fieldname = 'PERNR'.
wa_fieldcat-seltext_l = 'Personnel Number'.
wa_fieldcat-just = 'C'.
append wa_fieldcat to it_fieldcat.
wa_fieldcat-fieldname = 'VORNA'.
wa_fieldcat-seltext_l = 'First Name'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'NACHN'.
wa_fieldcat-seltext_l = 'Last Name'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'BEGDA'.
wa_fieldcat-seltext_l = 'Start Date'.
wa_fieldcat-just = 'C'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ENDDA'.
wa_fieldcat-seltext_l = 'End Date'.
wa_fieldcat-just = 'C'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'WERKS'.
wa_fieldcat-seltext_l = 'Personnel Area'.
wa_fieldcat-just = 'C'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'BTRTL'.
wa_fieldcat-seltext_l = 'Personnel Subarea'.
wa_fieldcat-just = 'C'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'PERSG'.
wa_fieldcat-seltext_l = 'Employee Group'.
wa_fieldcat-just = 'C'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'PERSK'.
wa_fieldcat-seltext_l = 'Employee Subgroup'.
wa_fieldcat-just = 'C'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'STAT'.
wa_fieldcat-seltext_l = 'Employment Status'.
wa_fieldcat-just = 'C'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'KALTG'.
wa_fieldcat-seltext_l = 'Continious Unauthorised Leave'.
wa_fieldcat-just = 'C'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'TDAYS'.
wa_fieldcat-seltext_l = 'Total No of Absence Days in the Year'.
wa_fieldcat-just = 'C'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
endform. " BUILD_FIELDCAT
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV
*----------------------------------------------------------------------*
form display_alv .
delete adjacent duplicates from it_final comparing pernr.
it_layout-zebra = 'X'.
it_layout-colwidth_optimize = 'X'.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = sy-repid
is_layout = it_layout
it_fieldcat = it_fieldcat
it_events = it_events
tables
t_outtab = it_final.
endform. " DISPLAY_ALV
*&---------------------------------------------------------------------*
*& Form PROCESS_DATA
*----------------------------------------------------------------------*
form process_data .
loop at it_pa2001.
loop at it_tmp_pa2001 where pernr = it_pa2001-pernr.
call function 'HR_SGPBS_YRS_MTHS_DAYS'
exporting
beg_da = it_tmp_pa2001-begda
end_da = it_tmp_pa2001-endda
importing
no_cal_day = v_days
exceptions
dateint_error = 1
others = 2.
total_days = v_days + total_days.
endloop.
it_final-pernr = it_pa2001-pernr.
it_final-begda = it_pa2001-begda.
it_final-endda = it_pa2001-endda.
it_final-kaltg = it_pa2001-kaltg.
read table it_pa0002 with key pernr = it_pa2001-pernr.
if sy-subrc = 0.
it_final-vorna = it_pa0002-vorna.
it_final-nachn = it_pa0002-nachn.
endif.
it_final-tdays = total_days .
read table it_pa0000 with key pernr = it_pa2001-pernr.
if sy-subrc = 0.
case: it_pa0000-stat2.
when '0'.
it_final-stat = 'Withdrawn'.
when '1'.
it_final-stat = 'Inactive'.
when '2'.
it_final-stat = 'Retiree'.
when '3'.
it_final-stat = 'Active'.
endcase.
endif.
read table it_pa0001 with key pernr = it_pa2001-pernr.
if sy-subrc = 0.
it_final-werks = it_pa0001-werks.
it_final-persg = it_pa0001-persg.
it_final-persk = it_pa0001-persk.
it_final-btrtl = it_pa0001-btrtl.
endif.
if it_final-kaltg ge 10 or it_final-tdays ge 21.
append it_final.
endif.
clear : it_final,
total_days.
endloop.
endform. " PROCESS_DATA
*&---------------------------------------------------------------------*
*& Form get_events
*----------------------------------------------------------------------*
form get_events .
*---top of page for the first block
wa_events-name = 'TOP_OF_PAGE'.
wa_events-form = 'TOP_OF_PAGE'.
append wa_events to it_events.
clear wa_events.
endform. " get_events
*&---------------------------------------------------------------------*
*& Form top_of_page
*----------------------------------------------------------------------*
form top_of_page .
perform write_header.
*--- Get the comments on the top of page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = it_list[].
endform. " top_of_page
*&---------------------------------------------------------------------*
*& Form write_header
*----------------------------------------------------------------------*
form write_header .
refresh it_list.
clear it_list.
clear it_list.
it_list-typ = 'H'.
it_list-key = space.
it_list-info = 'Termination Report'.
append it_list to it_list.
****** REPORT PROGRAM NAME AND CLIENT ****************
it_list-typ = 'S'.
it_list-key = space.
concatenate 'Report...:' sy-repid into it_list-info separated by space.
append it_list to it_list.
****** USER NAME *************************************
clear it_list.
it_list-typ = 'S'.
it_list-key = space.
concatenate 'User.....:' sy-uname into it_list-info separated by space.
append it_list to it_list.
****** DATE / TIME STAMP *****************************
clear it_list.
it_list-typ = 'S'.
it_list-key = space.
concatenate 'Date/Time:' ' ' sy-datum+6(2) '/' sy-datum+4(2) '/' sy-datum+0(4)
' ' '/' ' ' sy-uzeit+0(2) ':' sy-uzeit+2(2) ':' sy-uzeit+4(2)
into it_list-info.
append it_list to it_list.
it_list-typ = 'S'.
it_list-key = space.
concatenate 'Run Period:' s_date-low+4(2) '.' s_date-low+6(2) '.' s_date-low+0(4) ' ' '-' ' '
s_date-high+4(2) '.' s_date-high+6(2) '.' s_date-high+0(4) into it_list-info.
append it_list to it_list.
endform. " write_header.
ALSO READ:
- Service Calculation Report In HR ABAP.
- Use Of BAPI HR_MAINTAIN_MASTERDATA For Updating HR DATA.
- Upload The Over Time Report In HR ABAP.
- Displaying Off-Cycle Report In HR ABAP.
- Loans Detail Report In HR ABAP.
.....Back To Sub-Index On HR ABAP.
.....Back To MAIN INDEX.
No comments:
Post a Comment