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

Cash Payment Report In HR ABAP

REPORT zhr_cash_payment_report 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 *
************************************************************************

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

*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
zweck(60) TYPE c, "BANK NAME
waers(5) TYPE c,
iban(34) TYPE c,
* sign(100) type c,
icnum(30) TYPE c,
END OF ty_final.
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.

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_bnka TYPE ty_bnka,
wa_final TYPE ty_final,
it_pa0001 TYPE TABLE OF ty_pa0001,
it_pa0002 TYPE TABLE OF ty_pa0002,
it_pa0009 TYPE TABLE OF ty_pa0009,
it_pa0185 TYPE TABLE OF ty_pa0185,
wa_pa0185 TYPE ty_pa0185,
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,
it_events TYPE slis_t_event,
wa_events TYPE slis_alv_event,
it_list TYPE slis_t_listheader WITH HEADER LINE.

DATA : v_permo TYPE t549a-permo.

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_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 = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

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

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

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

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

wa_fieldcat-fieldname = 'ICNUM'.
wa_fieldcat-reptext_ddic = 'Iquama Numbe'.
wa_fieldcat-just = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

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

wa_fieldcat-fieldname = 'WAERS'.
wa_fieldcat-reptext_ddic = 'Currency'.
wa_fieldcat-just = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

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

it_layout-totals_text = 'Totals'(201).
it_layout-zebra = 'X'.

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

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
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
WHERE pernr IN s_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 zlsch = ' '
AND begda LE p_endda
AND endda GE p_begda.

IF sy-subrc = 0.

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.
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-vorna
wa_pa0002-nachn
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.

IF wa_final-zweck IS INITIAL.
wa_final-zweck = 'Not Available'.
ENDIF.
IF wa_final-iban IS INITIAL.
wa_final-iban = 'Not Available'.
ENDIF.

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

ENDIF.

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

PERFORM get_amount.

ENDLOOP.

ENDFORM. " GET_PA0001
*&---------------------------------------------------------------------*
*& Form GET_AMOUNT
*----------------------------------------------------------------------*
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
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 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 '/557'.
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.

CLEAR it_list.
it_list-typ = 'H'.
it_list-key = space.
it_list-info = 'Cash Payments 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.


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


ALSO READ:

- Bank Report For Employees In HR ABAP.

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

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

.....Back To MAIN INDEX.


No comments:

Post a Comment