HRP9505是组织机构的部门信息表,结构类型P9505,使用函数RH_PNNNN_MAINTAIN创建更新某个组织机构的部门信息,但是用函数直接创建的机构编码在PPOME查看时,部门位置并没有勾选,这个勾选的数据是来自信息类型P1003的,所以在创建部门的同时,需要往信息类型1003中插入一条数据(在插入时确保该机构编码已存在且为活动类型)
DATA:LS_RETURN TYPE HRRHAD_MSG,
LT_HRTNNNN TYPE TABLE OF HRTDBTAB,
LS_P9505 TYPE P9505,
LS_OUT TYPE WPLOG,
LS_HRINNNN TYPE WPLOG .
FIELD-SYMBOLS: <FS_P9505> TYPE P9505 ,
<FS_WPLOG> TYPE C .
DATA LV_MAG TYPE STRING .
LOOP AT LT_HRP9505 INTO DATA(PS_HRP5905).
PS_HRP5905-ISTAT = '1' .
MOVE-CORRESPONDING PS_HRP5905 TO LS_P9505 .
ASSIGN LS_P9505 TO <FS_P9505> .
CHECK SY-SUBRC EQ 0 .
ASSIGN <FS_P9505> TO <FS_WPLOG> CASTING.
IF SY-SUBRC = 0 AND <FS_WPLOG> IS ASSIGNED.
LS_HRINNNN = <FS_WPLOG>.
ENDIF.
CALL FUNCTION 'RH_PNNNN_MAINTAIN'
EXPORTING
ACT_FCODE = 'INSE'
ACT_PLVAR = LS_HRINNNN-PLVAR
ACT_OTYPE = LS_HRINNNN-OTYPE
ACT_OBJID = LS_HRINNNN-OBJID
ACT_INFTY = LS_HRINNNN-INFTY
ACT_SUBTY = LS_HRINNNN-SUBTY
ACT_ISTAT = LS_HRINNNN-ISTAT
ACT_BEGDA = LS_HRINNNN-BEGDA
ACT_ENDDA = LS_HRINNNN-ENDDA
* ACT_NEW_LANGU = '1'
ACT_PNNNN = LS_HRINNNN
* ACT_INFOTYPEKEY =
* ACT_DPATT =
* ACT_GDATE =
* ACT_NEW_HISTO =
* ACT_ENQUEUE = 'X'
SUPPRESS_DIALOG = '2'
ACT_VTASK = 'S'
IMPORTING
* ACT_OK_CODE =
ACT_PNNNN_OUT = LS_OUT
ACT_MESS_INFO = LS_RETURN
* TABLES
* ACT_HRTNNNN = lt_hrtnnnn
EXCEPTIONS
INFTY_NOT_VALID = 1
NO_PLVAR = 2
OBJECT_NOT_DEFINED = 3
OTYPE_NOT_VALID = 4
NO_AUTHORITY = 5
ACTION_REJECTED = 6
NO_GDATE = 7
FCODE_NOT_SUPPORTED = 8
OTHERS = 9
.
IF sy-subrc <> 0.
CLEAR LV_MAG .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
INTO LV_MAG.
* & & &
ENDIF.
已创建成功,但是部门并没有勾选,这时候再去更新信息类型1003
DATA: LS_RETURN TYPE HRRHAD_MSG,
LS_HRP1003 TYPE P1003,
LS_HRINNNN TYPE WPLOG .
DATA LV_MAG TYPE STRING .
FIELD-SYMBOLS: <FS_P1003> TYPE P1003 ,
<FS_WPLOG> TYPE C .
LS_HRP1003-OBJID = '部门编码'.
LS_HRP1003-PLVAR = '01'.
LS_HRP1003-OTYPE = 'O'.
LS_HRP1003-INFTY = '1003'.
LS_HRP1003-SUBTY = ''.
LS_HRP1003-ISTAT = '1'.
LS_HRP1003-ABTEL = 'X'.
LS_HRP1003-BEGDA = '20210701'
LS_HRP1003-ENDDA = '99991231'.
ASSIGN LS_HRP1003 TO <FS_P1003>.
IF <FS_P1003> IS ASSIGNED .
ASSIGN <FS_P1003> TO <FS_WPLOG> CASTING .
CLEAR LS_HRINNNN.
IF <FS_WPLOG> IS ASSIGNED.
LS_HRINNNN = <FS_WPLOG>.
ENDIF.
ENDIF.
CALL FUNCTION 'RH_PNNNN_MAINTAIN'
EXPORTING
ACT_FCODE = 'INSE'
ACT_PLVAR = LS_HRINNNN-PLVAR
ACT_OTYPE = LS_HRINNNN-OTYPE
ACT_OBJID = LS_HRINNNN-OBJID
ACT_INFTY = LS_HRINNNN-INFTY
ACT_SUBTY = LS_HRINNNN-SUBTY
ACT_ISTAT = LS_HRINNNN-ISTAT
ACT_BEGDA = LS_HRINNNN-BEGDA
ACT_ENDDA = LS_HRINNNN-ENDDA
* ACT_NEW_LANGU = '1'
ACT_PNNNN = LS_HRINNNN
* ACT_INFOTYPEKEY =
* ACT_DPATT =
* ACT_GDATE =
* ACT_NEW_HISTO =
* ACT_ENQUEUE = 'X'
SUPPRESS_DIALOG = '2'
ACT_VTASK = 'S'
* ACT_PPPAR_EXEP = ls_exep
IMPORTING
* ACT_OK_CODE =
* ACT_PNNNN_OUT = PS_OUT
ACT_MESS_INFO = LS_RETURN
* TABLES
* ACT_HRTNNNN = lt_hrtnnnn
EXCEPTIONS
INFTY_NOT_VALID = 1
NO_PLVAR = 2
OBJECT_NOT_DEFINED = 3
OTYPE_NOT_VALID = 4
NO_AUTHORITY = 5
ACTION_REJECTED = 6
NO_GDATE = 7
FCODE_NOT_SUPPORTED = 8
OTHERS = 9
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
INTO LV_MAG.
MESSAGE E000(ZHRMSG) WITH LV_MAG.
* & & &
ENDIF.