*-- Tables
TABLES : pernr, "Standard Selections for HR Master Data Reporting
pc207, "Payroll Results: Results Table
pcl1, "HR Cluster 1
pcl2, "HR Cluster 2
t510, "Pay scales
t549a, "Payroll areas
t549q, "Payroll Periods
pa0002. "Personal details
*-- Internal Tables
*-- Internal Table Declaration For Holding The Data
DATA: BEGIN OF int_petrol OCCURS 0,
pernr LIKE pa0008-pernr, "Personnel Number
trfst LIKE pa0008-trfst, "Pay Scale Level
name(40), "Name of Employee
pallowance TYPE p DECIMALS 2, "Petrol Allowance Amount
END OF int_petrol.
DATA: BEGIN OF pa0015_data OCCURS 0,
pernr LIKE pa0015-pernr,
betrg LIKE pa0015-betrg,
END OF pa0015_data.
DATA:BEGIN OF int_petrol2 OCCURS 0,
pernr LIKE pa0008-pernr, "Personnel Number
vorna LIKE pa0002-vorna, "First Name
nachn LIKE pa0002-nachn, "Last Name
trfst LIKE pa0008-trfst, "Pay Scale Level
name(40), "Name of Employee
pallowance TYPE p DECIMALS 2, "Petrol Allowance Amount
END OF int_petrol2.
DATA : title TYPE lvc_title.
DATA: BEGIN OF per_no OCCURS 0,
pernr LIKE pa0008-pernr,
trfst LIKE pa0008-trfst,
END OF per_no.
DATA: BEGIN OF msg OCCURS 0,
msg1(100) TYPE c,
END OF msg.
DATA: flag TYPE i VALUE '0',
dis_flag TYPE i VALUE '0'.
DATA: int_petrol3 LIKE STANDARD TABLE OF int_petrol2 INITIAL SIZE 0 WITH HEADER LINE.
DATA: int_petrol1 LIKE STANDARD TABLE OF int_petrol INITIAL SIZE 0 WITH HEADER LINE.
TYPES: BEGIN OF zbpetrol_all,
rate TYPE rate,
begda TYPE begda,
endda TYPE endda,
curr TYPE waers,
END OF zbpetrol_all.
DATA: wa_pet_allowance TYPE zbpetrol_all. "WORKAREA FOR INSERTING values.
*DATA: P_LGART1 LIKE T512T-LGART VALUE '0010'. "CHANGE WAGE TYPE HERE
DATA: p_lgart1 LIKE t512t-lgart VALUE '0077'. "CHANGE WAGE TYPE HERE
DATA: BEGIN OF int_0015 OCCURS 0,
pernr(038),
begda(010),
betrg(018),
END OF int_0015.
*-- Internal Table To Store Error Records.
DATA: e_int_0015 LIKE int_0015 OCCURS 0 WITH HEADER LINE.
*-- Batch Input Data of Single Transaction
DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
*-- Internal Table For Export and Import Payroll Results
DATA: int_rgdir LIKE pc261 OCCURS 0 WITH HEADER LINE,
lgtxt LIKE t512t-lgtxt.
DATA: BEGIN OF emp_no OCCURS 0,
pernr(4) TYPE c,
END OF emp_no.
DATA: BEGIN OF emp_no1 OCCURS 0,
pernr TYPE i,
END OF emp_no1.
DATA empno LIKE STANDARD TABLE OF emp_no INITIAL SIZE 0.
DATA empno1 LIKE STANDARD TABLE OF emp_no1 INITIAL SIZE 0 WITH HEADER LINE.
DATA len1 TYPE i.
DATA: err LIKE message.
DATA temp_num(200) TYPE c.
*-- Includes
*-- International Include
INCLUDE rpc2cd09. "Cluster CD data definition
INCLUDE rpc2ca00. "Cluster CA Data-Definition
INCLUDE rpppxd00. "Data Definition buffer PCL1/PCL2 Buffer
INCLUDE rpppxd10. "Common part buffer PCL1/PCL2
INCLUDE rpppxm00. "Buffer Handling routine
*-- Country Specific Include
INCLUDE pc2rxin0. "Cluster IN data definition
INCLUDE rpc2rx09.
*-- ALV Declaration
TYPE-POOLS : slis.
DATA: int_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
int_events TYPE slis_t_event,
int_layout TYPE slis_layout_alv,
ws_events TYPE slis_alv_event,
ws_repid LIKE sy-repid.
*-- Initialization
INITIALIZATION.
ws_repid = sy-repid.
*-- At Selection-Screen
START-OF-SELECTION.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(30) text-002.
SELECTION-SCREEN POSITION 33.
PARAMETERS: p_rate TYPE p DECIMALS 2.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-003.
SELECTION-SCREEN BEGIN OF BLOCK b3.
PARAMETERS: p_upload AS CHECKBOX,
p_fg RADIOBUTTON GROUP g1,
p_bg RADIOBUTTON GROUP g1.
SELECTION-SCREEN END OF BLOCK b3.
SELECTION-SCREEN BEGIN OF BLOCK b4.
PARAMETERS: p_di AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK b4.
SELECTION-SCREEN END OF BLOCK b2.
AT SELECTION-SCREEN.
*-- Wate Type Text
SELECT SINGLE lgtxt INTO lgtxt FROM t512t WHERE sprsl = 'E' AND
molga = '40' AND lgart = p_lgart1 .
*-- Data Retrieval From Logical Database PNP
GET pernr.
PROVIDE pernr FROM p0000 vorna nachn FROM p0002 BETWEEN pn-begda AND
pn-endda.
int_petrol1-pernr = p0000-pernr.
CONCATENATE p0002-vorna p0002-nachn INTO int_petrol1-name SEPARATED
BY space.
ENDPROVIDE.
*-- Clear Data
CLEAR: rgdir, int_rgdir.
REFRESH: rgdir, int_rgdir.
*-- Read All The Payroll Runs For An Employee
cd-key-pernr = pernr-pernr.
rp-imp-c2-cu.
CHECK rp-imp-cd-subrc EQ 0.
*-- Clear Data
REFRESH: rt.
* Read IN Cluster.
LOOP AT rgdir WHERE fpbeg >= pn-begda AND fpend <= pn-endda.
MOVE-CORRESPONDING rgdir TO int_rgdir.
APPEND int_rgdir.
CLEAR int_rgdir.
ENDLOOP.
* Read the last record.
SORT int_rgdir BY seqnr DESCENDING.
READ TABLE int_rgdir INDEX 1.
rx-key-seqno = int_rgdir-seqnr.
rx-key-pernr = pernr-pernr.
rp-imp-c2-in.
CHECK rp-imp-in-subrc EQ 0.
READ TABLE rt WITH KEY lgart = p_lgart1.
IF sy-subrc = 0.
int_petrol1-pallowance = rt-betrg.
ENDIF.
APPEND int_petrol1.
CLEAR int_petrol1.
SELECT trfst pernr
INTO CORRESPONDING FIELDS OF TABLE per_no
FROM pa0008
WHERE trfst LIKE 'L%'
AND bet01 > 0.
SORT per_no.
DELETE ADJACENT DUPLICATES FROM per_no.
*-- END-OF-SELECTION.
END-OF-SELECTION.
LOOP AT int_petrol1.
READ TABLE per_no WITH KEY pernr = int_petrol1-pernr.
IF sy-subrc = 0.
int_petrol-trfst = per_no-trfst.
MODIFY int_petrol1 FROM int_petrol TRANSPORTING trfst.
ENDIF.
ENDLOOP.
SORT int_petrol1.
DELETE ADJACENT DUPLICATES FROM int_petrol1.
IF p_di = 'X'. "TO DISPLAY PETROL ALLOWANCE ONLY
IF pnptimra = 'X'. "CHECK OTHER PERIOD CHECKED
dis_flag = 1.
ENDIF.
IF pnptimr9 = 'X'. "CHECK TO SEE CURRENT PERIOD SELECTED
* CASES - NO RATE GIVEN, RATE GIVEN
* CURRENT PERIOD UPLOADED BUT PAYROLL NOT WRITTEN SO NO RESULT FROM LDB
* SELECT rate INTO p_rate FROM zbpetrol_all WHERE begda = pn-begda AND endda = pn-endda.
* ENDSELECT.
* IF sy-dbcnt = 0.
* MESSAGE i455(0) WITH 'NO PETROL RATE EXSISTS'.
* ELSE.
flag = 1.
* ENDIF. "OF SY-DBCNT
IF p_rate > 0 AND flag = 1. " PETROL RATE EXSISTS.
SELECT pernr SUM( betrg ) INTO TABLE pa0015_data
FROM pa0015
WHERE begda BETWEEN pn-begda AND pn-endda
GROUP BY pernr.
SELECT a~pernr a~trfst b~vorna b~nachn
INTO CORRESPONDING FIELDS OF TABLE int_petrol3
FROM pa0008 AS a
INNER JOIN pa0002 AS b ON b~pernr = a~pernr
WHERE a~trfst LIKE 'L%'
AND a~bet01 > 0.
SORT int_petrol3.
DELETE ADJACENT DUPLICATES FROM int_petrol3.
REFRESH int_petrol1.
LOOP AT int_petrol3 INTO int_petrol2. "loop to transport employee name
CONCATENATE int_petrol2-vorna int_petrol2-nachn INTO
int_petrol2-name SEPARATED BY space.
MODIFY int_petrol3 FROM int_petrol2 TRANSPORTING name.
ENDLOOP.
"loop to transport one table to another table
LOOP AT int_petrol3 INTO int_petrol2.
READ TABLE pa0015_data WITH KEY pernr = int_petrol2-pernr.
IF sy-subrc = 0.
int_petrol-pernr = int_petrol2-pernr.
int_petrol-trfst = int_petrol2-trfst.
int_petrol-name = int_petrol2-name.
int_petrol-pallowance = pa0015_data-betrg.
APPEND int_petrol TO int_petrol1.
ENDIF.
ENDLOOP.
dis_flag = 1.
ENDIF. "P_RATE > 0 AND FLAG = 1.
IF p_rate > 0 AND flag = 0. "CURRENT PERIOD AND DATA NOT UPLOADED
SELECT a~pernr a~trfst b~vorna b~nachn
INTO CORRESPONDING FIELDS OF TABLE int_petrol3
FROM pa0008 AS a
INNER JOIN pa0002 AS b ON b~pernr = a~pernr
WHERE a~trfst LIKE 'L%'
AND a~bet01 > 0.
SORT int_petrol3.
DELETE ADJACENT DUPLICATES FROM int_petrol3.
REFRESH int_petrol1.
LOOP AT int_petrol3 INTO int_petrol2. "loop to transport employee name
CONCATENATE int_petrol2-vorna int_petrol2-nachn INTO
int_petrol2-name SEPARATED BY space.
MODIFY int_petrol3 FROM int_petrol2 TRANSPORTING name.
ENDLOOP.
PERFORM get_value. "TO CONVERT THE FIRST SCREEN PERNR INTO number formate
"loop to transport one table to another table
LOOP AT int_petrol3 INTO int_petrol2.
READ TABLE empno1 WITH KEY pernr = int_petrol2-pernr.
IF sy-subrc <> 0.
int_petrol-pernr = int_petrol2-pernr.
int_petrol-trfst = int_petrol2-trfst.
int_petrol-name = int_petrol2-name.
APPEND int_petrol TO int_petrol1.
ENDIF.
ENDLOOP.
PERFORM cal_allowance.
ENDIF. " OF P_RATE > 0
dis_flag = 1.
ENDIF. " OF CURRENT PERIOD CHECK.
ENDIF. " OF CHECK DISPLAY.
*----BDC
IF p_upload = 'X'.
IF pnptimra = 'X'. "CHECK OTHER PERIOD CHECKED
MESSAGE i455(0) WITH 'Petrol Allowance cannot be uploaded'.
LEAVE SCREEN.
ENDIF.
IF p_rate > 0.
* IF P_RATE > 0 OR P_RATE = 0.
IF pnptimr9 = 'X'. "CHECK TO SEE CURRENT PERIOD SELECTED
wa_pet_allowance-begda = pn-begda.
wa_pet_allowance-endda = pn-endda.
wa_pet_allowance-rate = p_rate.
wa_pet_allowance-curr = 'INR'.
* INSERT INTO zbpetrol_all VALUES wa_pet_allowance.
SELECT a~pernr a~trfst b~vorna b~nachn
INTO CORRESPONDING FIELDS OF TABLE int_petrol3
FROM pa0008 AS a
INNER JOIN pa0002 AS b ON b~pernr = a~pernr
WHERE a~trfst IN ('L1' , 'L2' , 'L3')
AND a~bet01 > 0.
SORT int_petrol3.
DELETE ADJACENT DUPLICATES FROM int_petrol3.
REFRESH int_petrol1.
"loop to transport employee name
LOOP AT int_petrol3 INTO int_petrol2.
CONCATENATE int_petrol2-vorna int_petrol2-nachn INTO
int_petrol2-name SEPARATED BY space.
MODIFY int_petrol3 FROM int_petrol2 TRANSPORTING name.
ENDLOOP.
PERFORM get_value. "TO CONVERT THE FIRST SCREEN PERNR INTO number formate
"loop to transport one table to another table
LOOP AT int_petrol3 INTO int_petrol2.
READ TABLE empno1 WITH KEY pernr = int_petrol2-pernr.
IF sy-subrc <> 0.
int_petrol-pernr = int_petrol2-pernr.
int_petrol-trfst = int_petrol2-trfst.
int_petrol-name = int_petrol2-name.
APPEND int_petrol TO int_petrol1.
ENDIF.
ENDLOOP.
PERFORM cal_allowance.
dis_flag = 1.
SORT int_petrol1.
LOOP AT int_petrol1.
MOVE: int_petrol1-pernr TO int_0015-pernr,
int_petrol1-pallowance TO int_0015-betrg.
CONCATENATE pn-endda+6(2) pn-endda+4(2) pn-endda+0(4) INTO
int_0015-begda SEPARATED BY '.'.
APPEND int_0015.
CLEAR int_0015.
ENDLOOP.
LOOP AT int_0015.
PERFORM f_bdcdata.
IF p_fg = 'X'.
CALL TRANSACTION 'PA30' USING bdcdata MODE 'A' UPDATE 'S'.
ELSE.
CALL TRANSACTION 'PA30' USING bdcdata MODE 'N' UPDATE 'S'.
ENDIF.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = ws_repid
is_layout = int_layout
it_fieldcat = int_fieldcat[]
i_default = 'X'
i_save = 'X'
it_events = int_events
TABLES
t_outtab = int_petrol1
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
*&--------------------------------------------------------------------*
*& Form GET_VALUE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM get_value.
GET PARAMETER ID: 'NUM' FIELD temp_num.
IF temp_num <> ''.
len1 = STRLEN( temp_num ).
PERFORM get_pernr.
APPEND temp_num TO empno.
*&--------------------------------------------------------------------*
*& Form GET_PERNR
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM get_pernr.
SPLIT temp_num AT ',' INTO emp_no temp_num.
APPEND emp_no TO empno.
CLEAR emp_no.
SEARCH temp_num FOR ','.
IF sy-subrc = 0.
PERFORM get_pernr.
ENDIF.
ENDFORM. "GET_PERNR
*&---------------------------------------------------------------------*
*& Form ERROR_MSG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM error_msg.
IF sy-subrc <> 0.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
lang = sy-langu
IMPORTING
msg = msg-msg1.
APPEND msg.
CLEAR msg.
ENDIF.
ENDFORM. "ERROR_MSG
*&--------------------------------------------------------------------*
*& Form F_BDCDATA
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM f_bdcdata.
PERFORM bdc_dynpro USING 'SAPMP50A' '1000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=INS'.
PERFORM bdc_field USING 'RP50G-PERNR'
int_0015-pernr.
PERFORM bdc_field USING 'RP50G-TIMR6'
'X'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RP50G-CHOIC'.
PERFORM bdc_field USING 'RP50G-CHOIC'
'0015'.
PERFORM bdc_dynpro USING 'MP001500' '2000'.
PERFORM bdc_field USING 'BDC_CURSOR'
'Q0015-BETRG'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'P0015-LGART'
'0077'. "CHANGE WAGE TYPE HERE also
PERFORM bdc_field USING 'Q0015-BETRG'
int_0015-betrg.
PERFORM bdc_field USING 'P0015-WAERS'
'INR'.
PERFORM bdc_field USING 'P0015-BEGDA'
int_0015-begda.
PERFORM bdc_dynpro USING 'MP001500' '2000'.
PERFORM bdc_field USING 'BDC_CURSOR'
'P0015-LGART'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P0015-LGART'
'0077'. "CHANGE WAGE TYPE HERE also
PERFORM bdc_field USING 'Q0015-BETRG'
int_0015-betrg.
PERFORM bdc_field USING 'P0015-WAERS'
'INR'.
PERFORM bdc_field USING 'P0015-BEGDA'
int_0015-begda.
ENDFORM. "F_BDCDATA
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0732 text
* -->P_0733 text
*----------------------------------------------------------------------*
FORM bdc_dynpro USING value(p_0732) TYPE c
value(p_0733) TYPE c.
CLEAR bdcdata.
bdcdata-program = p_0732.
bdcdata-dynpro = p_0733.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
ENDFORM. " BDC_DYNPRO
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0755 text
* -->P_0756 text
*----------------------------------------------------------------------*
FORM bdc_field USING value(p_0755) TYPE c
value(p_0756) TYPE c.
CLEAR bdcdata.
bdcdata-fnam = p_0755.
bdcdata-fval = p_0756.
APPEND bdcdata.
ENDFORM. " BDC_FIELD
*&--------------------------------------------------------------------*
*& Form CAL_ALLOWANCE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM cal_allowance.
*&---------------------------------------------------------------------*
*& Form FILL_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM fill_fieldcat.
*&---------------------------------------------------------------------*
*& Form GET_EVENTS_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_events_alv.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
READ TABLE int_events INTO ws_events WITH KEY name =
slis_ev_top_of_page.
IF sy-subrc = 0.
ws_events-form = 'TOP'.
MODIFY int_events FROM ws_events INDEX sy-tabix.
ENDIF.
ENDFORM. " GET_EVENTS_ALV
*&--------------------------------------------------------------------*
*& Form TOP-OF-PAGE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM top.
*-- ALV Declarations
DATA: ws_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.