Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Employee details in SAP ABAP Hr

hi folks,

do any one hav done Report -Employee details in SAP ABAP Hr.

Tags:
Former Member
Former Member replied

check this code

*--------------------------------------------------------------*
*                        INFOTYPES                             *
*--------------------------------------------------------------*
INFOTYPES : 0000,     " Actions
            0001,     " Organizaiton Assignment
            0002,     " Personnel Data
            0008,     " Basic Pay
            0022,     " Education
            0025,     " Appraisals
            0077,     " Additional Personal Data
            2001,     " Absences
            9002,     " Additional Personal Data
            9545,     " Discipline data
            0000 NAME INT_PROM,
            0000 NAME INT_CHGPY,
            0302.

*--------------------------------------------------------------*
*                        INCLUDES                             *
*--------------------------------------------------------------*


*--------------------------------------------------------------*
*                        TABLES                                *
*--------------------------------------------------------------*
TABLES    : PERNR.

*--------------------------------------------------------------*
*                        CONSTANTS                             *
*--------------------------------------------------------------*
CONSTANTS : C_ONE      TYPE CHAR1  VALUE '1',
            C_EARLY    TYPE CHAR1  VALUE 'E',
            C_NEW      TYPE CHAR1  VALUE 'N',
            C_EARLYDT  TYPE SY-DATUM VALUE '20000501',
            C_JAN      TYPE CHAR2  VALUE '01',
            C_FEB      TYPE CHAR2  VALUE '02',
            C_MAR      TYPE CHAR2  VALUE '03',
            C_AWL      TYPE CHAR3  VALUE 'AWL',
            C_LWP      TYPE CHAR3  VALUE 'LWP'.

*--------------------------------------------------------------*
*                        TYPES                                 *
*--------------------------------------------------------------*
TYPE-POOLS: SLIS.    		        " ALV Type Pool
TYPES  :

         BEGIN OF T_DISCACT,
           PERNR  TYPE CHAR8,
           COMM1  TYPE CHAR1,
           DESCRI TYPE CHAR40,
           COMM2  TYPE CHAR1,
           MDATE  TYPE CHAR10,
         END OF T_DISCACT,

         BEGIN OF T_INCRE,
           PERNR  TYPE CHAR8,
           INCR1 TYPE CHAR10,
           INCR2 TYPE CHAR10,
           INCR3 TYPE CHAR10,
         END OF T_INCRE,

         BEGIN OF T_OUTPUT,
           PERNR TYPE CHAR8,
           NAME  TYPE CHAR40,
           DESIG TYPE CHAR40,
           PESUB TYPE CHAR15,
           ORGUN TYPE CHAR40,
           COSTC TYPE CHAR20,
           ETHIC TYPE CHAR2,
           CPCODE TYPE ZCCODE,
           GRADE TYPE CHAR8,
           ***   TYPE CHAR6,
           DOB   TYPE CHAR10,
           DOJ   TYPE CHAR10,
           QUAL1 TYPE CHAR30,
           QUAL2 TYPE CHAR30,
           QUAL3 TYPE CHAR30,
           QUAL4 TYPE CHAR30,
           QUAL5 TYPE CHAR30,
           LPROM TYPE CHAR10,
           PROMD TYPE CHAR10,
           PROMT TYPE CHAR1,
           NOYRS TYPE CHAR2,
           AWL   TYPE CHAR9,
           LWP   TYPE CHAR9,
           APPR1 TYPE CHAR9,
           APPR2 TYPE CHAR9,
           APPR3 TYPE CHAR9,
           APPR4 TYPE CHAR9,
           APPR5 TYPE CHAR9,
           DISCI TYPE CHAR57,
         END   OF T_OUTPUT.

DATA : W_OUTPUT TYPE T_OUTPUT.

TYPES  :  BEGIN OF T_FILE.
        INCLUDE STRUCTURE W_OUTPUT.
TYPES  :   INCR1 TYPE CHAR10,
           INCR2 TYPE CHAR10,
           INCR3 TYPE CHAR10,
          END OF T_FILE.

DATA  : W_FILE TYPE T_FILE.

TYPES : BEGIN  OF T_EXCEL.
        INCLUDE STRUCTURE W_FILE.
TYPES :  END OF T_EXCEL.

*--------------------------------------------------------------*
*                        INTERNAL TABLES                       *
*--------------------------------------------------------------*
DATA   : INT_NONEXE  TYPE STANDARD TABLE OF ZHRT007   WITH HEADER LINE,
         INT_OUTPUT  TYPE STANDARD TABLE OF T_OUTPUT  WITH HEADER LINE,
         INT_DISCACT TYPE STANDARD TABLE OF T_DISCACT WITH HEADER LINE,
         INT_QUALFI  TYPE STANDARD TABLE OF T518B     WITH HEADER LINE,
         INT_INCRE   TYPE STANDARD TABLE OF T_INCRE   WITH HEADER LINE,
         INT_DISCIP  TYPE STANDARD TABLE OF ZHRT004   WITH HEADER LINE,
         INT_PESUB   TYPE STANDARD TABLE OF T001P     WITH HEADER LINE,
         INT_COSTC   TYPE STANDARD TABLE OF CSKT      WITH HEADER LINE,
         INT_EXCEL   TYPE STANDARD TABLE OF T_EXCEL   WITH HEADER LINE,
         EVENT       TYPE SLIS_T_EVENT WITH HEADER LINE,
         LISTHEAD    TYPE SLIS_T_LISTHEADER WITH HEADER LINE.

*--------------------------------------------------------------*
*                        VARIABLES                             *
*--------------------------------------------------------------*
DATA : W_HIREDATE TYPE BEGDA,
       W_WAGEGRP  TYPE TRFGR,
       W_CPCODE   TYPE ZCCODE,
       W_CAREERCD TYPE CHAR6,
       W_PROMTYPE TYPE ZTSTYPE,
       W_NOOFYRS  TYPE ZNOYRS,
       W_LASTPROM TYPE CHAR10,
       W_PROMDATE TYPE BEGDA,
       W_YEAR     TYPE CHAR4,
       W_APYEAR   TYPE CHAR4,
       W_APPRST   TYPE SY-DATUM,
       W_DISDATE  TYPE ENDDA,
       W_APPREND  TYPE ENDDA,
       W_ABSST    TYPE ENDDA,
       W_ABSEND   TYPE ENDDA,
       W_ABSYR    TYPE CHAR4,
       W_MONTH(2) TYPE N,
       W_AWL      TYPE CHAR9,
       W_LWP      TYPE CHAR9,
       W_DISCI    TYPE T_OUTPUT-DISCI,
       W_ONE(2)   TYPE N VALUE '01',
       W_CURDATE TYPE CHAR10,
       W_HEADING TYPE LVC_TITLE.


*--------------------------------------------------------------*
*                        SELECTION SCREEN                      *
*--------------------------------------------------------------*

SELECTION-SCREEN BEGIN OF BLOCK FRM1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:
  S_WAGRP    FOR  P0008-TRFGR OBLIGATORY,
  S_FROM     FOR  P0000-BEGDA OBLIGATORY NO-EXTENSION.
SELECTION-SCREEN END OF BLOCK FRM1.

* Selection screen serach help for wage groups.
INCLUDE : ZHRI0003.

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

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

  PERFORM PU_EXEUTIVES_PROM.
  IF S_FROM-HIGH IS INITIAL.
    S_FROM-HIGH = SY-DATUM.
  ENDIF.
*Fetching employee data for all infotypes.
GET PERNR.
  PERFORM  PU_DATA_RETRIEVAL.
*--------------------------------------------------------------*
*                        START OF SELECTION                    *
*--------------------------------------------------------------*
END-OF-SELECTION.
  PERFORM PU_FINAL_TABLE.

  PERFORM PU_GRID_DISPLAY.

  PERFORM PU_FREE_TABLES.
*--------------------------------------------------------------*
*                        SUBROUTINES                           *
*--------------------------------------------------------------*

*&---------------------------------------------------------------------*
*&      Form  PU_DATA_RETRIEVAL
*&---------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
FORM PU_DATA_RETRIEVAL .

* To find out date of join for employee
  PERFORM PU_DATA_OF_JOIN.

* Employee Personnel data
  RP_PROVIDE_FROM_LAST P0002 SPACE PN-BEGDA PN-ENDDA.
  IF PNP-SW-FOUND NE C_ONE.
    REJECT.
  ENDIF.
* Employee Name into output table
  INT_OUTPUT-NAME = P0002-VORNA.
*  INT_OUTPUT-DOB  = P0002-GBDAT.
  PERFORM PU_DATE_CONVERSION USING    P0002-GBDAT
                             CHANGING INT_OUTPUT-DOB.


  IF P0002-GESCH EQ 1.
    INT_OUTPUT-***  = 'Male'.
  ELSE.
    INT_OUTPUT-***  = 'Female'.
  ENDIF.

* Fetching employees from employee sub goup of Non Executive
  RP_PROVIDE_FROM_LAST P0001 SPACE PN-BEGDA PN-ENDDA.
  IF PNP-SW-FOUND NE C_ONE.
    REJECT.
  ENDIF.

  IF P0001-PERSK  EQ '30' OR P0001-PERSK  EQ '20'.
* Position for employee into output table
    PERFORM  PU_POSTION_TEXT.
  ELSE.
    REJECT.
  ENDIF.
*
* Position for employee into output table
  PERFORM  PU_POSTION_TEXT.
* Persoonel Sub Area text .
  READ TABLE INT_PESUB WITH KEY WERKS = P0001-WERKS
                                BTRTL = P0001-BTRTL.
  IF SY-SUBRC EQ 0.
    INT_OUTPUT-PESUB = INT_PESUB-BTEXT.
  ENDIF.
  READ TABLE INT_COSTC WITH KEY KOSTL = P0001-KOSTL.
  IF SY-SUBRC EQ 0.
    INT_OUTPUT-COSTC = INT_COSTC-KTEXT.
  ENDIF.


* Fetching employees from Additional Personal Data
  RP_PROVIDE_FROM_LAST P0077 SPACE PN-BEGDA PN-ENDDA.
  IF PNP-SW-FOUND EQ C_ONE.
* Ethnic origin of employee  into output table
    INT_OUTPUT-ETHIC = P0077-RACKY.
  ENDIF.


* Selecting data from  basic pay last record with wage group
  RP_PROVIDE_FROM_LAST P0008 SPACE PN-BEGDA PN-ENDDA.
  IF PNP-SW-FOUND NE C_ONE.
    REJECT.
  ELSE.
    W_WAGEGRP = P0008-TRFGR.
* Employee Pay Scale Group  into output table
    INT_OUTPUT-GRADE = P0008-TRFGR.
  ENDIF.


* Selecting data from  Education with wage group
  SORT P0022 BY BEGDA.
  PROVIDE * FROM P0022 BETWEEN PN-BEGDA AND PN-ENDDA.
    IF SY-TABIX EQ 1.
      READ TABLE INT_QUALFI WITH KEY AUSBI = P0022-AUSBI.
      IF SY-SUBRC EQ 0.
        INT_OUTPUT-QUAL1 = INT_QUALFI-ATEXT.
      ENDIF.
    ELSEIF SY-TABIX EQ 2.
      READ TABLE INT_QUALFI WITH KEY AUSBI = P0022-AUSBI.
      IF SY-SUBRC EQ 0.
        INT_OUTPUT-QUAL2 = INT_QUALFI-ATEXT.
      ENDIF.
    ELSEIF SY-TABIX EQ 3.
      READ TABLE INT_QUALFI WITH KEY AUSBI = P0022-AUSBI.
      IF SY-SUBRC EQ 0.
        INT_OUTPUT-QUAL3 = INT_QUALFI-ATEXT.
      ENDIF.
    ELSEIF SY-TABIX EQ 4.
      READ TABLE INT_QUALFI WITH KEY AUSBI = P0022-AUSBI.
      IF SY-SUBRC EQ 0.
        INT_OUTPUT-QUAL4 = INT_QUALFI-ATEXT.
      ENDIF.
    ELSEIF SY-TABIX EQ 5.
      READ TABLE INT_QUALFI WITH KEY AUSBI = P0022-AUSBI.
      IF SY-SUBRC EQ 0.
        INT_OUTPUT-QUAL5 = INT_QUALFI-ATEXT.
      ENDIF.
    ENDIF.
  ENDPROVIDE.



* Carrer path code for employee from Additional Personal Data.
  RP_PROVIDE_FROM_LAST P9002 SPACE PN-BEGDA PN-ENDDA.
  IF PNP-SW-FOUND EQ C_ONE.
    W_CPCODE  = P9002-CPCODE.
    INT_OUTPUT-CPCODE = P9002-CPCODE.
    IF W_CPCODE EQ '001'.
      IF W_HIREDATE < C_EARLYDT.
        CONCATENATE W_CPCODE
                    C_EARLY
              INTO  W_CAREERCD.
      ELSE.
        CONCATENATE W_CPCODE
                    C_NEW
              INTO  W_CAREERCD.
      ENDIF.
    ELSE.
      W_CAREERCD = W_CPCODE.
    ENDIF.
  ENDIF.

* Detrmine Promotion by Test/Service
  READ TABLE INT_NONEXE WITH KEY CPCODE    = W_CAREERCD
                                 WAGEGROUP = W_WAGEGRP.
  IF SY-SUBRC EQ 0.
    W_PROMTYPE = INT_NONEXE-TSTYPE.
    W_NOOFYRS  = INT_NONEXE-NOYRS.
    INT_OUTPUT-PROMT = W_PROMTYPE.
    INT_OUTPUT-NOYRS = W_NOOFYRS.
  ENDIF.


* Retriving last promotion date from actions
  DELETE INT_PROM WHERE MASSN NE 'B3'.
  SORT INT_PROM BY BEGDA DESCENDING.
*  RP_PROVIDE_FROM_LAST INT_PROM SPACE PN-BEGDA PN-ENDDA.
  READ TABLE INT_PROM INDEX 1.
  IF SY-SUBRC EQ 0 AND INT_PROM-MASSN EQ 'B3'.
    PERFORM PU_DATE_CONVERSION USING  INT_PROM-BEGDA
                             CHANGING W_LASTPROM.
  ELSE.
    PERFORM PU_DATE_CONVERSION USING  W_HIREDATE
                               CHANGING W_LASTPROM.
  ENDIF.

*  As there is no ending date for records which happen on same date
*  for cross check to get last promotion Infotype 0302' is retived
  IF P0302[] IS NOT INITIAL.
    DELETE P0302 WHERE MASSN NE 'B3'.
    SORT  P0302 BY BEGDA DESCENDING.
    READ TABLE P0302 INDEX 1.
    IF SY-SUBRC EQ 0 AND
       INT_PROM-BEGDA IS NOT INITIAL.
      IF INT_PROM-BEGDA < P0302-BEGDA.
        PERFORM PU_DATE_CONVERSION USING  P0302-BEGDA
                                 CHANGING W_LASTPROM.
      ENDIF.
    ENDIF.
  ENDIF.

  IF W_LASTPROM+0(2) GT '01'.
    W_LASTPROM+0(2) = '01'.
    W_ONE = W_LASTPROM+3(2) + 1.
    W_LASTPROM+3(2) =  W_ONE.
  ENDIF.

* Last promaotion date for Employee into output table
  INT_OUTPUT-LPROM =  W_LASTPROM.


* To Find out promotion due date for employee.
* Fetching service availabilty data
  W_YEAR     =  W_LASTPROM+6(4).
  W_YEAR     =  W_YEAR + W_NOOFYRS.
  CONCATENATE  W_YEAR
                 W_LASTPROM+3(2)
               W_LASTPROM+0(2)
          INTO W_PROMDATE.
* Check promotion duedate is with in input range.
  IF S_FROM-LOW IS NOT INITIAL.
    CHECK W_PROMDATE GE S_FROM-LOW.
  ENDIF.
  IF S_FROM-HIGH IS NOT INITIAL.
    CHECK W_PROMDATE LE S_FROM-HIGH.
  ENDIF.

* Promaotion due date for Employee into output table
  PERFORM PU_DATE_CONVERSION USING    W_PROMDATE
                             CHANGING INT_OUTPUT-PROMD.


* Apprisal rating data.
* If promotion month is JAN,FEB,MAR deduct 6 years
  IF W_PROMDATE+4(2) EQ C_JAN OR
     W_PROMDATE+4(2) EQ C_FEB OR
     W_PROMDATE+4(2) EQ C_MAR.
    CLEAR W_YEAR.
    W_YEAR   = W_PROMDATE+0(4).
    W_APYEAR = W_YEAR - 1.
    W_YEAR   = W_YEAR - 6.
  ELSE.
* If promotion month is not JAN,FEB,MAR deduct 5 years
    W_YEAR   = W_PROMDATE+0(4).
    W_APYEAR = W_YEAR.
    W_YEAR   = W_YEAR - 5.
  ENDIF.

  CONCATENATE  W_YEAR
               '0401'
          INTO W_APPRST.

  CONCATENATE  W_APYEAR
               '0331'
          INTO W_APPREND.


  DELETE P0025 WHERE BEGDA LT W_APPRST
                  OR BEGDA GT W_APPREND.
  PROVIDE * FROM P0025 BETWEEN PN-BEGDA AND PN-ENDDA.
    IF SY-TABIX EQ 1.
      INT_OUTPUT-APPR1 = P0025-KSU01.
    ELSEIF SY-TABIX EQ 2.
      INT_OUTPUT-APPR2 = P0025-KSU01.
    ELSEIF SY-TABIX EQ 3.
      INT_OUTPUT-APPR3 = P0025-KSU01.
    ELSEIF SY-TABIX EQ 4.
      INT_OUTPUT-APPR4 = P0025-KSU01.
    ELSEIF SY-TABIX EQ 5.
      INT_OUTPUT-APPR5 = P0025-KSU01.
    ENDIF.

  ENDPROVIDE.

* Absence data.
  IF W_PROMDATE+4(2) EQ C_JAN.
    CLEAR W_YEAR.
    W_YEAR   = W_PROMDATE+0(4).
    W_ABSYR  = W_YEAR - 1.
    W_MONTH  = '11'.
    W_YEAR   = W_YEAR - 2.
  ELSE.
* If promotion month is not JAN,FEB,MAR deduct 5 years
    W_YEAR   = W_PROMDATE+0(4).
    W_ABSYR  = W_YEAR.
    W_MONTH  = W_PROMDATE+4(2).
    W_MONTH  = W_MONTH - 01.
    W_YEAR   = W_YEAR - 1.
  ENDIF.
  CONCATENATE W_YEAR
              W_MONTH
              '23'
         INTO W_ABSST.
  CONCATENATE  W_ABSYR
               W_MONTH
               '22'
          INTO W_ABSEND.
  SORT   P2001 BY BEGDA.
  DELETE P2001 WHERE ( AWART NE C_AWL AND
                       AWART NE C_LWP )  OR
                     ( BEGDA LT W_ABSST
                 OR    BEGDA GT W_ABSEND ).
  PROVIDE * FROM P2001 BETWEEN PN-BEGDA AND PN-ENDDA.
    IF P2001-AWART  EQ  C_AWL.
      W_AWL = W_AWL + P2001-ABWTG.
    ELSEIF P2001-AWART  EQ  C_LWP.
      W_LWP = W_LWP + P2001-ABWTG.
    ENDIF.
  ENDPROVIDE.
  INT_OUTPUT-AWL = W_AWL.
  INT_OUTPUT-LWP = W_LWP.


* Increments dates' data.
  DELETE INT_CHGPY WHERE MASSN NE 'B7'.
  SORT   INT_CHGPY BY BEGDA DESCENDING.
  IF INT_CHGPY[] IS NOT INITIAL.
    INT_INCRE-PERNR = INT_CHGPY-PERNR.
    PROVIDE * FROM INT_CHGPY  BETWEEN PN-BEGDA
                                  AND PN-ENDDA.
      IF SY-TABIX EQ 1.
        PERFORM PU_DATE_CONVERSION USING    INT_CHGPY-BEGDA
                                   CHANGING INT_INCRE-INCR1.

      ELSEIF SY-TABIX EQ 2.
        PERFORM PU_DATE_CONVERSION USING    INT_CHGPY-BEGDA
                                   CHANGING INT_INCRE-INCR2.

      ELSEIF SY-TABIX EQ 3.
        PERFORM PU_DATE_CONVERSION USING    INT_CHGPY-BEGDA
                                   CHANGING INT_INCRE-INCR3.

      ENDIF.
    ENDPROVIDE.
    APPEND INT_INCRE.
    CLEAR  INT_INCRE.
  ENDIF.

* Disciplinary Actions.
  CLEAR W_YEAR.
  W_YEAR = W_PROMDATE+0(4).
  W_YEAR = W_YEAR - 3.
  CONCATENATE  W_YEAR
               W_PROMDATE+4(4)
          INTO W_DISDATE.

  SORT P9545 BY MDATE.
  DELETE P9545 WHERE MDATE LT W_DISDATE
                  OR MDATE GT W_PROMDATE.

  PROVIDE * FROM P9545 BETWEEN PN-BEGDA
                          AND  PN-ENDDA.
    READ TABLE INT_DISCIP WITH KEY MCODE = P9545-MCODE.
    IF SY-SUBRC EQ 0.
      INT_DISCACT-PERNR  = P9545-PERNR.
      INT_DISCACT-DESCRI = INT_DISCIP-DESCRI.
      PERFORM PU_DATE_CONVERSION USING    P9545-MDATE
                                 CHANGING INT_DISCACT-MDATE.
      INT_DISCACT-COMM1 = ','.
      INT_DISCACT-COMM2 = ','.
      APPEND INT_DISCACT.
      CLEAR  INT_DISCACT.
    ENDIF.
  ENDPROVIDE.

  APPEND INT_OUTPUT.
  CLEAR INT_OUTPUT.
  CLEAR : W_HIREDATE,W_WAGEGRP,W_CPCODE,W_CAREERCD,W_PROMTYPE,
          W_NOOFYRS,W_LASTPROM,W_PROMDATE,W_YEAR,W_APYEAR,
          W_APPRST,W_DISDATE,W_APPREND,W_ABSST,W_ABSEND,
          W_ABSYR,W_MONTH,W_AWL,W_LWP,W_DISCI.

ENDFORM.                    " PU_DATA_RETRIEVAL
*&---------------------------------------------------------------------*
*&      Form  PU_DATA_OF_JOIN
*&---------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
FORM PU_DATA_OF_JOIN .
  CLEAR INT_OUTPUT.
  READ TABLE P0000 WITH KEY  MASSN = 'B1'.
  IF SY-SUBRC NE 0 OR  P0000-STAT2 NE '3'.
    REJECT.
  ELSE.
* Personnel number into output table
    INT_OUTPUT-PERNR = P0000-PERNR.

    PERFORM PU_DATE_CONVERSION USING P0000-BEGDA
                            CHANGING INT_OUTPUT-DOJ.

    W_HIREDATE = P0000-BEGDA.
  ENDIF.
ENDFORM.                    " PU_DATA_OF_JOIN
*&---------------------------------------------------------------------*
*&      Form  PU_POSTION_TEXT
*&---------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
FORM PU_POSTION_TEXT .



  DATA  : S_OBJECT TYPE OBJEC_T,
          PERNR_TAB  TYPE HRQUERY_PERNR_T ,
          SOBID_TAB  TYPE HRQUERY_SOBID_T ,
          WA_SOBID TYPE HRQUERY_SOBID,
          WA_PERNR TYPE HRQUERY_PERNR,
          WA_OBJECT TYPE OBJEC.

  WA_PERNR-PERNR = P0001-PERNR.
  APPEND WA_PERNR TO PERNR_TAB.


  WA_SOBID-PLVAR = '01'.
  WA_SOBID-OTYPE = P0001-OTYPE.
  WA_SOBID-SOBID = P0001-PLANS.

  APPEND WA_SOBID TO SOBID_TAB.

  WA_SOBID-PLVAR = '01'.
  WA_SOBID-OTYPE = 'O'.
  WA_SOBID-SOBID = P0001-ORGEH.

  APPEND WA_SOBID TO SOBID_TAB.



  CALL FUNCTION 'HR_GET_TEXT_FOR_OBJECTS'
    EXPORTING
      BEGDA       = PN-BEGDA
      ENDDA       = PN-ENDDA
    IMPORTING
      OBJEC_TAB   = S_OBJECT
    CHANGING
      PERNR_TAB   = PERNR_TAB
      SOBID_TAB   = SOBID_TAB
    EXCEPTIONS
      WRONG_DATES = 1
      OTHERS      = 2.
  IF SY-SUBRC EQ 0.

    LOOP AT S_OBJECT INTO WA_OBJECT.
      IF WA_OBJECT-OTYPE EQ 'O'.
        INT_OUTPUT-ORGUN = WA_OBJECT-STEXT.
      ELSEIF  WA_OBJECT-OTYPE EQ 'S'.
        INT_OUTPUT-DESIG = WA_OBJECT-STEXT.
      ENDIF.
    ENDLOOP.
  ENDIF.

ENDFORM.                    " PU_POSTION_TEXT

*&---------------------------------------------------------------------*
*&      Form  PU_EXEUTIVES_PROM
*&---------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
FORM PU_EXEUTIVES_PROM .
  SELECT * FROM ZHRT007 INTO TABLE INT_NONEXE.
  SELECT * FROM ZHRT004 INTO TABLE INT_DISCIP.
  SELECT * FROM T001P   INTO TABLE INT_PESUB.
  SELECT * FROM CSKT    INTO TABLE INT_COSTC
                             WHERE SPRAS EQ SY-LANGU.
  SELECT * FROM T518B   INTO TABLE INT_QUALFI
                             WHERE LANGU EQ SY-LANGU.

ENDFORM.                    " PU_EXEUTIVES_PROM
*&---------------------------------------------------------------------*
*&      Form  PU_DATE_CONVERSION
*&---------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
FORM PU_DATE_CONVERSION  USING    INPUT_DATE    TYPE SY-DATUM
                         CHANGING OUTPUT_DATE   TYPE CHAR10.
  CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
    EXPORTING
      DATE_INTERNAL            = INPUT_DATE
    IMPORTING
      DATE_EXTERNAL            = OUTPUT_DATE
    EXCEPTIONS
      DATE_INTERNAL_IS_INVALID = 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.
ENDFORM.                    " PU_DATE_CONVERSION
*&---------------------------------------------------------------------*
*&      Form  PU_FINAL_TABLE
*&---------------------------------------------------------------------*
* Preparing final internal table for output to excel
*----------------------------------------------------------------------*
FORM PU_FINAL_TABLE .
  DATA : W_STR1(4)  TYPE N,
         W_STR2(4)  TYPE N,
         W_STR3(4)  TYPE N,
         W_EXSTR(4) TYPE N,
         W_ORSTR(4) TYPE N,
         W_INSTR(4) TYPE N,
         W_ONSTR(4) TYPE N,
         W_DISFLAG  TYPE CHAR1,
         W_INCFLAG  TYPE CHAR1.

  LOOP AT INT_OUTPUT.
    MOVE-CORRESPONDING INT_OUTPUT TO INT_EXCEL.
    LOOP AT INT_DISCACT WHERE PERNR = INT_OUTPUT-PERNR.
      IF SY-TABIX EQ 1.
        CONCATENATE INT_DISCACT-DESCRI
                     SPACE
                    INT_DISCACT-MDATE
               INTO W_DISCI.
        INT_EXCEL-DISCI = W_DISCI.
      ELSE.
        W_DISFLAG = 1.
      ENDIF.
    ENDLOOP.

    LOOP AT INT_INCRE WHERE PERNR = INT_OUTPUT-PERNR.

      INT_EXCEL-INCR1 =  INT_INCRE-INCR1.
      INT_EXCEL-INCR2 =  INT_INCRE-INCR2.
      INT_EXCEL-INCR3 =  INT_INCRE-INCR3.

    ENDLOOP.

    APPEND INT_EXCEL.
    CLEAR  INT_EXCEL.
    CLEAR : W_STR1,W_STR2,W_STR3.

    IF W_DISFLAG EQ 1.
      W_ORSTR = W_EXSTR.
      LOOP AT INT_DISCACT WHERE PERNR = INT_OUTPUT-PERNR.

        IF SY-TABIX NE 1.

          CONCATENATE INT_DISCACT-DESCRI
                       SPACE
                      INT_DISCACT-MDATE
                 INTO W_DISCI.
          INT_EXCEL-DISCI = W_DISCI.

          APPEND INT_EXCEL.
          CLEAR  INT_EXCEL.
          CLEAR : W_STR2,W_EXSTR.
        ENDIF.
      ENDLOOP.
    ENDIF.

  ENDLOOP.

ENDFORM.                    " PU_FINAL_TABLE
*&---------------------------------------------------------------------*
*&      Form  PU_GRID_DISPLAY
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM PU_GRID_DISPLAY .
  DATA W_GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

  PERFORM F_FIELDCAT_INIT USING 'IT_HEADER' W_GT_FIELDCAT[].

  IF INT_EXCEL[] IS NOT INITIAL.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        I_CALLBACK_PROGRAM = SY-CPROG
        IT_FIELDCAT        = W_GT_FIELDCAT[]
        IT_EVENTS          = EVENT[]
      TABLES
        T_OUTTAB           = INT_EXCEL
      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.
  ELSE.
    MESSAGE S011(ZHR).
    LEAVE LIST-PROCESSING.
  ENDIF.

ENDFORM.                    " PU_GRID_DISPLAY
*&---------------------------------------------------------------------*
*&      Form  F_FIELDCAT_INIT
*&---------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
FORM F_FIELDCAT_INIT USING IT_TABLE
                           LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
  DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'PERNR'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 14.
  LS_FIELDCAT-SELTEXT_L = 'Personnel Number'.
  LS_FIELDCAT-FIX_COLUMN = 'X'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'NAME'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 30.
  LS_FIELDCAT-SELTEXT_L    = 'Name'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'DESIG'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 25.
  LS_FIELDCAT-SELTEXT_L    = 'Desigination'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'PESUB'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 16.
  LS_FIELDCAT-SELTEXT_L    = 'Personnel Sub Area'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'ORGUN'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 25.
  LS_FIELDCAT-SELTEXT_L    = 'Organization Unit'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'COSTC'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 14.
  LS_FIELDCAT-SELTEXT_L    = 'Cost Center'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'ETHIC'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 6.
  LS_FIELDCAT-SELTEXT_L    = 'Ethic'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'CPCODE'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 7.
  LS_FIELDCAT-SELTEXT_L    = 'CPCode'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'GRADE'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    =  12.
  LS_FIELDCAT-SELTEXT_L    = 'Current Grade'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = '***'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 6.
  LS_FIELDCAT-SELTEXT_L    = 'Gender'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'DOB'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 11.
  LS_FIELDCAT-SELTEXT_L    = 'Date of Birth'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'DOJ'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 11.
  LS_FIELDCAT-SELTEXT_L    = 'Date of Join'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'QUAL1'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 13.
  LS_FIELDCAT-SELTEXT_L    = 'Qualification 1'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'QUAL2'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 13.
  LS_FIELDCAT-SELTEXT_L    = 'Qualification 2'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'QUAL3'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 13.
  LS_FIELDCAT-SELTEXT_L    = 'Qualification 3'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'QUAL4'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 13.
  LS_FIELDCAT-SELTEXT_L    = 'Qualification 4'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'QUAL5'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 13.
  LS_FIELDCAT-SELTEXT_L    = 'Qualification 5'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'LPROM'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 16.
  LS_FIELDCAT-SELTEXT_L    = 'Last Promotion Date'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'PROMD'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 16.
  LS_FIELDCAT-SELTEXT_L    = 'Promotion Due Date'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'PROMT'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 14.
  LS_FIELDCAT-SELTEXT_L    = 'Promotion Type'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'NOYRS'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 15.
  LS_FIELDCAT-SELTEXT_L    = 'Number of Years'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'AWL'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 22.
  LS_FIELDCAT-SELTEXT_L    = 'Absence Without Leave'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'LWP'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 22.
  LS_FIELDCAT-SELTEXT_L    = 'Leave Without Pay'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'APPR1'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 15.
  LS_FIELDCAT-SELTEXT_L    = 'Apprisal 1st'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'APPR2'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 15.
  LS_FIELDCAT-SELTEXT_L    = 'Apprisal 2nd'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'APPR3'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 15.
  LS_FIELDCAT-SELTEXT_L    = 'Apprisal 3rd'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'APPR4'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 15.
  LS_FIELDCAT-SELTEXT_L    = 'Apprisal 4th'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'APPR5'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 15.
  LS_FIELDCAT-SELTEXT_L    = 'Apprisal 5th'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'DISCI'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 60.
  LS_FIELDCAT-SELTEXT_L    = 'Disciplinary Actions - Date'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'INCR1'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 15.
  LS_FIELDCAT-SELTEXT_L    = '1st Increment'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'INCR2'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 15.
  LS_FIELDCAT-SELTEXT_L    = '2nd Increment'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-FIELDNAME    = 'INCR3'.
  LS_FIELDCAT-TABNAME      = INT_EXCEL.
  LS_FIELDCAT-OUTPUTLEN    = 15.
  LS_FIELDCAT-SELTEXT_L    = '3rd Increment'.
  APPEND LS_FIELDCAT TO LT_FIELDCAT.


ENDFORM.                    " F_FIELDCAT_INIT
*&---------------------------------------------------------------------*
*&      Form  PU_FREE_TABLES
*&---------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
FORM PU_FREE_TABLES .
  FREE :  INT_NONEXE  ,
          INT_OUTPUT  ,
          INT_DISCACT ,
          INT_QUALFI  ,
          INT_INCRE   ,
          INT_DISCIP  ,
          INT_PESUB   ,
          INT_COSTC   ,
          INT_EXCEL   ,
          EVENT       ,
          LISTHEAD    .
ENDFORM.                    " PU_FREE_TABLES

reward points if helpful

Edited by: mohammed abdul hai on Jul 25, 2008 7:21 PM

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question