Google Search - Blog...........

Displaying Off-Cycle Report In HR ABAP

REPORT ZHR_OFFCYCLE_REPORT MESSAGE-ID zmsg.

*----------------------------------------------------------------*
* TABLES *
*----------------------------------------------------------------*
TABLES:pa0001,
t569v,
t549a,
t549q.
*-----------------------------------------------------------------*
* T Y P E P O O L S *
*-----------------------------------------------------------------*
TYPE-POOLS : slis.

************************************************************************
* DECLARATION OF INTERNAL TABLES *
************************************************************************
DATA : v_permo TYPE t549a-permo.


TYPES: BEGIN OF ty_pa0000,
pernr TYPE pa0001-pernr,
begda TYPE pa0001-begda,
endda TYPE pa0001-endda,
massn TYPE pa0000-massn,
massg TYPE pa0000-massg,
stat2 TYPE pa0000-stat2,
END OF ty_pa0000.

TYPES: BEGIN OF ty_pa0002,
pernr TYPE pa0001-pernr,
vorna TYPE pa0002-vorna,
nachn TYPE pa0002-nachn,
natio type pa0002-natio,
END OF ty_pa0002.

TYPES: BEGIN OF ty_pa0001,
pernr TYPE pa0001-pernr,
begda type pa0001-begda,
endda type pa0001-endda,
bukrs TYPE pa0001-bukrs,
werks TYPE pa0001-werks,
persg TYPE pa0001-persg,
persk TYPE pa0001-persk,
btrtl TYPE pa0001-btrtl,
abkrs TYPE pa0001-abkrs,
kostl TYPE pa0001-kostl,
orgeh TYPE pa0001-orgeh,
plans TYPE pa0001-plans,
stell TYPE pa0001-stell,
END OF ty_pa0001.

TYPES: BEGIN OF ty_pa0008.
INCLUDE STRUCTURE p0008.
TYPES: END OF ty_pa0008.

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_pa2001.
INCLUDE STRUCTURE p2001.
TYPES: END OF ty_pa2001.

TYPES: BEGIN OF ty_pa2006.
INCLUDE STRUCTURE p2006.
TYPES: END OF ty_pa2006.

TYPES: BEGIN OF ty_pa0045.
INCLUDE STRUCTURE p0045.
TYPES: END OF ty_pa0045.

DATA: BEGIN OF wagetypes,
lga LIKE p0008-lga01,
bet LIKE p0008-bet01,
END OF wagetypes.

TYPES: BEGIN OF ty_pa0041.
INCLUDE STRUCTURE p0041.
TYPES: END OF ty_pa0041.

TYPES: BEGIN OF ty_pa0014.
INCLUDE STRUCTURE p0014.
TYPES: END OF ty_pa0014.

DATA: lfs_0008 LIKE p0008.

DATA: BEGIN OF dates,
dar LIKE p0041-dar01,
dat LIKE p0041-dat01,
END OF dates.


types: begin of ty_pa0009,
pernr type pa0009-pernr,
iban type pa0009-iban,
end of ty_pa0009.

types: begin of ty_t528t,
plans type t528t-plans,
plstx type t528t-plstx,
end of ty_t528t.

types: begin of ty_t513s,
stell type t513s-stell,
stltx type t513s-stltx,
end of ty_t513s.

types: begin of ty_cskt,
kostl type cskt-kostl,
ktext type cskt-ktext,
end of ty_cskt.

data: v_tabix type i.


*Internal table for storing field names for displaing in list
TYPES : BEGIN OF ty_final,
sno type i,
pernr TYPE p0001-pernr, "Personnel Number
ename TYPE p0001-ename, "Emp Name
kostl type pa0001-kostl,
ktext type cskt-ktext,
plstx type t528t-plstx,
stltx type t513s-stltx,
jdate type pa0001-begda,
iban type pa0009-iban,
natio type char20,
days type i,
aldays type i,
nmaldays type i,
basic TYPE pa0008-bet01,
transport TYPE pa0008-bet01,
hra TYPE pa0008-bet01,
tele TYPE pa0008-bet01,
arr TYPE pa0008-bet01,
splclm TYPE pa0008-bet01,
claim TYPE pa0008-bet01,
shift TYPE pa0008-bet01,
security TYPE pa0008-bet01,
other TYPE pa0008-bet01,
hours150 type pa0008-bet01,
over150 TYPE pa0008-bet01,
hours200 type pa0008-bet01,
over200 TYPE pa0008-bet01,
alc TYPE pa0008-bet01,
nmalc TYPE pa0008-bet01,
total TYPE pa0008-bet01,
dfpp TYPE pa0008-bet01,
dfpp1 TYPE pa0008-bet01,
ghded TYPE pa0008-bet01,
gosi_2 TYPE pa0008-bet01,
gosi_9 TYPE pa0008-bet01,
gosi_11 TYPE pa0008-bet01,
bankchrg TYPE pa0008-bet01,
otherded TYPE pa0008-bet01,
homeloan TYPE pa0008-bet01,
persloan TYPE pa0008-bet01,
netpay TYPE pa0008-bet01,
saladv TYPE pa0008-bet01,
total1 TYPE pa0008-bet01,
advrec TYPE pa0008-bet01,
whrs TYPE p DECIMALS 2,
alhrs TYPE p DECIMALS 2,
sick TYPE p DECIMALS 2,
auth TYPE p DECIMALS 2,
uauth TYPE p DECIMALS 2,
upleave TYPE p DECIMALS 2,
oleave TYPE p DECIMALS 2,
totalhrs TYPE p DECIMALS 2,
cell_colour TYPE lvc_t_scol, "Cell colour
END OF ty_final.

data: v_days type i,
v_days1 type i,
v_abs type i.

* To colour a cell.
DATA ls_cellcolour TYPE lvc_s_scol.

DATA: it_final TYPE TABLE OF ty_final WITH HEADER LINE.

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_pa0008 TYPE TABLE OF ty_pa0008 WITH HEADER LINE,
it_pa0009 type table of ty_pa0009 with header line,
it_t513s type table of ty_t513s with header line,
it_t528t type table of ty_t528t with header line,
it_cskt type table of ty_cskt with header line,
it_pa0041 TYPE TABLE OF ty_pa0041 WITH HEADER LINE,
it_pa0014 TYPE TABLE OF ty_pa0014 WITH HEADER LINE,
it_pa0045 TYPE TABLE OF ty_pa0045 WITH HEADER LINE,
it_pa2001 TYPE TABLE OF ty_pa2001 WITH HEADER LINE,
it_pa2001_01 TYPE TABLE OF ty_pa2001 WITH HEADER LINE,
it_pa2006 TYPE TABLE OF ty_pa2006 WITH HEADER LINE,
it_pa2010 TYPE TABLE OF ty_pa2010 WITH HEADER LINE,
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,
v_total TYPE pa0008-bet01,
v_pernr TYPE pa0001-pernr,
v_werks TYPE pa0001-werks,
v_btrtl TYPE pa0001-btrtl,
v_persg TYPE pa0001-persg,
v_persk TYPE pa0001-persk,
v_abkrs TYPE pa0001-abkrs.


*For ALV fieldcatlog
DATA : it_fieldcat TYPE slis_t_fieldcat_alv,
*For ALV fieldcatlog
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.
*************************************************************************
** SELECTION-SCREEN *
*************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-002.

*PARAMETERS:p_abkrs TYPE pa0001-abkrs .
select-options: s_abkrs for pa0001-abkrs no intervals obligatory.

PARAMETERS: p_pabrp TYPE t569v-pabrp,
p_pabrj TYPE t569v-pabrj,
p_begda TYPE pa0001-begda,
p_endda TYPE pa0001-endda.

PARAMETERS: r1 RADIOBUTTON GROUP g1 DEFAULT 'X' USER-COMMAND aaa,
r2 RADIOBUTTON GROUP g1.
SELECTION-SCREEN END OF BLOCK b3 .
SELECTION-SCREEN BEGIN OF BLOCK b4 WITH FRAME .
SELECT-OPTIONS: s_pernr FOR pa0001-pernr,
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 b4 .
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'
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.

************************************************************************
* START OF SELECTION *
************************************************************************
START-OF-SELECTION.

PERFORM get_pa0000_data.

IF NOT it_pa0000[] IS INITIAL.

PERFORM get_pa0001_data.

PERFORM get_pa0002_data.

PERFORM get_pa0008_data.

perform get_other_data.

perform get_pa2001_data.

ENDIF.

END-OF-SELECTION.


PERFORM process_data.

END-OF-SELECTION.

*To build ALV fieldcatlog
PERFORM build_fieldcatlog.

*For ALV Layout
PERFORM alv_layout.

PERFORM get_events.

PERFORM top_of_page.

*To diaplay output in ALV grid format
PERFORM display_alv.

*&---------------------------------------------------------------------*
*& Form GET_DATA_FROM_CURRENT_PERIOD
*----------------------------------------------------------------------*
FORM get_data_from_current_period .

SELECT SINGLE * FROM t569v
WHERE abkrs = s_abkrs-low
AND vwsaz = '01'.
IF sy-subrc = 0.
p_pabrp = t569v-pabrp.
p_pabrj = t569v-pabrj.
ENDIF.

SELECT SINGLE * FROM t549a WHERE abkrs = s_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 = s_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
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCATLOG
*&---------------------------------------------------------------------*
FORM build_fieldcatlog .

wa_fieldcat-fieldname = 'SNO'.
wa_fieldcat-reptext_ddic = 'Serial No'.
wa_fieldcat-just = 'C'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'PERNR'.
wa_fieldcat-reptext_ddic = 'Employee Number'.
wa_fieldcat-just = 'L'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'ENAME'.
wa_fieldcat-reptext_ddic = 'Employee Name'.
wa_fieldcat-just = 'L'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'STLTX'.
wa_fieldcat-reptext_ddic = 'Designation'.
wa_fieldcat-just = 'L'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.

wa_fieldcat-fieldname = 'KTEXT'.
wa_fieldcat-reptext_ddic = 'Cost Center'.
wa_fieldcat-just = 'L'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.

wa_fieldcat-fieldname = 'PLSTX'.
wa_fieldcat-reptext_ddic = 'Position'.
wa_fieldcat-just = 'L'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.

wa_fieldcat-fieldname = 'JDATE'.
wa_fieldcat-reptext_ddic = 'Date Of Joining'.
wa_fieldcat-just = 'L'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.

wa_fieldcat-fieldname = 'NATIO'.
wa_fieldcat-reptext_ddic = 'Nationality'.
wa_fieldcat-just = 'L'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.

wa_fieldcat-fieldname = 'IBAN'.
wa_fieldcat-reptext_ddic = 'IBAN Number'.
wa_fieldcat-just = 'L'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.

wa_fieldcat-fieldname = 'DAYS'.
wa_fieldcat-reptext_ddic = 'Days Worked'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'ALDAYS'.
wa_fieldcat-reptext_ddic = 'Vacation Leave Days'.
wa_fieldcat-just = 'C'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.

wa_fieldcat-fieldname = 'NMALDAYS'.
wa_fieldcat-reptext_ddic = 'Next Month Vacation Leave Days'.
wa_fieldcat-just = 'C'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.

wa_fieldcat-fieldname = 'BASIC'.
wa_fieldcat-reptext_ddic = 'Basic Salary'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'HRA'.
wa_fieldcat-reptext_ddic = 'House Rent Allowance'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'TRANSPORT'.
wa_fieldcat-reptext_ddic = 'Trans Allowance'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'TELE'.
wa_fieldcat-reptext_ddic = 'Teleph Allowance'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'ARR'.
wa_fieldcat-reptext_ddic = 'Arrears Payment'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'OTHER'.
wa_fieldcat-reptext_ddic = 'Other Allowance'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'HOURS150'.
wa_fieldcat-reptext_ddic = 'Hours 150%'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'OVER150'.
wa_fieldcat-reptext_ddic = 'Overtime 150%'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'HOURS200'.
wa_fieldcat-reptext_ddic = 'Hours 200%'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'OVER200'.
wa_fieldcat-reptext_ddic = 'Overtime 200%'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'ALC'.
wa_fieldcat-reptext_ddic = 'Annual Leave Compensation'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'NMALC'.
wa_fieldcat-reptext_ddic = 'Next Month AL Compensation'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'DFPP'.
wa_fieldcat-reptext_ddic = 'Difference from Previous Period'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.


wa_fieldcat-fieldname = 'TOTAL'.
wa_fieldcat-reptext_ddic = 'Gross Payment'.
wa_fieldcat-do_sum = 'X'.
wa_fieldcat-emphasize = 'C110'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'GOSI_9'.
wa_fieldcat-reptext_ddic = 'GOSI 9% deductions'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'GHDED'.
wa_fieldcat-reptext_ddic = 'Guest House Deduction'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'OTHERDED'.
wa_fieldcat-reptext_ddic = 'Other Deductions'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'BANKCHRG'.
wa_fieldcat-reptext_ddic = 'Bank Charges'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'CLAIM'.
wa_fieldcat-reptext_ddic = 'Claim'.
wa_fieldcat-do_sum = 'X'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.

wa_fieldcat-fieldname = 'HOMELOAN'.
wa_fieldcat-reptext_ddic = 'Home Loan Repay'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'PERSLOAN'.
wa_fieldcat-reptext_ddic = 'Pers Loan Repay'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'SALADV'.
wa_fieldcat-reptext_ddic = 'Advance Recovery'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'DFPP1'.
wa_fieldcat-reptext_ddic = 'Difference from Previous Period'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'TOTAL1'.
wa_fieldcat-reptext_ddic = 'Total Deductions'.
wa_fieldcat-do_sum = 'X'.
wa_fieldcat-emphasize = 'C710'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.


wa_fieldcat-fieldname = 'NETPAY'.
wa_fieldcat-reptext_ddic = 'Net Payment'.
wa_fieldcat-do_sum = 'X'.
wa_fieldcat-emphasize = 'C510'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'WHRS'.
wa_fieldcat-reptext_ddic = 'Working Hours'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'ALHRS'.
wa_fieldcat-reptext_ddic = 'Annuual Leave Hours'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'SICK'.
wa_fieldcat-reptext_ddic = 'Sick Leave Hours'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'AUTH'.
wa_fieldcat-reptext_ddic = 'Autthorised Leave Hours'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'UAUTH'.
wa_fieldcat-reptext_ddic = 'Unauthorised Leave Hours'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'UPLEAVE'.
wa_fieldcat-reptext_ddic = 'Unpain Leave Hours'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'OLEAVE'.
wa_fieldcat-reptext_ddic = 'Other Leave Hours'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'TOTALHRS'.
wa_fieldcat-reptext_ddic = 'Total Hours'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

ENDFORM. " BUILD_FIELDCATLOG
*&---------------------------------------------------------------------*
*& Form ALV_LAYOUT
*----------------------------------------------------------------------*
FORM alv_layout .

it_layout-colwidth_optimize = 'X'.
it_layout-totals_text = 'Totals'.
it_layout-subtotals_text = 'Totals'.
it_layout-zebra = 'X'.


ENDFORM. " ALV_LAYOUT
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV
*----------------------------------------------------------------------*
FORM display_alv .

DATA: is_print TYPE slis_print_alv.

is_print-no_print_listinfos = '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
is_print = is_print
TABLES
t_outtab = it_final
EXCEPTIONS
program_error = 1
OTHERS = 2.


ENDFORM. " DISPLAY_ALV
*&---------------------------------------------------------------------*
*& 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 = 'Employee Off cycle Payroll 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 sy-uzeit INTO it_list-info SEPARATED BY space.
APPEND it_list TO it_list.

clear it_list.
it_list-typ = 'S'.
it_list-key = space.
concatenate 'Payroll Area:' s_abkrs-low into it_list-info separated by space.
append it_list to it_list.

it_list-typ = 'S'.
it_list-key = space.
concatenate 'Payroll Period:' p_begda+4(2) '.' p_begda+6(2) '.' p_begda+0(4) ' ' '-' ' '
p_endda+4(2) '.' p_endda+6(2) '.' p_endda+0(4) into it_list-info.
append it_list to it_list.

ENDFORM. " WRITE_HEADER
*&---------------------------------------------------------------------*
*& Form GET_PA0000_DATA
*----------------------------------------------------------------------*
FORM get_pa0000_data .

SELECT pernr
begda
endda
massn
massg
stat2
FROM pa0000
INTO TABLE it_pa0000
WHERE pernr IN s_pernr
AND stat2 = '3'
AND begda LE p_endda
AND endda GE p_begda.


IF sy-subrc = 0.
DELETE ADJACENT DUPLICATES FROM it_pa0000 COMPARING pernr.
ENDIF.

ENDFORM. " GET_PA0000_DATA
*&---------------------------------------------------------------------*
*& Form GET_PA0001_DATA
*----------------------------------------------------------------------*
FORM get_pa0001_data .


SELECT pernr
begda
endda
bukrs
werks
persg
persk
btrtl
abkrs
kostl
orgeh
plans
stell
FROM pa0001
INTO TABLE it_pa0001
FOR ALL ENTRIES IN it_pa0000
WHERE pernr = it_pa0000-pernr
AND abkrs in s_abkrs
AND begda LE p_endda
AND endda GE p_begda
AND werks IN s_werks
AND btrtl IN s_btrtl
AND persg IN s_persg
AND persk IN s_persk.

IF sy-subrc = 0.

SELECT *
FROM pa0041
INTO CORRESPONDING FIELDS OF TABLE it_pa0041
FOR ALL ENTRIES IN it_pa0001
WHERE pernr = it_pa0001-pernr
AND begda LE p_endda
AND endda GE p_begda.


ENDIF.

ENDFORM. " GET_PA0001_DATA
*&---------------------------------------------------------------------*
*& Form GET_PA0002_DATA
*----------------------------------------------------------------------*
FORM get_pa0002_data .

SELECT pernr
vorna
nachn
natio
FROM pa0002
INTO TABLE it_pa0002
FOR ALL ENTRIES IN it_pa0000
WHERE pernr = it_pa0000-pernr
AND begda LE p_endda
AND endda GE p_begda.

ENDFORM. " GET_PA0002_DATA
*&---------------------------------------------------------------------*
*& Form GET_PA0008_DATA
*----------------------------------------------------------------------*
FORM get_pa0008_data .

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.


ENDFORM. " GET_PA0008_DATA
*&---------------------------------------------------------------------*
*& Form PROCESS_DATA
*----------------------------------------------------------------------*
FORM process_data .

LOOP AT it_pa0001.
clear: it_final.
it_final-pernr = it_pa0001-pernr.

read table it_pa0002 with key pernr = it_pa0001-pernr.
if sy-subrc = 0.
concatenate it_pa0002-nachn it_pa0002-vorna into it_final-ename.
if it_pa0002-natio = 'SA'.
it_final-natio = 'Saudi'.
else.
it_final-natio = 'Expatriate'.
endif.
endif.

read table it_pa0009 with key pernr = it_pa0001-pernr.
if sy-subrc = 0.
it_final-iban = it_pa0009-iban.
endif.

read table it_cskt with key kostl = it_pa0001-kostl.
if sy-subrc = 0.
it_final-ktext = it_cskt-kostl.
it_final-stltx = it_cskt-ktext.
endif.

read table it_t528t with key plans = it_pa0001-plans.
if sy-subrc = 0.
it_final-plstx = it_t528t-plstx.
endif.

read table it_pa0041 with key pernr = it_pa0001-pernr.
if sy-subrc = 0.

do 12 times varying dates-dar from it_pa0041-dar01 next it_pa0041-dar02
varying dates-dat from it_pa0041-dat01 next it_pa0041-dat02.

check dates-dar is not initial.

if dates-dar = '01'.
it_final-jdate = dates-dat.
endif.
enddo.
endif.
break abaper2.
IF it_pa0001-begda GT p_begda.
CLEAR: v_days.

CALL FUNCTION 'HR_99S_INTERVAL_BETWEEN_DATES'
EXPORTING
begda = it_pa0001-begda
endda = p_endda
IMPORTING
days = v_days1.

ELSE.
CLEAR: v_days.

CALL FUNCTION 'HR_99S_INTERVAL_BETWEEN_DATES'
EXPORTING
begda = p_begda
endda = p_endda
IMPORTING
days = v_days1.
ENDIF.


LOOP AT it_pa2001 WHERE pernr = it_final-pernr.

IF it_pa2001-begda LE p_begda.
it_pa2001-begda = p_begda.
ENDIF.

IF it_pa2001-endda GT p_endda.
it_pa2001-endda = p_endda.
ENDIF.

CALL FUNCTION 'HR_99S_INTERVAL_BETWEEN_DATES'
EXPORTING
begda = it_pa2001-begda
endda = it_pa2001-endda
IMPORTING
days = v_days.

CASE : it_pa2001-subty.
WHEN '5000'.

WHEN '5060'.
it_final-sick = it_final-sick + v_days * 8.
WHEN '5080'.
it_final-auth = it_final-auth + v_days * 8.
WHEN '5110'.
it_final-uauth = it_final-uauth + v_days * 8.
WHEN '5100'.
it_final-upleave = it_final-upleave + v_days * 8.
WHEN OTHERS.
it_final-oleave = it_final-oleave + v_days * 8.
ENDCASE.
v_abs = v_abs + v_days.
clear : it_pa2001.
ENDLOOP.

PERFORM get_rt_data.
CLEAR : v_days1, v_days, v_abs.

ENDLOOP.


ENDFORM. " PROCESS_DATA
*&---------------------------------------------------------------------*
*& 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.

IF r1 = 'X'.

IF NOT w_molga IS INITIAL.
CALL FUNCTION 'CD_READ_LAST'
EXPORTING
begin_date = p_begda
end_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.

READ TABLE it_rgdir INTO wa_itrgdir WITH KEY fpbeg = p_begda
fpend = p_endda.
check sy-subrc = 0 AND wa_itrgdir-ocrsn IS not INITIAL.
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 = 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.

ELSEIF r2 = 'X'.

IF NOT w_molga IS INITIAL.
CALL FUNCTION 'CD_READ_LAST'
EXPORTING
begin_date = p_begda
end_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.

* For Offcycle Payyroll
READ TABLE it_rgdir INTO wa_itrgdir WITH KEY fpbeg = p_begda
fpend = p_endda.
IF sy-subrc = 0 AND wa_itrgdir-ocrsn IS not INITIAL.
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 = 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.
else.
clear :w_seqnr .
ENDIF.
ENDIF.


if not w_seqnr is initial.
LOOP AT it_result-inter-rt INTO wa_rt.
wagetype = wa_rt-lgart.
CASE wagetype.
WHEN '1000'.
it_final-basic = wa_rt-betrg .
WHEN '1010'.
it_final-hra = wa_rt-betrg .
WHEN '1020'.
it_final-transport = wa_rt-betrg .
WHEN '1030'.
it_final-tele = wa_rt-betrg .
WHEN '4000'.
it_final-arr = wa_rt-betrg .
WHEN '1040'.
it_final-shift = wa_rt-betrg .
WHEN '1050'.
it_final-security = wa_rt-betrg .
WHEN '2040'.
it_final-other = wa_rt-betrg .
WHEN '5000'.
it_final-over150 = wa_rt-betrg .
it_final-HOURS150 = wa_rt-anzhl .
WHEN '5010'.
it_final-over200 = wa_rt-betrg .
it_final-HOURS200 = wa_rt-anzhl .
WHEN '/101'.
it_final-total = wa_rt-betrg .
WHEN '/110'.
it_final-total1 = wa_rt-betrg .
WHEN '2000'.
it_final-gosi_9 = wa_rt-betrg .
WHEN '2010'.
it_final-gosi_11 = wa_rt-betrg .
WHEN '2020'.
it_final-gosi_2 = wa_rt-betrg .
WHEN '2090'.
it_final-ghded = wa_rt-betrg .
WHEN '2080'.
it_final-otherded = wa_rt-betrg .
WHEN '2130'.
it_final-bankchrg = wa_rt-betrg .
WHEN '3LEP'.
it_final-splclm = wa_rt-betrg .
WHEN '9100'.
it_final-homeloan = it_final-homeloan + wa_rt-betrg .
WHEN '9300'.
it_final-persloan = it_final-persloan + wa_rt-betrg .
WHEN '9200'.
it_final-saladv = it_final-saladv + wa_rt-betrg .
WHEN '5050'.
it_final-alc = wa_rt-betrg .
it_final-aldays = wa_rt-anzhl.
it_final-alhrs = it_final-aldays * 8.
WHEN '5051'.
it_final-nmalc = wa_rt-betrg .
it_final-nmaldays = wa_rt-anzhl.
WHEN '9150'.
it_final-dfpp = wa_rt-betrg .
WHEN '9160'.
it_final-dfpp1 = wa_rt-betrg .
WHEN '/563'.
it_final-claim = it_final-claim + wa_rt-betrg .

ENDCASE.



ENDLOOP.

it_final-total = it_final-total + it_final-arr + it_final-other + it_final-dfpp .


IF it_final-saladv LT 0.
it_final-saladv = it_final-saladv * ( - 1 ) .
ENDIF.

IF it_final-dfpp1 LT 0.
it_final-dfpp1 = it_final-dfpp1 * ( - 1 ) .
ENDIF.

IF it_final-otherded LT 0.
it_final-otherded = it_final-otherded * ( - 1 ) .
ENDIF.

IF it_final-gosi_9 LT 0.
it_final-gosi_9 = it_final-gosi_9 * ( - 1 ) .
ENDIF.

IF it_final-homeloan LT 0.
it_final-homeloan = it_final-homeloan * ( - 1 ) .
ENDIF.

IF it_final-persloan LT 0.
it_final-persloan = it_final-persloan * ( - 1 ) .
ENDIF.

IF it_final-dfpp1 LT 0.
it_final-dfpp1 = it_final-dfpp1 * ( - 1 ) .
ENDIF.

IF it_final-ghded LT 0.
it_final-ghded = it_final-ghded * ( - 1 ) .
ENDIF.

IF it_final-bankchrg LT 0.
it_final-bankchrg = it_final-bankchrg * ( - 1 ) .
ENDIF.

it_final-total1 = it_final-gosi_9 + it_final-otherded + it_final-homeloan + it_final-persloan +
it_final-saladv + it_final-ghded + it_final-claim + it_final-bankchrg + it_final-dfpp1.

it_final-days = v_days1 - v_abs.

it_final-whrs = it_final-days * 8.

it_final-totalhrs = it_final-whrs + it_final-alhrs + it_final-sick
+ it_final-auth + it_final-uauth + it_final-upleave
+ it_final-oleave .

it_final-netpay = it_final-total - it_final-total1.

v_tabix = v_tabix + 1.

it_final-sno = v_tabix.

APPEND it_final .
CLEAR it_final .

clear : it_final, w_seqnr,wa_itrgdir, it_result-inter-rt[].
else.
clear : it_final, w_seqnr,wa_itrgdir, it_result-inter-rt[].
endif.

ENDFORM. " GET_RT_DATA
*&---------------------------------------------------------------------*
*& Form GET_OTHER_DATA
*----------------------------------------------------------------------*
form GET_OTHER_DATA .

select pernr
iban
from pa0009
into table it_pa0009
for all entries in it_pa0001
where pernr = it_pa0001-pernr
and begda le p_endda
and endda ge p_begda.

select stell
stltx
from t513s
into table it_t513s
for all entries in it_pa0001
where stell = it_pa0001-stell
and sprsl = 'E'.

select plans
plstx
from t528t
into table it_t528t
for all entries in it_pa0001
where plans = it_pa0001-plans
and sprsl = 'E'.

select kostl
ktext
from cskt
into table it_cskt
for all entries in it_pa0001
where kostl = it_pa0001-kostl.

endform. " GET_OTHER_DATA
*&---------------------------------------------------------------------*
*& Form GET_PA2001_DATA
*----------------------------------------------------------------------*
form GET_PA2001_DATA .

select * from pa2001
into corresponding fields of table it_pa2001
for all entries in it_pa0001
where pernr = it_pa0001-pernr
and begda le p_endda
and endda ge p_begda.

if sy-subrc = 0.
sort it_pa2001 by pernr.
endif.


endform. " GET_PA2001_DATA


ALSO READ:

- Loans Detail Report In HR ABAP.

- Gosi Calculation Report In HR ABAP.

- Employee Pay Details Report In HR ABAP.

- Employee Existence Check Report.

- Send Employee Payslip As An E-Mail Attachment.

.....Back To Sub-Index On HR ABAP.

.....Back To MAIN INDEX.


No comments:

Post a Comment