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

Bank Report For Employees In HR ABAP.

REPORT ZHR_BANK MESSAGE-ID zmsg.
*----------------------------------------------------------------*
* TABLES *
*----------------------------------------------------------------*
TABLES: bnka,
pa0001,
pa0009,
t569v,
t549a,
t549q.

*-----------------------------------------------------------------*
* T Y P E P O O L S *
*-----------------------------------------------------------------*
TYPE-POOLS : slis.
************************************************************************
* DECLARATION OF INTERNAL TABLES *
************************************************************************

types: begin of ty_pa0000,
pernr type pa0000-pernr,
end of ty_pa0000.

* Internal Table for string the Bank Data
TYPES : BEGIN OF ty_pa0009,
pernr LIKE pa0009-pernr,
waers LIKE pa0009-waers,
zlsch LIKE pa0009-zlsch,
banks LIKE pa0009-banks,
bankl LIKE pa0009-bankl,
bankn LIKE pa0009-bankn,
ZWECK LIKE pa0009-ZWECK,
iban LIKE pa0009-iban,
END OF ty_pa0009.

TYPES: BEGIN OF ty_bnka,
bankl TYPE bnka-bankl,
banka TYPE bnka-banka,
END OF ty_bnka.

TYPES: BEGIN OF ty_pa0001,
pernr TYPE pa0001-pernr,
werks TYPE pa0001-werks,
persg TYPE pa0001-persg,
persk TYPE pa0001-persk,
btrtl TYPE pa0001-btrtl,
abkrs TYPE pa0001-abkrs,
END OF ty_pa0001.

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

types: begin of ty_pa0185,
pernr type pa0185-pernr,
begda type pa0185-begda,
endda type pa0185-endda,
ICTYP type pa0185-ICTYP,
ICNUM type pa0185-ICNUM,
end of ty_pa0185.

*Internal table for storing field names for displaing in list

TYPES : BEGIN OF ty_final,
sno(5) TYPE c ,
pernr(8) TYPE c, "Personnel Number
ename(40) TYPE c, "Emp Name
amount TYPE pa0008-bet01,
bankn(18) TYPE c, "customer bank acc no.
bankl(15) TYPE c, "BANK KEY
banka(60) TYPE c, "BANK NAME
waers(5) TYPE c,
ZWECK(40) TYPE c,
iban(34) TYPE c,
icnum(30) type c,
curr(5) type c,
cell_colour type lvc_t_scol, "Cell colour
END OF ty_final.

* To colour a cell.
data ls_cellcolour type lvc_s_scol.

DATA: v_tabix TYPE i.
* Work area and Internal tables declaration
DATA: wa_pa0001 TYPE ty_pa0001,
wa_pa0002 TYPE ty_pa0002,
wa_pa0009 TYPE ty_pa0009,
wa_pa0185 TYPE ty_pa0185,
wa_bnka TYPE ty_bnka,
wa_final TYPE ty_final,
it_pa0001 TYPE TABLE OF ty_pa0001,
it_pa0000 TYPE TABLE OF ty_pa0000,
it_pa0185 TYPE TABLE OF ty_pa0185,
it_pa0002 TYPE TABLE OF ty_pa0002,
it_pa0009 TYPE TABLE OF ty_pa0009,
it_bnka TYPE TABLE OF ty_bnka,
it_final TYPE TABLE OF ty_final.

* for getting wagetype amount
DATA : it_rgdir TYPE STANDARD TABLE OF pc261,
wa_itrgdir TYPE pc261,
it_result TYPE pay99_result,
wa_rt TYPE pc207.

DATA: w_molga TYPE t500l-molga,
w_seqnr TYPE cdseq,
w_relid TYPE relid_pcl2,
wagetype TYPE char15.

*For ALV fieldcatlog
DATA : it_fieldcat TYPE slis_t_fieldcat_alv,
*For ALV fieldcatlog
wa_fieldcat TYPE slis_fieldcat_alv,
*For ALV output layout
it_layout TYPE slis_layout_alv,
wa_layout TYPE slis_layout_alv,
it_events TYPE slis_t_event,
wa_events TYPE slis_alv_event,
i_sort TYPE slis_t_sortinfo_alv,
wa_sort TYPE slis_sortinfo_alv,
it_list TYPE slis_t_listheader WITH HEADER LINE.

DATA : v_permo TYPE t549a-permo.

DATA : cs_prnt TYPE slis_print_alv.


DATA: 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.

*************************************************************************
** 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 .

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 b2 WITH FRAME TITLE text-002.
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 b2 .

SELECTION-SCREEN END OF BLOCK b1 .

************************************************************************
* AT SELECTION SCREEN *
************************************************************************

IF NOT s_pernr[] IS INITIAL.
SELECT pernr
FROM pa0001
INTO v_pernr
WHERE pernr IN s_pernr.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'Enter a valid Personnel Number'.
ENDIF.
ENDSELECT.
ENDIF.

IF NOT s_werks[] IS INITIAL.
SELECT werks
FROM pa0001
INTO v_werks
WHERE pernr IN s_werks.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'Enter a valid Personnel Area'.
ENDIF.
ENDSELECT.
ENDIF.

IF NOT s_btrtl[] IS INITIAL.
SELECT btrtl
FROM pa0001
INTO v_btrtl
WHERE pernr IN s_btrtl.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'Enter a valid Personnel Subarea'.
ENDIF.
ENDSELECT.
ENDIF.

IF NOT s_persg[] IS INITIAL.
SELECT persg
FROM pa0001
INTO v_persg
WHERE pernr IN s_persg.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'Enter a valid Employee Group'.
ENDIF.
ENDSELECT.
ENDIF.

IF NOT s_persk[] IS INITIAL.
SELECT persk
FROM pa0001
INTO v_persk
WHERE pernr IN s_persk.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'Enter a valid Employee Subgroup'.
ENDIF.
ENDSELECT.
ENDIF.

IF NOT p_abkrs IS INITIAL.
SELECT abkrs
FROM pa0001
INTO v_abkrs
WHERE pernr = p_abkrs.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'Enter a valid Payroll Area'.
ENDIF.
ENDSELECT.
ENDIF.

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.

PERFORM get_pa0001.

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 BUILD_FIELDCATLOG
*----------------------------------------------------------------------*
FORM build_fieldcatlog .


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

wa_fieldcat-fieldname = 'ZWECK'.
wa_fieldcat-reptext_ddic = 'Bank Name'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'IBAN'.
wa_fieldcat-reptext_ddic = 'IBAN Number'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

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

wa_fieldcat-fieldname = 'PERNR'.
wa_fieldcat-reptext_ddic = 'Personnel Number'.
wa_fieldcat-just = 'C'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'ICNUM'.
wa_fieldcat-reptext_ddic = 'Iquma Number'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'AMOUNT'.
wa_fieldcat-reptext_ddic = 'Amount'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'CURR'.
wa_fieldcat-reptext_ddic = 'Currency'.
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'(201).
it_layout-zebra = 'X'.
it_layout-coltab_fieldname = 'CELL_COLOUR'.

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

cs_prnt-no_print_listinfos = 'X'. "gs_test-prnt_no_listinfo.


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


ENDFORM. " DISPLAY_ALV
*&---------------------------------------------------------------------*
*& Form GET_PA0001
*----------------------------------------------------------------------*
FORM get_pa0001 .

SELECT pernr
werks
persg
persk
btrtl
abkrs
FROM pa0001
INTO TABLE it_pa0001
for all entries in it_pa0000
WHERE pernr = it_pa0000-pernr
and begda le p_endda
and endda ge p_begda
AND werks IN s_werks
AND persg IN s_persg
AND persk IN s_persk
AND btrtl IN s_btrtl
AND abkrs = p_abkrs.

IF sy-subrc = 0.
SORT it_pa0001 BY pernr.

SELECT pernr
vorna
nachn
FROM pa0002
INTO TABLE it_pa0002
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_pa0002 BY pernr.
ENDIF.

SELECT pernr
waers
zlsch
banks
bankl
bankn
ZWECK
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
AND zlsch eq 'E'.

IF sy-subrc = 0.
SORT it_pa0009 BY pernr.
ENDIF.

SELECT bankl
banka
FROM bnka
INTO TABLE it_bnka
FOR ALL ENTRIES IN it_pa0009
WHERE bankl = it_pa0009-bankl.

IF sy-subrc = 0.
SORT it_bnka BY bankl.
ENDIF.

select pernr
begda
endda
ictyp
icnum
from pa0185
into table it_pa0185
for all entries in it_pa0001
where pernr = it_pa0001-pernr
and ictyp = '08'
and begda le p_endda
and endda ge p_begda.


IF sy-subrc = 0.
SORT it_pa0185 BY pernr.
ENDIF.

ENDIF.


LOOP AT it_pa0009 INTO wa_pa0009.
wa_final-pernr = wa_pa0009-pernr.

READ TABLE it_pa0002 INTO wa_pa0002 WITH KEY pernr = wa_pa0009-pernr.
IF sy-subrc = 0.
CONCATENATE wa_pa0002-nachn
wa_pa0002-vorna
INTO wa_final-ename.
ENDIF.

wa_final-bankn = wa_pa0009-bankn.
wa_final-waers = wa_pa0009-waers.
wa_final-ZWECK = wa_pa0009-ZWECK.
wa_final-iban = wa_pa0009-iban.

READ TABLE it_bnka INTO wa_bnka WITH KEY bankl = wa_pa0009-bankl.
IF sy-subrc = 0.
wa_final-banka = wa_bnka-banka.
wa_final-bankl = wa_bnka-bankl.
ENDIF.

READ TABLE it_pa0185 INTO wa_pa0185 WITH KEY pernr = wa_pa0009-pernr.
IF sy-subrc = 0.
wa_final-icnum = wa_pa0185-icnum.
ENDIF.

wa_final-curr = 'SAR'.
PERFORM get_amount.


ENDLOOP.

data: v_iban type pa0009-iban.

sort it_final by iban.
*----populate colors for the field
loop at it_final into wa_final.

if sy-tabix = '1'.
v_iban = wa_final-iban.
else.

check v_iban = wa_final-iban.
ls_cellcolour-fname = 'IBAN'.
ls_cellcolour-color-col = '5'.
ls_cellcolour-color-int = '1'.
ls_cellcolour-color-inv = '0'.
ls_cellcolour-nokeycol = 'X'.
append ls_cellcolour to wa_final-cell_colour.
modify it_final from wa_final.
clear : wa_final.

endif.
endloop.

sort it_final by pernr.

ENDFORM. " GET_PA0001
*&---------------------------------------------------------------------*
*& Form GET_AMOUNT
* this is to fil the amount for the employee
*----------------------------------------------------------------------*
FORM get_amount .

DATA: l_pernr LIKE pa0001-pernr.


CALL FUNCTION 'CU_READ_RGDIR'
EXPORTING
persnr = wa_pa0009-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 fpend = p_endda.
CHECK sy-subrc = 0 and wa_itrgdir-ocrsn is initial.
w_seqnr = wa_itrgdir-seqnr.

SELECT SINGLE
relid
FROM t500l
INTO w_relid
WHERE molga = w_molga.

l_pernr = wa_final-pernr .


CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT'
EXPORTING
clusterid = w_relid
employeenumber = l_pernr " wa_final-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.

READ TABLE it_rgdir INTO wa_itrgdir WITH KEY fpend = p_endda.
CHECK sy-subrc = 0 and wa_itrgdir-ocrsn is initial.
w_seqnr = wa_itrgdir-seqnr.

SELECT SINGLE relid FROM t500l INTO w_relid WHERE molga = w_molga.

l_pernr = wa_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.
ENDIF.


LOOP AT it_result-inter-rt INTO wa_rt.
wagetype = wa_rt-lgart.
CLEAR: wa_rt-lgart.
CASE wagetype.
WHEN '/559'.
wa_final-amount = wa_rt-betrg.
ENDCASE.
ENDLOOP.
check wa_final-amount is not initial.

v_tabix = v_tabix + 1.
wa_final-sno = v_tabix.

APPEND wa_final TO it_final.
CLEAR wa_final.

ENDFORM. " GET_AMOUNT
*&---------------------------------------------------------------------*
*& Form GET_DATA_FROM_CURRENT_PERIOD
*----------------------------------------------------------------------*
FORM get_data_from_current_period .

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

SELECT SINGLE * FROM t549a WHERE abkrs = p_abkrs.
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.
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 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.
it_list-typ = 'H'.
it_list-key = space.
it_list-info = 'Salary Payments'.
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.

clear it_list.
it_list-typ = 'S'.
it_list-key = space.
concatenate 'Payroll Area:' p_abkrs 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
*----------------------------------------------------------------------*
form GET_PA0000 .


select pernr
from pa0000
into table it_pa0000
where pernr in s_pernr
and stat2 = '3'.

endform. " GET_PA0000


ALSO READ:

- BDC For Uploading Absence Data Into PA30 Transaction.

- HR Master Data Update Using T-Code CAT2 With BAPI.

- Upload Job & Position Relations Through PO03.

- BDC To Upload The OM Relations Through T-code PO13.

- Function Modules To Read Benefits Data In HR ABAP.

.....Back To Index On HR ABAP.

.....Back To MAIN INDEX.


No comments:

Post a Comment