Download - Zhr Report
-
7/29/2019 Zhr Report
1/16
report ZHR_OVERTIME_REPORT line-size 213 message-id ZMSG.
.
type-pools: SLIS.
tables: PA0001,
T569V,
T549A,
T549Q.
types: begin of TY_PA0000,
PERNR type PA0000-PERNR,
end of TY_PA0000.
types: begin of TY_PA0001,
PERNR type PA0001-PERNR,
BUKRS type PA0001-BUKRS,
end of TY_PA0001.
types: begin of TY_PA0002,
PERNR type PA0002-PERNR,
VORNA type PA0002-VORNA,
NACHN type PA0002-NACHN,
end of TY_PA0002.
types: begin of TY_PA2010,
PERNR type PA2010-PERNR,
BEGDA type PA2010-BEGDA,
ENDDA type PA2010-ENDDA,LGART type PA2010-LGART,
ANZHL type PA2010-ANZHL,
end of TY_PA2010.
types: begin of TY_PA0008.
include structure P0008.
types: end of TY_PA0008.
data: begin of WAGETYPES,
LGA like P0008-LGA01,
BET like P0008-BET01,
end of WAGETYPES.
data: LFS_0008 like P0008.
data : V_CHAR type CHAR35,
V_CHAR1 type CHAR2 ,
GV_HRS type CHAR40,
V_CHAR2 type CHAR40.
-
7/29/2019 Zhr Report
2/16
types: begin of TY_FINAL,
PERNR type PA0001-PERNR,
BUKRS type PA0001-BUKRS,
VORNA type PA0002-VORNA,
NACHN type PA0002-NACHN,
HRS1 type P decimals 2,
AMOUNT1 type BSIS-DMBTR,
* amount1 TYPE p length 13 decimals 6,
HRS2 type P decimals 2,
AMOUNT2 type BSIS-DMBTR,
* amount2 TYPE p length 13 decimals 6, "
pa0045-darbt,
THRS type P decimals 2,
TOTAL type BSIS-DMBTR, " pa0045-
darbt,
end of TY_FINAL.
data : V_PERMO type T549A-PERMO.
data : AMOUNT1 type P length 13 decimals 6.
data : AMOUNT2 type P length 13 decimals 6.
data: TOTAL type BSIS-DMBTR, " pa0008-
bet01,
TOTAL1 type BSIS-DMBTR, " pa0008-bet01,
THR type PA0008-BET01,
TAMT type PA0008-BET01,
TOTALHR1 type P decimals 2,TOTALHR2 type P decimals 2.
data : IT_PA0000 type table of TY_PA0000 with header line,
IT_PA0001 type table of TY_PA0001 with header line,
IT_PA0002 type table of TY_PA0002 with header line,
IT_PA2010 type table of TY_PA2010 with header line,
IT_PA0008 type table of TY_PA0008 with header line,
IT_FINAL type table of TY_FINAL with header line.
data : IT_RGDIR type table of PC261 with header line,
IT_RESULT type PAY99_RESULT ,
WA_ITRGDIR type PC261,WA_RT type PC207,
W_MOLGA type T500L-MOLGA,
W_SEQNR type CDSEQ,
W_RELID type RELID_PCL2,
WAGETYPE type CHAR15.
-
7/29/2019 Zhr Report
3/16
selection-screen begin of block B1 with frame title TEXT-001.
selection-screen begin of block B3 with frame title TEXT-002.
SELECT-OPTIONS:p_abkrs FOR pa0001-abkrs NO INTERVALS.
parameters: P_PABRP type T569V-PABRP,
P_PABRJ type T569V-PABRJ,
P_BEGDA type PA0001-BEGDA,
P_ENDDA type PA0001-ENDDA.
parameters : R3 radiobutton group G2 user-
command UC1 default 'X', " Periods
R4 radiobutton group G2.
" Key Date
selection-screen begin of block B4 with frame title TEXT-006.
parameters: R1 radiobutton group R3 modif id BBB,
R2 radiobutton group R3 modif id BBB.
parameters: P_DATE like PA0001-BEGDA modif id CCC default SY-DATUM.
selection-screen end of block B4.
selection-screen end of block B3.
selection-screen begin of block B2 with frame title TEXT-003.
select-options: S_PERNR for PA0001-PERNR.* s_abkrs for pa0001-abkrs, "Payroll Area
* s_werks for pa0001-werks, "Personnel Area
* s_btrtl for pa0001-
btrtl, "Personnel Subarea
* s_persg for pa0001-persg, "Employee Group
* s_persk for pa0001-
persk. "Employee Subgroup
selection-screen end of block B2 .
selection-screen end of block B1 .
at selection-screen output.
if R1 = 'X'.
perform GET_DATA_FROM_CURRENT_PERIOD.
loop at screen.
if SCREEN-NAME = 'P_PABRP'
-
7/29/2019 Zhr Report
4/16
or SCREEN-NAME = 'P_PABRJ'
or SCREEN-NAME = 'P_BEGDA'
or SCREEN-NAME = 'P_ENDDA'.
SCREEN-INPUT = 0.
endif.
modify screen.
endloop.
elseif R2 = 'X'.
perform GET_DATA_FROM_PERIOD.
loop at screen.
if SCREEN-NAME = 'P_BEGDA'
or SCREEN-NAME = 'P_ENDDA'.
SCREEN-INPUT = 0.
endif.
modify screen.
endloop.
endif.
if R4 = 'X'.
loop at screen.
if SCREEN-GROUP1 = 'BBB'.SCREEN-ACTIVE = '0'.
modify screen.
endif.
endloop.
elseif R3 = 'X'.
loop at screen.
if SCREEN-GROUP1 = 'CCC'.
SCREEN-ACTIVE = '0'.
modify screen.endif.
endloop.
endif.
-
7/29/2019 Zhr Report
5/16
start-of-selection.
if R4 = 'X'.
if P_DATE lt P_BEGDA or P_DATE gt P_ENDDA.
* MESSAGE e000(ZMSG) with 'Enter the date within periods'.
message E003.
endif.
endif.
* if P_date eq '00000000'.
* MESSAGE e000(ZMSG) with 'Enter Key date'.
* else.
if R4 = 'X'.
P_BEGDA = P_DATE.
P_ENDDA = P_DATE.
endif.
*endif.
perform GET_DATA.
perform PROCESS_DATA.
end-of-selection.
perform DISPLAY_ALV.
top-of-page.
****** Payroll Area ******************************-------------------------------------------------
DATA it_params TYPE STANDARD TABLE OF rsparams.
DATA wa_params TYPE rsparams.
CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
EXPORTING
curr_report = sy-repid
TABLES
selection_table = it_params.
DELETE it_params WHERE selname NE 'P_ABKRS'.
CLEAR P_ABKRS.
LOOP AT it_params INTO wa_params.IF wa_params-sign = space.
P_ABKRS = 'ALL'.
EXIT.
ELSEIF wa_params-sign = 'I' AND wa_params-option = 'EQ'.
CONCATENATE P_ABKRS wa_params-
low INTO P_ABKRS SEPARATED BY space.
ELSEIF wa_params-sign = 'I' AND wa_params-option = 'BT'.
-
7/29/2019 Zhr Report
6/16
CONCATENATE P_ABKRS 'BETWEEN' wa_params-low 'AND' wa_params-
HIGH INTO P_ABKRS
SEPARATED BY SPACE.
ENDIF.
ENDLOOP.
CONDENSE P_ABKRS.
****** Payroll Area *****************************
*-------------------------------------------------
write:/05 SY-TITLE.
write:/05 'Report Name :' , SY-REPID.
write:/05 'User Name :' , SY-UNAME.
write:/05 'Run Date :' , SY-DATUM.
write:/05 'Paroll Area :' , P_ABKRS.
write:/05 'Paroll period :' , P_BEGDA mm/dd/yyyy, '-
', P_ENDDA mm/dd/yyyy.
*&---------------------------------------------------------------------
*
*& Form GET_DATA
*----------------------------------------------------------------------
*
form GET_DATA .
select PERNR
from PA0000
into table IT_PA0000
where PERNR in S_PERNRand STAT2 = '3'
and BEGDA le P_ENDDA
and ENDDA ge P_BEGDA.
if SY-SUBRC = 0.
sort IT_PA0000 by PERNR.
select PERNR
BUKRS
from PA0001
into table IT_PA0001
for all entries in IT_PA0000where PERNR = IT_PA0000-PERNR
and BEGDA le P_ENDDA
and ENDDA ge P_BEGDA
and ABKRS IN P_ABKRS
and werks = 'NOMC'.
-
7/29/2019 Zhr Report
7/16
if SY-SUBRC = 0.
sort IT_PA0000 by PERNR.
delete adjacent duplicates from IT_PA0001 comparing PERNR.
endif.
*break abaper2.
select PERNR
VORNA
NACHN
from PA0002
into table IT_PA0002
for all entries in IT_PA0000
where PERNR = IT_PA0000-PERNR
and SPRSL = 'E'
and BEGDA le P_ENDDA
and ENDDA ge P_BEGDA.
if SY-SUBRC = 0.
sort IT_PA0002 by PERNR.
endif.
select *
from PA0008
into corresponding fields of table IT_PA0008
for all entries in IT_PA0000
where PERNR = IT_PA0000-PERNR
and BEGDA le P_ENDDA
and ENDDA ge P_BEGDA.
if SY-SUBRC = 0.sort IT_PA0008 by PERNR.
endif.
select PERNR
BEGDA
ENDDA
LGART
ANZHL
from PA2010
into table IT_PA2010
for all entries in IT_PA0000
where PERNR = IT_PA0000-PERNRand BEGDA le P_ENDDA
and ENDDA ge P_BEGDA.
if SY-SUBRC = 0.
sort IT_PA2010 by PERNR.
endif.
-
7/29/2019 Zhr Report
8/16
endif.
endform. " GET_DATA
*&---------------------------------------------------------------------
*
*& Form PROCESS_DATA
*----------------------------------------------------------------------
*
form PROCESS_DATA .
data: L_AMOUNT type CHAR40.
loop at IT_PA0001.
IT_FINAL-PERNR = IT_PA0001-PERNR.
IT_FINAL-BUKRS = IT_PA0001-BUKRS.
read table IT_PA0002 with key PERNR = IT_PA0001-PERNR.
if SY-SUBRC = 0.
IT_FINAL-VORNA = IT_PA0002-VORNA.
IT_FINAL-NACHN = IT_PA0002-NACHN.
endif.
read table IT_PA0008 with key PERNR = IT_PA0001-PERNR.
if SY-SUBRC = 0.
clear : LFS_0008.
move-corresponding IT_PA0008 to LFS_0008.
do 40 times varying WAGETYPES-LGA from LFS_0008-
LGA01 next LFS_0008-LGA02
varying WAGETYPES-BET from LFS_0008-
BET01 next LFS_0008-BET02.
check WAGETYPES-LGA is not initial.
case WAGETYPES-LGA.
when '1000'.
L_AMOUNT = WAGETYPES-BET . " Basic
endcase.enddo.
endif.
********Added By Abaper 22_march_2011***********
* PERFORM get_rt_data.
*******Ended By Abaper *************************
-
7/29/2019 Zhr Report
9/16
loop at IT_PA2010 where PERNR = IT_PA0001-PERNR.
*
case: IT_PA2010-LGART.
when '5000'.
IT_FINAL-HRS1 = IT_FINAL-HRS1 + IT_PA2010-ANZHL.
when '5010'.
IT_FINAL-HRS2 = IT_FINAL-HRS2 + IT_PA2010-ANZHL.
endcase.
endloop.
* if it_final-hrs1 is not initial or it_final-hrs2 is not initial.
IT_FINAL-HRS1 = 0.
IT_FINAL-HRS2 = 0.
perform GET_RT_DATA.
* endif.
endloop.
THR = TOTALHR1 + TOTALHR2.
TAMT = TOTAL + TOTAL1.
endform. " PROCESS_DATA
*&---------------------------------------------------------------------
*
*& Form DISPLAY_ALV
*----------------------------------------------------------------------
*
form DISPLAY_ALV .
write:/1(213) SY-ULINE.
write:/1 SY-VLINE,
2 'Personnel Number',
18 SY-VLINE,
20 'Comp Code',
30 SY-VLINE,
39 'First Name' centered,
55 SY-VLINE,
63 'Last Name' centered,
80 SY-VLINE,
94 'Over time 150%' centered,
125 SY-VLINE,
140 'Over time 200%' centered,170 SY-VLINE,
191 'Total' centered,
* 180 sy-vline,
* 184 'Total',
213 SY-VLINE.
write:/1 SY-VLINE,
-
7/29/2019 Zhr Report
10/16
2 ' ',
18 SY-VLINE,
19 ' ',
30 SY-VLINE,
31 ' ' centered,
55 SY-VLINE,
56 ' ' centered,
80 SY-VLINE,
81(135) SY-ULINE,
170 SY-VLINE,
* 161 'Total Hours',
* 180 sy-vline,
* 176 'Total Amount',
213 SY-VLINE.
write:/1 SY-VLINE,
2 '',
18 SY-VLINE,
19 '',
30 SY-VLINE,
31 '' centered,
55 SY-VLINE,
56 '' centered,
80 SY-VLINE,
88 'Hours' centered,
100 SY-VLINE,
110 'Amount' centered,
125 SY-VLINE,
133 'Hours' centered,145 SY-VLINE,
155 'Amount' centered,
170 SY-VLINE,
180 'Hours' centered,
193 SY-VLINE,
201 'Amount' centered,
213 SY-VLINE.
write:/1(213) SY-ULINE.
if not IT_FINAL[] is initial.
loop at IT_FINAL.
write:/1 SY-VLINE,
4 IT_FINAL-PERNR,
18 SY-VLINE,
22 IT_FINAL-BUKRS,
30 SY-VLINE,
31 IT_FINAL-VORNA ,
-
7/29/2019 Zhr Report
11/16
55 SY-VLINE,
56 IT_FINAL-NACHN ,
80 SY-VLINE,
84 IT_FINAL-HRS1 ,
100 SY-VLINE,
110 IT_FINAL-AMOUNT1 ,
125 SY-VLINE,
129 IT_FINAL-HRS2 ,
145 SY-VLINE,
155 IT_FINAL-AMOUNT2 ,
170 SY-VLINE,
177 IT_FINAL-THRS ,
193 SY-VLINE,
199 IT_FINAL-TOTAL ,
213 SY-VLINE.
endloop.
write:/1(213) SY-ULINE.
write:/1 SY-VLINE,
20 'Totals : ',
80 SY-VLINE,
84 TOTALHR1 ,
100 SY-VLINE,
110 TOTAL ,
125 SY-VLINE,
129 TOTALHR2 ,
145 SY-VLINE,
155 TOTAL1 ,
170 SY-VLINE,176 THR ,
193 SY-VLINE ,
199 TAMT,
* 180 sy-vline,
213 SY-VLINE.
write:/1(213) SY-ULINE.
endif.
endform. " DISPLAY_ALV
*&---------------------------------------------------------------------*
*& Form GET_DATA_FROM_CURRENT_PERIOD
*----------------------------------------------------------------------
*
form GET_DATA_FROM_CURRENT_PERIOD .
select single * from T569V
-
7/29/2019 Zhr Report
12/16
where ABKRS = P_ABKRS-LOW
and VWSAZ = '01'.
if SY-SUBRC = 0.
P_PABRP = T569V-PABRP.
P_PABRJ = T569V-PABRJ.
endif.
select single * from T549A where ABKRS = P_ABKRS-LOW.
if SY-SUBRC = 0.
V_PERMO = T549A-PERMO.
else.
if R2 = 'X'.
message E000 with 'Enter a valid Payroll Period'.
endif.
endif.
select single * from T549Q where PERMO = V_PERMO
and PABRJ = T569V-PABRJ
and PABRP = T569V-PABRP.
if SY-SUBRC = 0.
P_BEGDA = T549Q-BEGDA.
P_ENDDA = T549Q-ENDDA.
endif.
endform. " GET_DATA_FROM_CURRENT_PERIOD
*&---------------------------------------------------------------------
*
*& Form GET_DATA_FROM_PERIOD
*----------------------------------------------------------------------*
form GET_DATA_FROM_PERIOD .
select single * from T549A where ABKRS = P_ABKRS-LOW.
V_PERMO = T549A-PERMO.
select single * from T549Q where PERMO = V_PERMO
and PABRJ = P_PABRJ
and PABRP = P_PABRP.
if SY-SUBRC = 0.P_BEGDA = T549Q-BEGDA.
P_ENDDA = T549Q-ENDDA.
endif.
endform. " GET_DATA_FROM_PERIOD
-
7/29/2019 Zhr Report
13/16
**********************************************Added By ABAPER**********
********************************************************
*&---------------------------------------------------------------------
*
*& Form GET_RT_DATA
*----------------------------------------------------------------------
*
form GET_RT_DATA .
data: L_PERNR like PA0001-PERNR.
call function 'CU_READ_RGDIR'
exporting
PERSNR = it_final-pernr
importing
MOLGA = W_MOLGA
tables
IN_RGDIR = IT_RGDIR
exceptions
NO_RECORD_FOUND = 1
others = 2.
clear W_SEQNR.
if not W_MOLGA is initial.
call function 'CD_READ_LAST'
exporting
BEGIN_DATE = P_BEGDAEND_DATE = P_ENDDA
importing
OUT_SEQNR = W_SEQNR
tables
RGDIR = IT_RGDIR
exceptions
NO_RECORD_FOUND = 1
others = 2.
endif.
sort IT_RGDIR by FPEND descending.
loop at IT_RGDIR into WA_ITRGDIR where fpper = p_begda+0(6) and INPER
= P_BEGDA+0(6).
w_seqnr = wa_itrgdir-seqnr.
select single
RELID
from T500L
-
7/29/2019 Zhr Report
14/16
into W_RELID
where MOLGA = W_MOLGA.
L_PERNR = IT_FINAL-PERNR .
call function 'PYXX_READ_PAYROLL_RESULT'
exporting
CLUSTERID = W_RELID
EMPLOYEENUMBER = L_PERNR
SEQUENCENUMBER = W_SEQNR
READ_ONLY_INTERNATIONAL = 'X'
changing
PAYROLL_RESULT = IT_RESULT
exceptions
ILLEGAL_ISOCODE_OR_CLUSTERID = 1
ERROR_GENERATING_IMPORT = 2
IMPORT_MISMATCH_ERROR = 3
SUBPOOL_DIR_FULL = 4
NO_READ_AUTHORITY = 5
NO_RECORD_FOUND = 6
VERSIONS_DO_NOT_MATCH = 7
ERROR_READING_ARCHIVE = 8
ERROR_READING_RELID = 9
others = 10.
loop at IT_RESULT-INTER-RT into WA_RT .
WAGETYPE = WA_RT-LGART.
case WAGETYPE.
when '5000'.
IT_FINAL-HRS1 = IT_FINAL-HRS1 + WA_RT-ANZHL.
IT_FINAL-AMOUNT1 = IT_FINAL-AMOUNT1 + WA_RT-BETRG.
when '5010'.
IT_FINAL-HRS2 = IT_FINAL-HRS2 + WA_RT-ANZHL.
IT_FINAL-AMOUNT2 = IT_FINAL-AMOUNT2 + WA_RT-BETRG.
endcase.
endloop.
endloop.
if IT_FINAL-HRS1 is not initial or IT_FINAL-HRS2 is not initial.
IT_FINAL-THRS = IT_FINAL-HRS1 + IT_FINAL-HRS2.
IT_FINAL-TOTAL = IT_FINAL-AMOUNT1 + IT_FINAL-AMOUNT2.
-
7/29/2019 Zhr Report
15/16
TOTAL = TOTAL + IT_FINAL-AMOUNT1.
TOTAL1 = TOTAL1 + IT_FINAL-AMOUNT2.
TOTALHR1 = TOTALHR1 + IT_FINAL-
HRS1. " Added for summing up the total Hours ( Kalyan on 05.08.2010
)
TOTALHR2 = TOTALHR2 + IT_FINAL-
HRS2. " Added for summing up the total Hours ( Kalyan on 05.08.2010
)
append IT_FINAL .
endif.
***************** ENDIF.
****For OffCycle ES 08082012.
CLEAR: W_SEQNR, IT_FINAL-HRS1, IT_FINAL-AMOUNT1, IT_FINAL-
HRS2, IT_FINAL-AMOUNT2, IT_FINAL-THRS, IT_FINAL-TOTAL.
loop at IT_RGDIR into WA_ITRGDIR where ( OCRSN = '3020' ) and PAYDT = P
_BEGDA.
w_seqnr = wa_itrgdir-seqnr.
select single
RELID
from T500L
into W_RELID
where MOLGA = W_MOLGA.
L_PERNR = IT_FINAL-PERNR .
call function 'PYXX_READ_PAYROLL_RESULT'
exporting
CLUSTERID = W_RELID
EMPLOYEENUMBER = L_PERNR
SEQUENCENUMBER = W_SEQNR
READ_ONLY_INTERNATIONAL = 'X'
changing
PAYROLL_RESULT = IT_RESULT
exceptions
ILLEGAL_ISOCODE_OR_CLUSTERID = 1
ERROR_GENERATING_IMPORT = 2
IMPORT_MISMATCH_ERROR = 3SUBPOOL_DIR_FULL = 4
NO_READ_AUTHORITY = 5
NO_RECORD_FOUND = 6
VERSIONS_DO_NOT_MATCH = 7
ERROR_READING_ARCHIVE = 8
ERROR_READING_RELID = 9
others = 10.
-
7/29/2019 Zhr Report
16/16
loop at IT_RESULT-INTER-RT into WA_RT .
WAGETYPE = WA_RT-LGART.
case WAGETYPE.
when '3095'.
IT_FINAL-HRS1 = IT_FINAL-HRS1 + WA_RT-ANZHL.
IT_FINAL-AMOUNT1 = IT_FINAL-AMOUNT1 + WA_RT-BETRG.
when '3100'.
IT_FINAL-HRS2 = IT_FINAL-HRS2 + WA_RT-ANZHL.
IT_FINAL-AMOUNT2 = IT_FINAL-AMOUNT2 + WA_RT-BETRG.
endcase.
endloop.
endloop.
if IT_FINAL-HRS1 is not initial or IT_FINAL-HRS2 is not initial.
IT_FINAL-THRS = IT_FINAL-HRS1 + IT_FINAL-HRS2.
IT_FINAL-TOTAL = IT_FINAL-AMOUNT1 + IT_FINAL-AMOUNT2.
TOTAL = TOTAL + IT_FINAL-AMOUNT1.
TOTAL1 = TOTAL1 + IT_FINAL-AMOUNT2.
TOTALHR1 = TOTALHR1 + IT_FINAL-
HRS1. " Added for summing up the total Hours ( Kalyan on 05.08.2010
)TOTALHR2 = TOTALHR2 + IT_FINAL-
HRS2. " Added for summing up the total Hours ( Kalyan on 05.08.2010
)
append IT_FINAL .
endif.
****For OffCycle ES 08082012.
clear IT_FINAL .
endform. " GET_RT_DATA