Yk HCM Personnel Profile

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 11

*&---------------------------------------------------------------------*

*& Report YK_HCM_PERSONNEL_PROFILE


*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT YK_HCM_PERSONNEL_PROFILE.
*&---------------------------------------------------------------------*
*& Infotypes
*&---------------------------------------------------------------------*
INFOTYPES: 0001,
0002,
0021,
0022,
0023,
0041,
0185,
0529,
0534.
TYPES: BEGIN OF TS_PINFO,
PERNR TYPE PA0002-PERNR,
NAME TYPE ZHR_NAME,
"Name
GESCH TYPE PA0002-GESCH, "Gender
GBDAT TYPE PA0002-GBDAT, "Date of Birth
GBORT TYPE PA0002-GBORT, "Birthplace
PTEXT TYPE T7CN5R-PTEXT, "Political status
LTEXT TYPE T505S-LTEXT,
"Ethnic group
WORK TYPE ZHR_WORK,
"work time
CONGYE TYPE ZHR_CONGYE,
"congye
STEXT TYPE T519T-STEXT,
"Certificate
MAJOR TYPE ZHR_MAJOR,
"school & major
IDCARD TYPE PA0185-ICNUM, "ID Card
PASSPORT TYPE PA0185-ICNUM,"Passport
STLTX TYPE T513S-STLTX,
"Job
ORGTX TYPE T527X-ORGTX,
"Organizational Unit
LEADER TYPE ZHR_LEADER,
"leader
END OF TS_PINFO.
TYPES: BEGIN OF TS_FAMILY,
SUBTY TYPE PA0021-SUBTY,
GUANXI TYPE T591S-STEXT,
FANAM TYPE PA0021-FANAM,
FAVOR TYPE PA0021-FAVOR,
NAME TYPE ZHR_NAME,
FGBDT TYPE PA0021-FGBDT,
AGE
TYPE ZHR_AGE,
FANAT TYPE PA0021-FANAT,
NATION TYPE NATIO50,
FGBOT TYPE PA0021-FGBOT,
END OF TS_FAMILY.

"Subtype
"Relation
"Last Name
"First Name
"Name
"Date of Birth
"Age
"Nationality
"Nationality
"job

TYPES: BEGIN OF TS_CV,


ARBGB TYPE PA0023-ARBGB,
BEGDA TYPE PA0023-BEGDA,
ENDDA TYPE PA0023-ENDDA,
TAETE TYPE PA0023-TAETE,

"employer
"begin date
"end date
"job

LTEXT TYPE T513C-LTEXT,


END OF TS_CV.
DATA:
DATA:
DATA:
DATA:
DATA:

GS_PINFO
GT_FAMILY
GS_FAMILY
GT_CV
GS_CV

TYPE
TYPE
LIKE
TYPE
LIKE

"job text

TS_PINFO.
TABLE OF TS_FAMILY.
LINE OF GT_FAMILY.
TABLE OF TS_CV.
LINE OF GT_CV.

CONSTANTS: G_TIME TYPE T VALUE '000000'.


*&---------------------------------------------------------------------*
*& Selection screen
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK BK1 WITH FRAME.
*Personnel
PARAMETER: P_PERNR TYPE PA0001-PERNR OBLIGATORY.
SELECTION-SCREEN END OF BLOCK BK1.
*----------------------------------------------------------------------*
* START-OF-SELECTION
*----------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM GET_INFO.
PERFORM PRINT_OUT.
*&---------------------------------------------------------------------*
*&
Form GET_INFO
*&---------------------------------------------------------------------*
*
Get personnel info.
*----------------------------------------------------------------------*
FORM GET_INFO .
perform get_pa0002.
perform get_pa0534.
perform get_pa0529.
perform get_pa0041.
perform get_pa0022.
perform get_pa0185.
perform get_pa0001.
perform get_leader.
perform get_pa0023.
perform get_pa0021.
ENDFORM.
" GET_INFO
*&---------------------------------------------------------------------*
*&
Form GET_PA0002
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM GET_PA0002 .
DATA: L_NACHN TYPE PA0002-NACHN,
L_VORNA TYPE PA0002-VORNA.
SELECT single
PERNR
NACHN
VORNA
GBORT
GBDAT
GESCH
INTO (GS_PINFO-PERNR,
L_NACHN,

"personnel no.
"Last Name
"First Name
"Birthplace
"Date of Birth
"Gender Key

FROM
WHERE
AND
AND

L_VORNA,
GS_PINFO-GBORT,
GS_PINFO-GBDAT,
GS_PINFO-GESCH)
PA0002
PERNR = P_PERNR
BEGDA <= SY-DATUM
ENDDA >= SY-DATUM.

CONCATENATE L_NACHN L_VORNA INTO GS_PINFO-NAME SEPARATED BY SPACE.


ENDFORM.
" GET_PA0001
*&---------------------------------------------------------------------*
*&
Form GET_PA0534
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM GET_PA0534 .
DATA: L_PCODE TYPE PA0534-PCODE.
SELECT
INTO
FROM
WHERE
AND
AND

SINGLE PCODE
L_PCODE
PA0534
PERNR = P_PERNR
BEGDA <= SY-DATUM
ENDDA >= SY-DATUM.

SELECT
INTO
FROM
WHERE
AND

SINGLE PTEXT
GS_PINFO-PTEXT
T7CN5R
PCODE = L_PCODE
LANGU = SY-LANGU.

"Political status

ENDFORM.
" GET_PA0534
*&---------------------------------------------------------------------*
*&
Form GET_PA0529
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM GET_PA0529 .
DATA: L_RACKY TYPE PA0529-RACKY.
SELECT
INTO
FROM
WHERE
AND
AND

SINGLE RACKY
L_RACKY
PA0529
PERNR = P_PERNR
BEGDA <= SY-DATUM
ENDDA >= SY-DATUM.

SELECT
INTO
FROM
WHERE
AND
AND

SINGLE LTEXT
GS_PINFO-LTEXT
T505S
RACKY = L_RACKY
MOLGA = '28'
SPRSL = SY-LANGU.

"Ethnic group

ENDFORM.
" GET_PA0529
*&---------------------------------------------------------------------*

*&
Form GET_PA0041
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM GET_PA0041 .
DATA:
DATA:
DATA:
DATA:
DATA:
SELECT
INTO
FROM
WHERE

LS_PA0041 TYPE PA0041.


L_TIME_WORK TYPE DATUM.
L_TIME_CONGYE TYPE DATUM.
L_TIME_1 TYPE TVRO-FAHZTD.
L_TIME_2 TYPE TVRO-FAHZTD.
SINGLE *
LS_PA0041
PA0041
PERNR = P_PERNR.

IF LS_PA0041-DAR01 = 'D2'.
L_TIME_WORK = LS_PA0041-DAT01.
ELSEIF LS_PA0041-DAR01 = 'D4'.
L_TIME_CONGYE = LS_PA0041-DAT01.
ENDIF.
IF LS_PA0041-DAR02 = 'D2'.
L_TIME_WORK = LS_PA0041-DAT02.
ELSEIF LS_PA0041-DAR02 = 'D4'.
L_TIME_CONGYE = LS_PA0041-DAT02.
ENDIF.
IF LS_PA0041-DAR03 = 'D2'.
L_TIME_WORK = LS_PA0041-DAT03.
ELSEIF LS_PA0041-DAR03 = 'D4'.
L_TIME_CONGYE = LS_PA0041-DAT03.
ENDIF.
IF LS_PA0041-DAR04 = 'D2'.
L_TIME_WORK = LS_PA0041-DAT04.
ELSEIF LS_PA0041-DAR04 = 'D4'.
L_TIME_CONGYE = LS_PA0041-DAT04.
ENDIF.
IF LS_PA0041-DAR05 = 'D2'.
L_TIME_WORK = LS_PA0041-DAT05.
ELSEIF LS_PA0041-DAR05 = 'D4'.
L_TIME_CONGYE = LS_PA0041-DAT05.
ENDIF.
IF LS_PA0041-DAR06 = 'D2'.
L_TIME_WORK = LS_PA0041-DAT06.
ELSEIF LS_PA0041-DAR06 = 'D4'.
L_TIME_CONGYE = LS_PA0041-DAT06.
ENDIF.
IF LS_PA0041-DAR07 = 'D2'.
L_TIME_WORK = LS_PA0041-DAT07.
ELSEIF LS_PA0041-DAR07 = 'D4'.
L_TIME_CONGYE = LS_PA0041-DAT07.
ENDIF.
IF LS_PA0041-DAR08 = 'D2'.

L_TIME_WORK = LS_PA0041-DAT08.
ELSEIF LS_PA0041-DAR08 = 'D4'.
L_TIME_CONGYE = LS_PA0041-DAT08.
ENDIF.
IF LS_PA0041-DAR09 = 'D2'.
L_TIME_WORK = LS_PA0041-DAT09.
ELSEIF LS_PA0041-DAR09 = 'D4'.
L_TIME_CONGYE = LS_PA0041-DAT09.
ENDIF.
IF LS_PA0041-DAR10 = 'D2'.
L_TIME_WORK = LS_PA0041-DAT10.
ELSEIF LS_PA0041-DAR10 = 'D4'.
L_TIME_CONGYE = LS_PA0041-DAT10.
ENDIF.
IF LS_PA0041-DAR11 = 'D2'.
L_TIME_WORK = LS_PA0041-DAT11.
ELSEIF LS_PA0041-DAR11 = 'D4'.
L_TIME_CONGYE = LS_PA0041-DAT11.
ENDIF.
IF LS_PA0041-DAR12 = 'D2'.
L_TIME_WORK = LS_PA0041-DAT12.
ELSEIF LS_PA0041-DAR12 = 'D4'.
L_TIME_CONGYE = LS_PA0041-DAT12.
ENDIF.
CALL FUNCTION 'SD_CALC_DURATION_FROM_DATETIME'
EXPORTING
I_DATE1
= SY-DATUM
I_TIME1
= G_TIME
I_DATE2
= L_TIME_WORK
I_TIME2
= G_TIME
IMPORTING
E_TDIFF
= L_TIME_1
*
E_DATE2_EARLY
=
EXCEPTIONS
INVALID_DATETIME
= 1
OTHERS
= 2
.
IF SY-SUBRC <> 0.
*Implement suitable error handling here
ENDIF.
GS_PINFO-WORK = L_TIME_1 / ( 24 * 365 * 10000 ).
CALL FUNCTION 'SD_CALC_DURATION_FROM_DATETIME'
EXPORTING
I_DATE1
= SY-DATUM
I_TIME1
= G_TIME
I_DATE2
= L_TIME_CONGYE
I_TIME2
= G_TIME
IMPORTING
E_TDIFF
= L_TIME_2
*
E_DATE2_EARLY
=
EXCEPTIONS
INVALID_DATETIME
= 1
OTHERS
= 2

.
IF SY-SUBRC <> 0.
*Implement suitable error handling here
ENDIF.
GS_PINFO-CONGYE = L_TIME_2 / ( 24 * 365 * 10000 ).
ENDFORM.
" GET_PA0041
*&---------------------------------------------------------------------*
*&
Form GET_PA0022
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM GET_PA0022 .
DATA: L_SLABS
L_AUSBI
L_INSTI
L_ATEXT

TYPE
TYPE
TYPE
TYPE

PA0022-SLABS,
PA0022-AUSBI,
PA0022-INSTI,
T518B-ATEXT.

SELECT SINGLE SLABS


AUSBI
INSTI
INTO (L_SLABS,
L_AUSBI,
L_INSTI)
FROM PA0022
WHERE PERNR = P_PERNR.
SELECT
INTO
FROM
WHERE
AND

SINGLE STEXT
GS_PINFO-STEXT
T519T
SLABS = L_SLABS
SPRSL = SY-LANGU.

SELECT
INTO
FROM
WHERE
AND

SINGLE ATEXT
L_ATEXT
T518B
AUSBI = L_AUSBI
LANGU = SY-LANGU.

"Certificate
"major
"school

CONCATENATE L_INSTI L_ATEXT INTO GS_PINFO-MAJOR SEPARATED BY SPACE.


ENDFORM.
" GET_PA0022
*&---------------------------------------------------------------------*
*&
Form GET_PA0185
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM GET_PA0185 .
SELECT
INTO
FROM
WHERE
AND
AND
AND

SINGLE ICNUM
GS_PINFO-IDCARD
PA0185
PERNR = P_PERNR
SUBTY = '01'
BEGDA <= SY-DATUM
ENDDA >= SY-DATUM.

SELECT SINGLE ICNUM


INTO GS_PINFO-PASSPORT

"ID Crad

"passport

FROM
WHERE
AND
AND
AND

PA0185
PERNR =
SUBTY =
BEGDA <=
ENDDA >=

P_PERNR
'02'
SY-DATUM
SY-DATUM.

ENDFORM.
" GET_PA0185
*&---------------------------------------------------------------------*
*&
Form GET_PA0001
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM GET_PA0001 .
DATA: L_STELL TYPE PA0001-STELL,
L_ORGEH TYPE PA0001-ORGEH.
SELECT SINGLE STELL
ORGEH
INTO (L_STELL,
L_ORGEH)
FROM PA0001
WHERE PERNR = P_PERNR
AND BEGDA <= SY-DATUM
AND ENDDA >= SY-DATUM.
SELECT
INTO
FROM
WHERE
AND

SINGLE STLTX
GS_PINFO-STLTX
T513S
STELL = L_STELL
SPRSL = SY-LANGU.

SELECT
INTO
FROM
WHERE
AND

SINGLE ORGTX
GS_PINFO-ORGTX
T527X
ORGEH = L_ORGEH
SPRSL = SY-LANGU.

"Job
"Organizational Unit

ENDFORM.
" GET_PA0001
*&---------------------------------------------------------------------*
*&
Form GET_LEADER
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM GET_LEADER .
DATA: LT_LEADER TYPE TSWHACTOR,
LS_LEADER LIKE LINE OF LT_LEADER,
L_OBJID TYPE HRSOBID-SOBID,
L_NACHN TYPE PA0002-NACHN,
L_VORNA TYPE PA0002-VORNA.
L_OBJID = P_PERNR.
CALL FUNCTION 'HR_ASR_GET_LEADER'
EXPORTING
OTYPE
= 'P'
OBJID
= L_OBJID
*
KEYDATE
= SY-DATUM
LEVEL
= '01'

IMPORTING
LEADER_TAB
EXCEPTIONS
WRONG_INPUT
NOTHING_FOUND
NO_ACTIVE_PLVAR
OTHERS
.
IF SY-SUBRC <> 0.
* Implement suitable error
ENDIF.

= LT_LEADER
=
=
=
=

1
2
3
4

handling here

LOOP AT LT_LEADER INTO LS_LEADER.


SELECT SINGLE NACHN
VORNA
INTO (L_NACHN,
L_VORNA)
FROM PA0002
WHERE PERNR = LS_LEADER-OBJID
AND BEGDA <= SY-DATUM
AND ENDDA >= SY-DATUM.

"Last Name
"First Name

CONCATENATE LS_LEADER-OBJID L_NACHN L_VORNA INTO GS_PINFO-LEADER


SEPARATED BY SPACE.
ENDLOOP.
ENDFORM.
" GET_LEADER
*&---------------------------------------------------------------------*
*&
Form GET_PA0023
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM GET_PA0023 .
SELECT ARBGB
BEGDA
ENDDA
TAETE
INTO CORRESPONDING FIELDS
FROM PA0023
WHERE PERNR = P_PERNR.

"Name of employer
"Start Date
"End Date
"Job at former employer(s)
OF TABLE GT_CV

LOOP AT GT_CV INTO GS_CV.


SELECT SINGLE LTEXT
INTO GS_CV-LTEXT
FROM T513C
WHERE SPRAS = SY-LANGU
AND TAETE = GS_CV-TAETE.
MODIFY GT_CV FROM GS_CV TRANSPORTING LTEXT
WHERE ARBGB = GS_CV-ARBGB
AND BEGDA = GS_CV-BEGDA
AND ENDDA = GS_CV-ENDDA.
ENDLOOP.
ENDFORM.
" GET_PA0023
*&---------------------------------------------------------------------*
*&
Form GET_PA0021
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*

FORM GET_PA0021 .
DATA: L_TIME TYPE TVRO-FAHZTD.
SELECT SUBTY
"subtype
FANAM
"Last name
FAVOR
"First name
FGBDT
"Date of Birth
FANAT
"Nationality
FGBOT
"Job
INTO CORRESPONDING FIELDS OF TABLE GT_FAMILY
FROM PA0021
WHERE PERNR = P_PERNR
AND BEGDA <= SY-DATUM
AND ENDDA >= SY-DATUM.
LOOP AT GT_FAMILY INTO GS_FAMILY.
SELECT
INTO
FROM
WHERE
AND
AND

SINGLE STEXT
GS_FAMILY-GUANXI
T591S
INFTY = '0021'
SUBTY = GS_FAMILY-SUBTY
SPRSL = SY-LANGU.

CONCATENATE GS_FAMILY-FANAM GS_FAMILY-FAVOR INTO GS_FAMILY-NAME SEPARATED BY


SPACE.
CALL FUNCTION 'SD_CALC_DURATION_FROM_DATETIME'
EXPORTING
I_DATE1
= SY-DATUM
I_TIME1
= G_TIME
I_DATE2
= GS_FAMILY-FGBDT
I_TIME2
= G_TIME
IMPORTING
E_TDIFF
= L_TIME
*
E_DATE2_EARLY
=
EXCEPTIONS
INVALID_DATETIME
= 1
OTHERS
= 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
GS_FAMILY-AGE = L_TIME / ( 24 * 365 * 10000 ).
SELECT
INTO
FROM
WHERE
AND

SINGLE NATIO50
GS_FAMILY-NATION
T005T
SPRAS = SY-LANGU
LAND1 = GS_FAMILY-FANAT.

MODIFY GT_FAMILY FROM GS_FAMILY TRANSPORTING GUANXI NAME AGE NATION


WHERE SUBTY = GS_FAMILY-SUBTY
AND FANAM = GS_FAMILY-FANAM
AND FAVOR = GS_FAMILY-FAVOR.
ENDLOOP.
ENDFORM.
" GET_PA0021
*&---------------------------------------------------------------------*

*&
Form PRINT_OUT
*&---------------------------------------------------------------------*
*
Print out
*----------------------------------------------------------------------*
FORM PRINT_OUT.
DATA: LC_FORM_ZH TYPE TDSFNAME VALUE 'YKCN_HR_PERSONNEL_PROFILE_ZH'.
DATA: LC_FORM_EN TYPE TDSFNAME VALUE 'YKCN_HR_PERSONNEL_PROFILE_EN'.
DATA: LV_NAME
TYPE RS38L_FNAM,
"FUNCTION NAME
LV_TITLE TYPE SSFCOMPOP-TDCOVTITLE, "Text for Cover Page
LS_OUTOP TYPE SSFCOMPOP,
"Output Option
LS_CONTROL TYPE SSFCTRLOP.
"Control Parameters
DATA: LC_PRINTER TYPE SSFCTRLOP-DEVICE VALUE 'PRINTER'.

*
*

*
*

IF SY-LANGU = '1'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME
= LC_FORM_ZH
"YKCN_HR_PERSONNEL_PROFILE_ZH
VARIANT
= ' '
DIRECT_CALL
= ' '
IMPORTING
FM_NAME
= LV_NAME
EXCEPTIONS
NO_FORM
= 1
NO_FUNCTION_MODULE = 2
OTHERS
= 3.
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.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME
= LC_FORM_EN
"YKCN_HR_PERSONNEL_PROFILE_EN
VARIANT
= ' '
DIRECT_CALL
= ' '
IMPORTING
FM_NAME
= LV_NAME
EXCEPTIONS
NO_FORM
= 1
NO_FUNCTION_MODULE = 2
OTHERS
= 3.
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.
LS_OUTOP-TDIMMED
LS_OUTOP-TDNEWID
LS_OUTOP-TDCOVTITLE
LS_CONTROL-NO_DIALOG
LS_CONTROL-PREVIEW
LS_CONTROL-DEVICE

=
=
=
=
=
=

CALL FUNCTION LV_NAME


EXPORTING
CONTROL_PARAMETERS
OUTPUT_OPTIONS
USER_SETTINGS
IV_PERNR

'X'.
'X'.
LV_TITLE.
'X'.
'X'.
LC_PRINTER.

"Print Immidiately
"New Print Spool
"Text for Cover Page
"No Preview Dialog
"Print preview
"Printer

=
=
=
=

"Control setting
"Output setting

LS_CONTROL
LS_OUTOP
SPACE
GS_PINFO-PERNR

"personnel no.

IS_PINFO
TABLES
IT_CV
IT_FAMILY
EXCEPTIONS
FORMATTING_ERROR
INTERNAL_ERROR
SEND_ERROR
USER_CANCELED
OTHERS
ENDFORM.

= GS_PINFO

"Personnel info.

= GT_CV
= GT_FAMILY

"CV
"Family

=
=
=
=
=

1
2
3
4
5.

You might also like