Está en la página 1de 6

*************************************************************************

* Project Name : Focus


*************************************************************************
* Program Name : ZHCM_ANNUAL_ALLOWANCE
* Program Type : ALV report
* Development Class :
* Initiated on :
* Completed on : 21-06-2014
* Developed by : Kasif Shameem
* Modified by :
* Transport Request No : ECDK908391
********************************************************************
* Program Description : Annual special allowance of
* an employee
********************************************************************
REPORT ZHCM_ANNUAL_ALLOWANCE.
TABLES : PA0000.
TYPE-POOLS: SLIS. "ALV Declarations
*&---------------------------------------------------------------------*
*& TABLES
*&---------------------------------------------------------------------*
TABLES: PERNR,
T522T.
*&---------------------------------------------------------------------*
*& INFOTYPES
*&---------------------------------------------------------------------*
INFOTYPES: 0000,
0001,
0002.
*&---------------------------------------------------------------------*
*& SELECTION-SCREEN
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK PCODE WITH FRAME TITLE TEXT-S01.
SELECT-OPTIONS: P_FIN FOR PA0000-BEGDA OBLIGATORY.
SELECTION-SCREEN END OF BLOCK PCODE.
*&---------------------------------------------------------------------*
*& TABLE TYPE DECLARATION
*&---------------------------------------------------------------------*
TYPES: BEGIN OF T_OUTPUT,
PERNR TYPE P0001-PERNR,
ANREDTXT TYPE T522T-ATEXT,
FNAME TYPE P0002-VORNA,
LNAME TYPE P0002-NACHN,
DOJ TYPE P0000-BEGDA,
ENDDA TYPE P0000-ENDDA,
PROMO TYPE P0000-BEGDA,
SUBG TYPE P0001-PERSK,
SUBGD TYPE T503T-PTEXT,
ANALOW TYPE ZHCM_PER_PAY-ANALOW,
ACTUAL TYPE ZHCM_PER_PAY-ANALOW,
FYF TYPE ZHCM_PER_PAY-FYF,
FYT TYPE ZHCM_PER_PAY-FYT,
END OF T_OUTPUT.
*&---------------------------------------------------------------------*
*& INTERNAL TABLE DECLARATIONS
*&---------------------------------------------------------------------*
DATA: IT_OUTPUT TYPE TABLE OF T_OUTPUT INITIAL SIZE 0,
IT_OUTPUT1 TYPE TABLE OF T_OUTPUT INITIAL SIZE 0,
WA_OUTPUT TYPE T_OUTPUT,
WA_OUTPUT1 TYPE T_OUTPUT.
DATA TABIX TYPE SY-TABIX.
*ALV data declarations
DATA: FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
GD_TAB_GROUP TYPE SLIS_T_SP_GROUP_ALV,
GD_LAYOUT TYPE SLIS_LAYOUT_ALV,
GD_REPID LIKE SY-REPID,
GT_EVENTS TYPE SLIS_T_EVENT,
GD_PRNTPARAMS TYPE SLIS_PRINT_ALV,
GD_COUNT(6) TYPE N,
GD_OUTTEXT(70) TYPE C,
GD_LINES TYPE I.
DATA : IT_SORT TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE.
************************************************************************
DATA : LV_FROM TYPE ZFYF1.
DATA : LV_TO TYPE ZFYT2.
DATA : LV_PERNR TYPE PERNR-PERNR.
DATA: ACTUAL_CAL1 TYPE ZHCM_PER_PAY-ANALOW,
ACTUAL_CAL2 TYPE ZHCM_PER_PAY-ANALOW.
AT SELECTION-SCREEN.
SELECT SINGLE FYF
FYT
INTO (LV_FROM , LV_TO)
FROM ZHCM_PER_PAY
WHERE fyf EQ P_FIN-LOW
and fyt EQ P_FIN-high.
IF P_FIN-LOW NE LV_FROM OR P_FIN-HIGH NE LV_TO.
MESSAGE 'Please maintain the Financial Year in the Tcode : ZHCM_TAB_PAY' TYP
E 'E'.
ENDIF.
START-OF-SELECTION.
GET PERNR.
PROVIDE * FROM P0000
* FROM P0001
* FROM P0002
BETWEEN P_FIN-LOW
AND P_FIN-HIGH .
IF P0000-MASSN EQ 'ZC' OR P0000-MASSN EQ 'ZQ' OR P0000-MASSN EQ 'ZN'.
IF P0001-PERSK IS NOT INITIAL.
* Personnel number
WA_OUTPUT-PERNR = PERNR-PERNR.
* First name
WA_OUTPUT-FNAME = P0002-VORNA.
* Last name
WA_OUTPUT-LNAME = P0002-NACHN.
* Date of joining
IF P0000-MASSN = 'ZC' OR P0000-MASSN = 'ZQ'.
WA_OUTPUT-DOJ = P0000-BEGDA.
ELSEIF P0000-MASSN = 'ZN' .
WA_OUTPUT-PROMO = P0000-BEGDA.
ENDIF.
WA_OUTPUT-ENDDA = P0000-ENDDA.
* Employee subgroup
WA_OUTPUT-SUBG = P0001-PERSK.
* Personnel title
SELECT SINGLE ATEXT
FROM T522T
INTO WA_OUTPUT-ANREDTXT
WHERE SPRSL EQ SY-LANGU AND
ANRED EQ P0002-ANRED.
* Subgroup text
SELECT SINGLE PTEXT
FROM T503T INTO WA_OUTPUT-SUBGD
WHERE SPRSL EQ SY-LANGU AND PERSK EQ WA_OUTPUT-SUBG.
SELECT SINGLE ANALOW
FROM ZHCM_PER_PAY INTO WA_OUTPUT-ANALOW
WHERE PERSK EQ WA_OUTPUT-SUBG.
* APPEND wa_output TO it_output.
APPEND WA_OUTPUT TO IT_OUTPUT1.
CLEAR WA_OUTPUT.
ENDIF.
CLEAR : WA_OUTPUT-ANREDTXT,
WA_OUTPUT-FNAME,
WA_OUTPUT-LNAME,
WA_OUTPUT-PERNR,
WA_OUTPUT-ANALOW,
WA_OUTPUT-SUBG,
WA_OUTPUT-SUBGD.
ENDIF.
ENDPROVIDE.
END-OF-SELECTION.
SORT IT_OUTPUT1 BY PERNR DOJ.
LOOP AT IT_OUTPUT1 INTO WA_OUTPUT.
* Personnel number
WA_OUTPUT1-PERNR = WA_OUTPUT-PERNR.
* First name
WA_OUTPUT1-FNAME = WA_OUTPUT-FNAME.
* Last name
WA_OUTPUT1-LNAME = WA_OUTPUT-LNAME.
WA_OUTPUT1-DOJ = WA_OUTPUT-DOJ.
WA_OUTPUT1-PROMO = WA_OUTPUT-PROMO.
WA_OUTPUT1-ANALOW = WA_OUTPUT-ANALOW.
WA_OUTPUT1-SUBGD = WA_OUTPUT-SUBGD.
WA_OUTPUT1-ANREDTXT = WA_OUTPUT-ANREDTXT.
WA_OUTPUT1-SUBG = WA_OUTPUT-SUBG.
IF WA_OUTPUT1-PROMO IS INITIAL.
WA_OUTPUT1-ACTUAL = ( WA_OUTPUT1-ANALOW / 365 ) * ( ( WA_OUTPUT-ENDDA + 1
) - WA_OUTPUT1-DOJ ).
ELSEIF WA_OUTPUT1-PROMO IS NOT INITIAL.
WA_OUTPUT1-ACTUAL = ( WA_OUTPUT1-ANALOW / 365 ) * ( ( WA_OUTPUT-ENDDA + 1
) - WA_OUTPUT1-PROMO ).
ENDIF.
APPEND WA_OUTPUT1 TO IT_OUTPUT.
SORT IT_OUTPUT BY DOJ DESCENDING.
CLEAR WA_OUTPUT1.
CLEAR : WA_OUTPUT1-ANREDTXT,
WA_OUTPUT1-FNAME,
WA_OUTPUT1-LNAME,
WA_OUTPUT1-PERNR,
WA_OUTPUT1-ANALOW,
WA_OUTPUT1-SUBG,
WA_OUTPUT1-SUBGD,
WA_OUTPUT1-ACTUAL.
ENDLOOP.
PERFORM BUILD_FIELDCATALOG.
PERFORM BUILD_LAYOUT.
PERFORM DISPLAY_ALV_REPORT.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
* Build Fieldcatalog for ALV Report
*----------------------------------------------------------------------*
FORM BUILD_FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'PERNR'.
FIELDCATALOG-SELTEXT_M = 'Personnel No.'.
FIELDCATALOG-COL_POS = 0.
FIELDCATALOG-OUTPUTLEN = 10.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'FNAME'.
FIELDCATALOG-SELTEXT_M = 'First Name'.
FIELDCATALOG-COL_POS = 1.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'LNAME'.
FIELDCATALOG-SELTEXT_M = 'Last Name'.
FIELDCATALOG-COL_POS = 2.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'DOJ'.
FIELDCATALOG-SELTEXT_M = 'Date of Joining'.
FIELDCATALOG-COL_POS = 3.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'PROMO'.
FIELDCATALOG-SELTEXT_M = 'Date of Promotion'.
FIELDCATALOG-COL_POS = 4.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'SUBG'.
FIELDCATALOG-SELTEXT_M = 'Employee Sub-group'.
FIELDCATALOG-COL_POS = 5.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'SUBGD'.
FIELDCATALOG-SELTEXT_M = 'Description'.
FIELDCATALOG-COL_POS = 5.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'ANALOW'.
FIELDCATALOG-SELTEXT_M = 'Annual Special Allowance'.
FIELDCATALOG-COL_POS = 6.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
*
FIELDCATALOG-FIELDNAME = 'ACTUAL'.
FIELDCATALOG-SELTEXT_M = 'Actual Eligibility'.
FIELDCATALOG-COL_POS = 7.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
ENDFORM. " BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
*& Form BUILD_LAYOUT
*&---------------------------------------------------------------------*
* Build layout for ALV grid report
*----------------------------------------------------------------------*
FORM BUILD_LAYOUT.
GD_LAYOUT-NO_INPUT = 'X'.
GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
GD_LAYOUT-ZEBRA = 'X'.
ENDFORM. " BUILD_LAYOUT
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
* Display report using ALV grid
*----------------------------------------------------------------------*
FORM DISPLAY_ALV_REPORT.
GD_REPID = SY-REPID.
IT_SORT-SPOS = 1.
IT_SORT-UP = 'X'.
IT_SORT-FIELDNAME = 'PERNR'.
IT_SORT-GROUP = '*'.
APPEND IT_SORT.
IT_SORT-SPOS = 2.
IT_SORT-UP = 'X'.
IT_SORT-FIELDNAME = 'FNAME'.
IT_SORT-GROUP = '*'.
APPEND IT_SORT.
IT_SORT-SPOS = 3.
IT_SORT-UP = 'X'.
IT_SORT-FIELDNAME = 'LNAME'.
IT_SORT-GROUP = '*'.
APPEND IT_SORT.
********************************************************************
IF IT_OUTPUT IS NOT INITIAL.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = GD_REPID
IS_LAYOUT = GD_LAYOUT
IT_FIELDCAT = FIELDCATALOG[]
IT_SORT = IT_SORT[]
I_SAVE = 'X'
TABLES
T_OUTTAB = IT_OUTPUT
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.
ENDFORM. " DISPLAY_ALV_REPORT
*Selection texts
*----------------------------------------------------------
* P_FIN Financial Year
*Messages
*----------------------------------------------------------
*
* Message class: Hard coded
* Please maintain the Financial Year in the Tcode : ZHCM_TAB_PAY
--------------------------------------------------------------------------------
--
Extracted by Mass Download version 1.4.1 - E.G.Mellodew. 1998-2014. Sap Release
731