employee summary report - sharathsym/SAP-Employee_summary GitHub Wiki
DATA: lv_plvar TYPE plvar,
lv_molga TYPE molga.
- Photo
- Get Active plan version
- Get Molga
- Get Org data
- Get Personal data
- Get Address
- Get Manager
- Get national ID
- Get Baisc pay & other wages
- Get education details
- Get Employer
- Get Qualifications
- Get Awards
- Get loan balance
- Get Kin
FORM get_award USING im_pernr TYPE pernr_d
lv_molga TYPE molga. DATA: lv_pskey TYPE pskey, lt_ptext TYPE TABLE OF ty_ptext, lt_i0183 TYPE TABLE OF p0183.
CALL FUNCTION 'HR_READ_INFOTYPE_AUTHC_DISABLE'. CALL FUNCTION 'HR_READ_INFOTYPE' EXPORTING pernr = im_pernr infty = '0183' TABLES infty_tab = lt_i0183. IF lt_i0183 IS NOT INITIAL. LOOP AT lt_i0183 ASSIGNING FIELD-SYMBOL(<fs_0183>). APPEND INITIAL LINE TO gt_award ASSIGNING FIELD-SYMBOL(<fs_award>). MOVE-CORRESPONDING <fs_0183> TO <fs_award>. SELECT SINGLE awdtx FROM t5r02 INTO <fs_award>-awdtx WHERE sprsl EQ sy-langu AND molga EQ lv_molga AND awdtp EQ <fs_0183>-awdtp. lv_pskey-pernr = im_pernr. lv_pskey-infty = '0183'. lv_pskey-endda = <fs_0183>-endda. lv_pskey-begda = <fs_0183>-begda. IMPORT ptext TO lt_ptext FROM DATABASE pcl1(tx) ID lv_pskey. LOOP AT lt_ptext ASSIGNING FIELD-SYMBOL(<fs_ptext>). <fs_award>-text1 = <fs_ptext>-line. IF sy-tabix GT 1. APPEND INITIAL LINE TO gt_award ASSIGNING <fs_award>. <fs_award>-text1 = <fs_ptext>-line. ENDIF. ENDLOOP. ENDLOOP. ENDIF.
ENDFORM. FORM get_qual USING im_pernr TYPE pernr_d
im_plvar TYPE plvar. DATA: lt_objct TYPE hrahq_hrsobid_table, lt_prof TYPE TABLE OF hrpe_ind_dev_plan, lt_qcat TYPE hap_t_q_profile.
APPEND INITIAL LINE TO lt_objct ASSIGNING FIELD-SYMBOL(<fs_objct>). <fs_objct>-plvar = im_plvar. <fs_objct>-otype = 'P'. <fs_objct>-sobid = im_pernr.
CALL FUNCTION 'BAPI_QUALIFIC_GETLIST' EXPORTING plvar = <fs_objct>-plvar otype = <fs_objct>-otype sobid = <fs_objct>-sobid TABLES qualificationprofile = lt_qcat.
gt_qual = lt_qcat.
CALL FUNCTION 'HR_READ_INFOTYPE_AUTHC_DISABLE'. CALL FUNCTION 'RHPQ_INDIVIDUAL_PLAN_READ' EXPORTING plvar = im_plvar begda = '19900101' TABLES persons = lt_objct pplans_tab = lt_prof EXCEPTIONS no_authority = 1 nothing_found = 2 OTHERS = 3. IF sy-subrc EQ 0. gt_dev = lt_prof. ENDIF.
ENDFORM. FORM get_employer USING im_pernr TYPE pernr_d.
DATA: lt_t005t TYPE TABLE OF t005t, lt_i0023 TYPE TABLE OF p0023.
CALL FUNCTION 'HR_READ_INFOTYPE_AUTHC_DISABLE'. CALL FUNCTION 'HR_READ_INFOTYPE' EXPORTING pernr = im_pernr infty = '0023' TABLES infty_tab = lt_i0023.
IF lt_i0023 IS NOT INITIAL. SELECT * FROM t005t APPENDING TABLE lt_t005t FOR ALL ENTRIES IN lt_i0023 WHERE spras EQ sy-langu AND land1 EQ lt_i0023-land1.
LOOP AT lt_i0023 ASSIGNING FIELD-SYMBOL(<fs_0023>). APPEND INITIAL LINE TO gt_employer ASSIGNING FIELD-SYMBOL(<fs_emp>). MOVE-CORRESPONDING <fs_0023> TO <fs_emp>. READ TABLE lt_t005t ASSIGNING FIELD-SYMBOL(<fs_t005t>) WITH KEY land1 = <fs_0023>-land1. IF sy-subrc EQ 0. <fs_emp>-landx = <fs_t005t>-landx. ENDIF. ENDLOOP. ENDIF.
ENDFORM. FORM get_address USING im_pernr TYPE pernr_d.
DATA lt_p0006 TYPE p0006_tab. DATA lv_landx TYPE t005t-landx. DATA ls_p0006 TYPE p0006.
CALL FUNCTION 'HR_READ_INFOTYPE_AUTHC_DISABLE'. CALL FUNCTION 'HR_READ_INFOTYPE' EXPORTING pernr = im_pernr infty = '0006' begda = sy-datum endda = sy-datum TABLES infty_tab = lt_p0006.
READ TABLE lt_p0006 INTO ls_p0006 INDEX 1. IF sy-subrc EQ 0. IF ls_p0006-locat IS NOT INITIAL. CONCATENATE ls_p0006-locat ',' INTO ls_p0006-locat. ENDIF. IF ls_p0006-stras IS NOT INITIAL. CONCATENATE ls_p0006-stras ',' INTO ls_p0006-stras. ENDIF. IF ls_p0006-ort01 IS NOT INITIAL. CONCATENATE ls_p0006-ort01 ',' INTO ls_p0006-ort01. ENDIF. CONCATENATE ls_p0006-locat ls_p0006-stras ls_p0006-ort01 INTO gv_addr SEPARATED BY space. IF ls_p0006-land1 IS NOT INITIAL. SELECT SINGLE landx FROM t005t INTO lv_landx WHERE spras EQ sy-langu AND land1 EQ ls_p0006-land1. IF sy-subrc EQ 0. lv_landx = lv_landx && '.'. CONCATENATE gv_addr lv_landx INTO gv_addr SEPARATED BY space. ENDIF. ENDIF. IF ls_p0006-telnr IS NOT INITIAL. CONCATENATE gv_addr 'Telephone Number:' ls_p0006-telnr INTO gv_addr SEPARATED BY space. ENDIF. ENDIF.
ENDFORM. FORM get_mgr USING im_pernr TYPE pernr_d
im_plvar TYPE plvar CHANGING lv_mgr TYPE emnam.
DATA: lv_objid TYPE realo, lv_pernr TYPE pernr_d.
CALL FUNCTION 'HR_READ_INFOTYPE_AUTHC_DISABLE'. lv_objid = im_pernr. CALL FUNCTION 'RH_GET_LEADER' EXPORTING plvar = im_plvar keydate = sy-datum otype = 'P' objid = lv_objid IMPORTING leader_id = lv_objid EXCEPTIONS no_leader_found = 1 no_leading_position_found = 2 OTHERS = 3. IF sy-subrc EQ 0. lv_pernr = lv_objid. CALL FUNCTION 'HR_TMW_GET_EMPLOYEE_NAME' EXPORTING person_no = lv_pernr IMPORTING edit_name = lv_mgr. ENDIF.
ENDFORM. FORM get_id USING im_pernr TYPE pernr_d
im_molga TYPE molga CHANGING lv_ictxt TYPE ictxt lv_idnum TYPE psg_idnum lv_dpass TYPE psg_idnum. DATA: lt_i0185 TYPE TABLE OF p0185, ls_i0185 TYPE p0185, lt_t5r06 TYPE TABLE OF t5r06.
CALL FUNCTION 'HR_READ_INFOTYPE_AUTHC_DISABLE'. CALL FUNCTION 'HR_READ_INFOTYPE' EXPORTING pernr = im_pernr infty = '0185' TABLES infty_tab = lt_i0185.
LOOP AT lt_i0185 INTO ls_i0185. CASE ls_i0185-ictyp. WHEN '08'. lv_dpass = ls_i0185-icnum. WHEN '02'. SELECT SINGLE ictxt FROM t5r06 INTO lv_ictxt WHERE sprsl EQ sy-langu AND molga EQ im_molga AND ictyp EQ ls_i0185-ictyp. IF sy-subrc EQ 0. lv_ictxt = lv_ictxt && ':'. ENDIF. lv_idnum = ls_i0185-icnum. WHEN OTHERS. ENDCASE. ENDLOOP. IF lv_ictxt IS INITIAL. lv_ictxt = 'National Passport:'. ENDIF.
ENDFORM. FORM get_002 USING im_pernr TYPE pernr_d.
DATA: lt_i0002 TYPE TABLE OF p0002.
CALL FUNCTION 'HR_READ_INFOTYPE_AUTHC_DISABLE'. CALL FUNCTION 'HR_READ_INFOTYPE' EXPORTING pernr = im_pernr infty = '0002' TABLES infty_tab = lt_i0002. READ TABLE lt_i0002 INTO gs_p0002 INDEX 1. IF sy-subrc EQ 0. SELECT SINGLE ftext FROM t502t INTO gv_marr_stat WHERE sprsl EQ sy-langu AND famst EQ gs_p0002-famst.
SELECT SINGLE landx FROM t005t INTO gv_cob WHERE spras EQ sy-langu AND land1 EQ gs_p0002-gblnd.
SELECT SINGLE landx FROM t005t INTO gv_natio WHERE spras EQ sy-langu AND land1 EQ gs_p0002-natio.
ENDIF.
ENDFORM. FORM get_001 TABLES lt_001 TYPE tt_001
USING lv_molga TYPE molga im_pernr TYPE pernr_d. TYPES: BEGIN OF ty_orgeh, objid TYPE hrp1000-objid, stext TYPE hrp1000-stext, END OF ty_orgeh.
DATA: li_orgeh TYPE TABLE OF ty_orgeh WITH KEY objid, lt_i0008 TYPE TABLE OF p0008, lt_pa001 TYPE p0001_tab, li_cskt TYPE TABLE OF cskt WITH KEY kokrs kostl, lv_plvar TYPE plvar. FIELD-SYMBOLS: <fs_001> TYPE ty_001.
CALL FUNCTION 'HR_READ_INFOTYPE_AUTHC_DISABLE'. CALL FUNCTION 'HR_READ_INFOTYPE' EXPORTING pernr = im_pernr infty = '0001' TABLES infty_tab = lt_pa001.
CHECK lt_pa001[] IS NOT INITIAL.
CALL FUNCTION 'HR_READ_INFOTYPE_AUTHC_DISABLE'. CALL FUNCTION 'HR_READ_INFOTYPE' EXPORTING pernr = im_pernr infty = '0008' TABLES infty_tab = lt_i0008.
SELECT * FROM cskt INTO TABLE li_cskt FOR ALL ENTRIES IN lt_pa001 WHERE spras EQ sy-langu AND kokrs EQ lt_pa001-bukrs AND kostl EQ lt_pa001-kostl.
cl_hap_generic=>get_active_plan_version( IMPORTING plan_version = lv_plvar ).
SELECT objid stext FROM hrp1000 INTO TABLE li_orgeh FOR ALL ENTRIES IN lt_pa001 WHERE plvar EQ lv_plvar AND otype EQ 'O' AND objid EQ lt_pa001-orgeh.
SORT lt_i0008 DESCENDING. LOOP AT lt_i0008 ASSIGNING FIELD-SYMBOL(<fs_p0008>).
IF <fs_001> IS ASSIGNED. IF <fs_001>-TRFGR EQ <fs_p0008>-trfgr AND <fs_p0008>-trfst EQ <fs_001>-TRFST. <fs_001>-begda = <fs_p0008>-begda. ELSE. APPEND INITIAL LINE TO lt_001 ASSIGNING <fs_001>. MOVE-CORRESPONDING <fs_p0008> TO <fs_001>. ENDIF. ELSE. APPEND INITIAL LINE TO lt_001 ASSIGNING <fs_001>. MOVE-CORRESPONDING <fs_p0008> TO <fs_001>. ENDIF.
LOOP AT lt_pa001 INTO gs_p0001 WHERE endda GE <fs_p0008>-endda AND begda LE <fs_p0008>-begda. EXIT. ENDLOOP.
READ TABLE li_cskt ASSIGNING FIELD-SYMBOL(<fs_cskt>) WITH TABLE KEY kokrs = gs_p0001-bukrs kostl = gs_p0001-kostl. IF sy-subrc EQ 0. <fs_001>-ktext = <fs_cskt>-ltext. ENDIF.
READ TABLE li_orgeh ASSIGNING FIELD-SYMBOL(<fs_t527x>) WITH TABLE KEY objid = gs_p0001-orgeh. IF sy-subrc EQ 0. gv_dept = <fs_001>-orgtx = <fs_t527x>-stext. ENDIF.
IF gs_p0001-begda LE sy-datum AND gs_p0001-endda GE sy-datum. SELECT SINGLE name1 FROM t500p INTO gv_persa WHERE persa EQ gs_p0001-werks AND molga EQ lv_molga AND bukrs EQ gs_p0001-kokrs.
SELECT SINGLE stext FROM hrp1000 INTO gv_plans WHERE plvar EQ lv_plvar AND otype EQ 'S' AND objid EQ gs_p0001-plans AND begda LE sy-datum AND endda GE sy-datum AND langu EQ sy-langu. ENDIF. CLEAR gs_p0001. ENDLOOP. READ TABLE lt_pa001 INTO gs_p0001 INDEX 1.
ENDFORM. FORM get_molga USING im_pernr TYPE pernr_d
CHANGING im_molga TYPE molga.
CALL FUNCTION 'HR_READ_INFOTYPE_AUTHC_DISABLE'. CALL FUNCTION 'RH_PM_GET_MOLGA_FROM_PERNR' EXPORTING pernr = im_pernr IMPORTING molga = im_molga EXCEPTIONS nothing_found = 1 no_active_plvar = 2 OTHERS = 3. IF sy-subrc <> 0.
- Implement suitable error handling here
ENDIF.
ENDFORM. FORM get_photo USING im_pernr TYPE pernr_d.
- Photo
CALL FUNCTION 'HRWPC_RFC_EP_READ_PHOTO_URI' EXPORTING pernr = im_pernr datum = sy-datlo
- TCLAS = 'A'
IMPORTING uri = gv_url EXCEPTIONS not_supported = 1 nothing_found = 2 no_authorization = 3 internal_error = 4 OTHERS = 5. IF sy-subrc NE 0. gv_url = 'https://upload.wikimedia.org/wikipedia/commons/d/d6/Nophoto.jpg'. ENDIF.
ENDFORM. FORM get_basic_pay USING im_pernr TYPE pernr_d.
DATA: lt_wages TYPE TABLE OF bapip0008p, lv_curr TYPE waers, lt_i0008 TYPE TABLE OF p0008.
CALL FUNCTION 'HR_READ_INFOTYPE_AUTHC_DISABLE'. CALL FUNCTION 'HR_READ_INFOTYPE' EXPORTING pernr = im_pernr infty = '0008' TABLES infty_tab = lt_i0008. CHECK lt_i0008 IS NOT INITIAL. READ TABLE lt_i0008 INTO gs_p0008 INDEX lines( lt_i0008 ). CHECK sy-subrc EQ 0. CALL FUNCTION 'HR_READ_INFOTYPE_AUTHC_DISABLE'. CALL FUNCTION 'BAPI_BASICPAY_GETDETAIL' EXPORTING employeenumber = gs_p0008-pernr subtype = gs_p0008-subty objectid = gs_p0008-objps lockindicator = gs_p0008-sprps validitybegin = gs_p0008-begda validityend = gs_p0008-endda recordnumber = gs_p0008-seqnr IMPORTING currency = lv_curr TABLES wagetypes = lt_wages.
DELETE lt_wages WHERE wagetype = '0901'.
LOOP AT lt_wages ASSIGNING FIELD-SYMBOL(<fs_wages>). IF lv_curr NE 'USD'. CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY' EXPORTING
- CLIENT = SY-MANDT
date = sy-datum foreign_amount = <fs_wages>-amount foreign_currency = lv_curr local_currency = 'USD'
- RATE = 0
- TYPE_OF_RATE = 'M'
- READ_TCURR = 'X'
IMPORTING local_amount = <fs_wages>-amount EXCEPTIONS no_rate_found = 1 overflow = 2 no_factors_found = 3 no_spread_found = 4 derived_2_times = 5 OTHERS = 6. IF sy-subrc <> 0.
- Implement suitable error handling here
ENDIF. ENDIF. IF <fs_wages>-wagetype(2) EQ '05'. CONTINUE. ENDIF. COLLECT <fs_wages> INTO gt_wages. ENDLOOP.
ENDFORM. FORM get_edu USING im_pernr TYPE pernr_d.
DATA: lt_i0022 TYPE TABLE OF p0022, lt_t517t TYPE TABLE OF t517t, lt_t005t TYPE TABLE OF t005t, lt_t538t TYPE TABLE OF t538t, lt_t519t TYPE TABLE OF t519t.
CALL FUNCTION 'HR_READ_INFOTYPE_AUTHC_DISABLE'. CALL FUNCTION 'HR_READ_INFOTYPE' EXPORTING pernr = im_pernr infty = '0022' TABLES infty_tab = lt_i0022.
SORT lt_i0022 DESCENDING. IF lt_i0022 IS NOT INITIAL.
SELECT * FROM t517t INTO TABLE lt_t517t FOR ALL ENTRIES IN lt_i0022 WHERE sprsl EQ sy-langu AND slart EQ lt_i0022-slart.
SELECT * FROM t005t INTO TABLE lt_t005t FOR ALL ENTRIES IN lt_i0022 WHERE spras EQ sy-langu AND land1 EQ lt_i0022-sland.
SELECT * FROM t519t INTO TABLE lt_t519t FOR ALL ENTRIES IN lt_i0022 WHERE sprsl EQ sy-langu AND slabs EQ lt_i0022-slabs.
SELECT * FROM t538t INTO TABLE lt_t538t FOR ALL ENTRIES IN lt_i0022 WHERE sprsl EQ sy-langu AND zeinh EQ lt_i0022-anzeh. ENDIF.
LOOP AT lt_i0022 ASSIGNING FIELD-SYMBOL(<fs_0022>). APPEND INITIAL LINE TO gt_edu ASSIGNING FIELD-SYMBOL(<fs_edu>). MOVE-CORRESPONDING <fs_0022> TO <fs_edu>. READ TABLE lt_t538t ASSIGNING FIELD-SYMBOL(<fs_t538t>) WITH KEY zeinh = <fs_0022>-anzeh. IF sy-subrc EQ 0. <fs_edu>-etext = <fs_t538t>-etext. ENDIF. READ TABLE lt_t519t ASSIGNING FIELD-SYMBOL(<fs_t519t>) WITH KEY slabs = <fs_0022>-slabs. IF sy-subrc EQ 0. <fs_edu>-satxt = <fs_t519t>-stext. ENDIF. READ TABLE lt_t517t ASSIGNING FIELD-SYMBOL(<fs_t517t>) WITH KEY slart = <fs_0022>-slart. IF sy-subrc EQ 0. <fs_edu>-stext = <fs_t517t>-stext. ENDIF. READ TABLE lt_t005t ASSIGNING FIELD-SYMBOL(<fs_t005t>) WITH KEY land1 = <fs_0022>-sland. IF sy-subrc EQ 0. <fs_edu>-landx = <fs_t005t>-landx. ENDIF. ENDLOOP.
ENDFORM. FORM loan_bal USING im_pernr TYPE pernr_d.
DATA(lo_loan) = NEW zcl_assist_loan_req( ). CALL METHOD lo_loan->get_outstanding_loan EXPORTING im_pernr = im_pernr IMPORTING ex_outstand = DATA(li_loan). CHECK li_loan IS NOT INITIAL. READ TABLE li_loan ASSIGNING FIELD-SYMBOL(<fs_loan>) INDEX lines( li_loan ). IF sy-subrc EQ 0. gv_loan = <fs_loan>-bal_amt. ENDIF.
ENDFORM. FORM get_kin USING im_pernr TYPE pernr_d.
DATA: lv_subty TYPE subty VALUE '7', ls_p0021 TYPE p0021, lv_objps TYPE objps.
CALL FUNCTION 'HR_READ_INFOTYPE_AUTHC_DISABLE'. CALL FUNCTION 'HRMGE_GET_DEPENDANT_INFO' EXPORTING pernr = im_pernr subty = lv_subty objps = lv_objps IMPORTING p0021 = ls_p0021. CONCATENATE ls_p0021-favor ls_p0021-fanam INTO gv_kin SEPARATED BY space.
ENDFORM. FORM get_plvar CHANGING ex_plvar TYPE plvar.
DATA : lv_plvar TYPE plvar. cl_hap_generic=>get_active_plan_version( IMPORTING plan_version = lv_plvar ). ex_plvar = lv_plvar.
ENDFORM.