SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Get employee data



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> HR
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Fri Apr 11, 2008 11:39 pm    Post subject: Get employee data Reply with quote

Code:
REPORT ZPS_GET_EMPLOYEE_DATA .

***********************************************************************
* This report displays the employee fact sheet developed for the
* Public Sector HRIC functionality Demo using CRM. The report displays
* a predefined set of field values from various infotypes on a screen.
* All infotypes are read using the RH_GET_INFTY_NNNN function call to
* preserve authority checking. If no data exists or no authority to
* view the data the output will contain blanks.
***********************************************************************
* Creation date: 17.03.2002
* Created by: Neil Missig
***********************************************************************
* Last Changed date:
* Changed by:
* Reason:
***********************************************************************
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*
* INCLUDES
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*

include <LIST>.
include <icon>.

*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*
* MACROS Section
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*
DEFINE GETDATA.

  CALL FUNCTION 'RH_READ_INFTY_NNNN'
    EXPORTING
     AUTHORITY                   = 'DISP'
     WITH_STRU_AUTH              = 'X'
     INFTY                       = &1
*   ISTAT                       = ' '
*   EXTEND                      = 'X'
     SUBTY                       = &2
     BEGDA                       = SELDAT
     ENDDA                       = SELDAT
*   CONDITION                   = '00000'
*   INFTB                       = '1'
*   SORT                        = 'X'
    TABLES
      INNNN                       = &3
      OBJECTS                     = SELPER
   EXCEPTIONS
     NOTHING_FOUND               = 1
     WRONG_CONDITION             = 2
     INFOTYP_NOT_SUPPORTED       = 3
     OTHERS                      = 4
            .
  SUBRC = SY-SUBRC.
  IF SY-SUBRC <> 0.

  ENDIF.

END-OF-DEFINITION.

*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*
* DATA Section
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*

constants SPOUSE TYPE PA0021-FAMSA VALUE '1'.
constants HOMEADDR TYPE PA0006-SUBTY VALUE '1'.
constants EMAIL TYPE PA0105-SUBTY VALUE '0010'.
DATA: SUBRC like sy-subrc.

DATA: I0000 type p0000 occurs 0 with header line.
DATA: I0001 type p0001 occurs 0 with header line.
DATA: I0002 type p0002 occurs 0 with header line.
DATA: I0006 type p0006 occurs 0 with header line.
DATA: I0021 type p0021 occurs 0 with header line.
DATA: I0041 type p0041 occurs 0 with header line.
DATA: I0105 type p0105 occurs 0 with header line.
DATA: I0167 type p0167 occurs 0 with header line.
DATA: I0171 type p0171 occurs 0 with header line.
DATA: SELPER type HROBJECT occurs 0 with header line.

DATA: BEGIN OF IPERDATA,
        PERNR TYPE PA0002-PERNR,
        NACHN TYPE PA0002-NACHN,
        VORNA TYPE PA0002-VORNA,
        GESCH TYPE PA0002-GESCH,
        GBDAT TYPE PA0002-GBDAT,
        FAMST TYPE PA0002-FAMST,
        PERID TYPE PA0002-PERID,
        FGBDT TYPE PA0021-FGBDT,
        FAVOR TYPE PA0021-FAVOR,
        FANAM TYPE PA0021-FANAM,
        NAME2 TYPE PA0006-NAME2,
        STRAS TYPE PA0006-STRAS,
        ORT01 TYPE PA0006-ORT01,
        ORT02 TYPE PA0006-ORT02,
        LAND1 TYPE PA0006-LAND1,
        PSTLZ TYPE PA0006-PSTLZ,
        TELNR TYPE PA0006-TELNR,
        LOCAT TYPE PA0006-LOCAT,
        STATE TYPE PA0006-STATE,
        USRID_LONG TYPE PA0105-USRID_LONG,
      END OF IPERDATA.

DATA: BEGIN OF IEMPDATA,
        PERNR TYPE PA0000-PERNR,
        STAT2 TYPE PA0000-STAT2,
        DAT01 TYPE PA0041-DAT01,
        DAT02 TYPE PA0041-DAT02,
        BUKRS TYPE PA0001-BUKRS,
        WERKS TYPE PA0001-WERKS,
        PERSG TYPE PA0001-PERSG,
        PERSK TYPE PA0001-PERSK,
        BTRTL TYPE PA0001-BTRTL,
        ABKRS TYPE PA0001-ABKRS,
        ANSVH TYPE PA0001-ANSVH,
        KOSTL TYPE PA0001-KOSTL,
        ORGEH TYPE PA0001-ORGEH,
        PLANS TYPE PA0001-PLANS,
        STELL TYPE PA0001-STELL,
        ORGTX TYPE P1000-STEXT,
        PLSTX TYPE P1000-STEXT,
        STLTX TYPE P1000-STEXT,
        BAREA TYPE PA0171-BAREA,
        BENGR TYPE PA0171-BENGR,
        BSTAT TYPE PA0171-BSTAT,
        DEPCV TYPE PA0167-DEPCV,
      END OF IEMPDATA.
DATA: BEGIN OF DATETYPES,
        DAR LIKE P0041-DAR01,
        DAT LIKE P0041-DAT01,
      END OF DATETYPES.

DATA OK_CODE like sy-ucomm.
DATA SAVE_OK like sy-ucomm.

*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*
* Selection Screen
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*

selection-screen begin of block A1 with frame title TEXT-A01.
parameters tpernr like pa0000-pernr memory id PER.
selection-screen end of block A1.
Selection-screen begin of block A2 with frame title TEXT-A02.
parameters seldat like pa0000-endda default sy-datum.
parameters plang like hrp1000-langu default sy-langu.

parameters: hirdt like pa0041-dar01 default '40',
            vacdt like pa0041-dar01 default 'A3'.
selection-screen end of block A2.

*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*
* START-OF-SELECTION
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*

start-of-selection.

  SELPER-plvar = '01'.
  SELPER-otype = 'P'.
  SELPER-OBJID = tpernr.
  append selper.

  GETDATA '0002' '' I0002.
  if subrc = 0.
    read table I0002 index 1.
    IPERDATA-NACHN = I0002-NACHN.
    IPERDATA-VORNA = I0002-VORNA.
    IPERDATA-GESCH = I0002-GESCH.
    IPERDATA-GBDAT = I0002-GBDAT.
    IPERDATA-FAMST = I0002-FAMST.
    IPERDATA-PERID = I0002-PERID.
  endif.

  GETDATA '0021' SPOUSE I0021.
  if subrc = 0.
    read table I0021 with key FAMSA = SPOUSE.
    if sy-subrc = 0.
      IPERDATA-FGBDT = I0021-FGBDT.
      IPERDATA-FAVOR = I0021-FAVOR.
      IPERDATA-FANAM = I0021-FANAM.
    endif.
  endif.

  GETDATA '0006' HOMEADDR I0006.
  if subrc = 0.
    read table I0006 with key SUBTY = HOMEADDR.
    if sy-subrc = 0.
      IPERDATA-STRAS = I0006-STRAS.
      IPERDATA-ORT01 = I0006-ORT01.
      IPERDATA-LAND1 = I0006-LAND1.
      IPERDATA-TELNR = I0006-TELNR.
      IPERDATA-LOCAT = I0006-LOCAT.
      IPERDATA-STATE = I0006-STATE.
      IPERDATA-PSTLZ = I0006-PSTLZ.
    endif.
  endif.

  GETDATA '0105' EMAIL I0105.
  if subrc = 0.
    read table I0105 with key SUBTY = EMAIL.
    if sy-subrc = 0.
      IPERDATA-USRID_LONG = I0105-USRID_LONG.
    endif.
  endif.

  GETDATA '0171' '' I0171.
  if subrc = 0.
    read table I0171 index 1.
    IEMPDATA-BAREA = I0171-BAREA.
    IEMPDATA-BENGR = I0171-BENGR.
    IEMPDATA-BSTAT = I0171-BSTAT.
  endif.

  GETDATA '0167' '' I0167.
  if subrc = 0.
    read table I0167 index 1.
    IEMPDATA-DEPCV = I0167-DEPCV.
  endif.

  GETDATA '0000' '' I0000.
  if subrc = 0.
    read table I0000 index 1.
    IEMPDATA-STAT2 = I0000-STAT2.
  endif.

  GETDATA '0001' '' I0001.
  if subrc = 0.
    read table I0001 index 1.
    IEMPDATA-BUKRS = I0001-BUKRS.
    IEMPDATA-WERKS = I0001-WERKS.
    IEMPDATA-PERSG = I0001-PERSG.
    IEMPDATA-PERSK = I0001-PERSK.
    IEMPDATA-BTRTL = I0001-BTRTL.
    IEMPDATA-ABKRS = I0001-ABKRS.
    IEMPDATA-ANSVH = I0001-ANSVH.
    IEMPDATA-KOSTL = I0001-KOSTL.
    IEMPDATA-ORGEH = I0001-ORGEH.
    IEMPDATA-PLANS = I0001-PLANS.
    IEMPDATA-STELL = I0001-STELL.

    select single stext from hrp1000
         into iempdata-orgtx
         where plvar = '01'
           and otype = 'O'
           and objid = iempdata-orgeh
           and langu = plang
           and begda le seldat
           and endda ge seldat.

    select single stext from hrp1000
         into iempdata-plstx
         where plvar = '01'
           and otype = 'S'
           and objid = iempdata-plans
           and langu = plang
           and begda le seldat
           and endda ge seldat.

    select single stext from hrp1000
         into iempdata-stltx
         where plvar = '01'
           and otype = 'C'
           and objid = iempdata-stell
           and langu = plang
           and begda le seldat
           and endda ge seldat.
  endif.

  GETDATA '0041' '' I0041.
  if subrc = 0.
    read table I0041 index 1.
    DO 12 TIMES VARYING DATETYPES
      FROM I0041-DAR01
      NEXT I0041-DAR02.
      IF DATETYPES-DAR = HIRDT.
        IEMPDATA-DAT01 = DATETYPES-DAT.
        EXIT.
      ENDIF.
    ENDDO.
    DO 12 TIMES VARYING DATETYPES
      FROM I0041-DAR01
      NEXT I0041-DAR02.
      IF DATETYPES-DAR = VACDT.
        IEMPDATA-DAT02 = DATETYPES-DAT.
        EXIT.
      ENDIF.
    ENDDO.
  endif.
end-of-selection.

perform screen_out.

*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*
* FORMS Section
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*

*&---------------------------------------------------------------------*
*&      Form  screen_out
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM screen_out.
  call screen 500.
ENDFORM.                    " screen_out

*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*
* MODULES Section
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0500  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0500 INPUT.
  SAVE_OK = OK_CODE.
  CASE OK_CODE.
    WHEN 'BACK'.
      SET SCREEN 0.
      LEAVE SCREEN.
    WHEN 'EXIT'.
      SET SCREEN 0.
      LEAVE SCREEN.
    WHEN 'CANCEL'.
      SET SCREEN 0.
      LEAVE SCREEN.
  ENDCASE.
ENDMODULE.                 " USER_COMMAND_0500  INPUT
*&---------------------------------------------------------------------*
*&      Module  EXIT  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE EXIT INPUT.
  SET SCREEN 0.
  LEAVE SCREEN..
ENDMODULE.                 " EXIT  INPUT
*&---------------------------------------------------------------------*
*&      Module  STATUS_0500  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_0500 OUTPUT.
  SET PF-STATUS 'FACTSHT'.
*  SET TITLEBAR 'xxx'.
  CLEAR OK_CODE.

ENDMODULE.                 " STATUS_0500  OUTPUT

*Text elements
*----------------------------------------------------------
* A01 Mandatory parameter:
* A02 Optional parameters:


*Selection texts
*----------------------------------------------------------
* HIRDT         Hire Date Type Code in IT0041
* PLANG         Language.
* SELDAT         Selection Date
* TPERNR         Employee Number
* VACDT         Vac. Date Type Code in IT0041



screen_0500.txt
 Description:
Screen 500

Download
 Filename:  screen_0500.txt
 Filesize:  8.75 KB
 Downloaded:  1930 Time(s)

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> HR All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
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.