HR常用

薪资核算

FORM GT_RT_DATA .
  DATA:P_DATE LIKE SY-DATUM(6).
  CALL FUNCTION 'CU_READ_RGDIR'
    EXPORTING
      PERSNR             = P0001-PERNR
      NO_AUTHORITY_CHECK = 'X'
    TABLES
      IN_RGDIR           = T_RGDIR
    EXCEPTIONS
      NO_RECORD_FOUND    = 1
      OTHERS             = 2.
  CHECK SY-SUBRC = 0.
  P_DATE = G_BEGDA(6).

  LOOP AT T_RGDIR WHERE FPPER = P_DATE AND SRTZA = 'A'.    "从员工薪酬结果表RGDIR中获取符合条件的工作
*    check t_rgdir-fpbeg between g_begda and g_endda .      "工资结算的开始日期
*    check t_rgdir-fpend between g_begda and g_endda .      "工资结算的结束日期
*    CHECK t_rgdir-fpend <> t_rgdir-fpbeg  .                    "工资结算的开始日期和结束日期不相等
*    check t_rgdir-abkrs = pnpxabkr.                         "判断是否在工资核算范围内
*    l_sum = l_sum + 1.                                      "计算当月人数
    CHECK T_RGDIR-FPPER IS NOT INITIAL.
    CHECK T_RGDIR-INPER IS NOT INITIAL.
    G_NUMBER = T_RGDIR-SEQNR.
    CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT'
      EXPORTING
        CLUSTERID                    = 'CN'
        EMPLOYEENUMBER               = P0001-PERNR
        SEQUENCENUMBER               = G_NUMBER
        CHECK_READ_AUTHORITY         = ''
      CHANGING
        PAYROLL_RESULT               = G_RESULT
      EXCEPTIONS
        ILLEGAL_ISOCODE_OR_CLUSTERID = 1
        ERROR_GENERATING_IMPORT      = 2
        IMPORT_MISMATCH_ERROR        = 3
        SUBPOOL_DIR_FULL             = 4
        NO_READ_AUTHORITY            = 5
        NO_RECORD_FOUND              = 6
        VERSIONS_DO_NOT_MATCH        = 7
        ERROR_READING_ARCHIVE        = 8
        ERROR_READING_RELID          = 9
        OTHERS                       = 10.
    CHECK SY-SUBRC = 0.                                    "判断函数是否执行成功

    LOOP AT G_RESULT-INTER-RT INTO LT_RT .
      CASE LT_RT-LGART.
        WHEN '/101'.
          ITAB-RT101 = ABS( LT_RT-BETRG ).  "收入额
        WHEN '/401'.
          ITAB-RT103 = ABS( LT_RT-BETRG ).  "应纳税所得额
        WHEN '/403'.
          ITAB-RT403 = ABS( LT_RT-BETRG ).
        WHEN '/404'.
          ITAB-RT404 = ABS( LT_RT-BETRG ).
        WHEN OTHERS.
      ENDCASE.
    ENDLOOP.
  ENDLOOP.
ENDFORM.

工作日历读取

BKK_ADD_WORKINGDAY

/**/FUNCTION ZHR_PC_PUBLIC_010.
*"----------------------------------------------------------------------
*"*"本地接口:
*"  IMPORTING
*"     VALUE(I_BEGDA) TYPE  SY-DATUM OPTIONAL
*"     VALUE(I_ENDDA) TYPE  SY-DATUM OPTIONAL
*"     VALUE(I_OBJID) TYPE  HROBJID OPTIONAL
*"  TABLES
*"      OT_GZRL STRUCTURE  PA0000
*"      OT_GZRL1 STRUCTURE  PA0000
*"      OT_GZRL2 STRUCTURE  PA0000
*"      OT_GZRL3 STRUCTURE  PA0000
*"----------------------------------------------------------------------
  DATA : LT_OBJEC TYPE TABLE OF OBJEC WITH HEADER LINE,
         LT_STRUC TYPE TABLE OF STRUC WITH HEADER LINE.
  DATA : LT_BEGDA LIKE SY-DATUM,LT_ENDDA LIKE SY-DATUM,L_PERNR LIKE PERNR-PERNR.
  DATA : LT_PERWS LIKE TABLE OF PTPSP WITH HEADER LINE.

  CALL FUNCTION 'RH_STRUC_GET'
    EXPORTING
      ACT_OTYPE      = 'O'
      ACT_OBJID      = I_OBJID
      ACT_WEGID      = 'O-S-P'
      ACT_PLVAR      = '01'
      ACT_BEGDA      = I_BEGDA
      ACT_ENDDA      = I_ENDDA
*     authority_check = 'x'
    TABLES
      RESULT_OBJEC   = LT_OBJEC
      RESULT_STRUC   = LT_STRUC
    EXCEPTIONS
      NO_PLVAR_FOUND = 1
      NO_ENTRY_FOUND = 2
      OTHERS         = 3.

  DELETE LT_STRUC WHERE OTYPE NE  'P' .
  LOOP AT LT_STRUC WHERE OTYPE = 'P' AND VPROZT > 50 .
    CLEAR:L_PERNR.
    L_PERNR = LT_STRUC-OBJID.
    CALL FUNCTION 'HR_PERSONAL_WORK_SCHEDULE'
      EXPORTING
        PERNR         = L_PERNR
        BEGDA         = I_BEGDA
        ENDDA         = I_ENDDA
      TABLES
        PERWS         = LT_PERWS
      EXCEPTIONS
        ERROR_OCCURED = 1
        ABORT_OCCURED = 2
        OTHERS        = 3.
    LOOP AT LT_PERWS WHERE ACTIV = 'X' AND TPROG = 'WORK' AND TAGTY <> '1' AND FTKLA <> '1'.
      OT_GZRL-PERNR = L_PERNR.
      OT_GZRL-BEGDA = LT_PERWS-DATUM.           "日期.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
        EXPORTING
          INPUT  = OT_GZRL-PERNR
        IMPORTING
          OUTPUT = OT_GZRL-PERNR.
      APPEND OT_GZRL.CLEAR OT_GZRL.
    ENDLOOP.

    "法假
    LOOP AT LT_PERWS WHERE ACTIV = 'X'  AND FTKLA = '1'.
      OT_GZRL1-PERNR = L_PERNR.
      OT_GZRL1-BEGDA = LT_PERWS-DATUM.           "日期.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
        EXPORTING
          INPUT  = OT_GZRL1-PERNR    
        IMPORTING
          OUTPUT = OT_GZRL1-PERNR.
      APPEND OT_GZRL1.CLEAR OT_GZRL1.
    ENDLOOP.
    "休息
    LOOP AT LT_PERWS WHERE ACTIV = 'X' AND TPROG = 'REST' AND TAGTY <> '1' .
      OT_GZRL2-PERNR = L_PERNR.
      OT_GZRL2-BEGDA = LT_PERWS-DATUM.           "日期.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
        EXPORTING
          INPUT  = OT_GZRL2-PERNR
        IMPORTING
          OUTPUT = OT_GZRL2-PERNR.
      APPEND OT_GZRL2.CLEAR OT_GZRL2.
    ENDLOOP.
    "周六
    LOOP AT LT_PERWS WHERE ACTIV = 'X'  AND TPROG = 'HALF'.
      OT_GZRL3-PERNR = L_PERNR.
      OT_GZRL3-BEGDA = LT_PERWS-DATUM.           "日期.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
        EXPORTING
          INPUT  = OT_GZRL3-PERNR
        IMPORTING
          OUTPUT = OT_GZRL3-PERNR.
      APPEND OT_GZRL3.CLEAR OT_GZRL3.
    ENDLOOP.

  ENDLOOP.

ENDFUNCTION.
 DATA : LT_PERWS LIKE TABLE OF PTPSP WITH HEADER LINE.
  DATA: L_BEGDA LIKE SY-DATUM,L_ENDDA LIKE SY-DATUM.
  CONCATENATE I_BEGDA+0(4) '0101' INTO L_BEGDA.
  CONCATENATE I_BEGDA+0(4) '1231' INTO L_ENDDA.

  CALL FUNCTION 'HR_PERSONAL_WORK_SCHEDULE'
    EXPORTING
      PERNR         = I_PERNR
      BEGDA         = L_BEGDA
      ENDDA         = L_ENDDA
    TABLES
      PERWS         = LT_PERWS
    EXCEPTIONS
      ERROR_OCCURED = 1
      ABORT_OCCURED = 2
      OTHERS        = 3.

  LOOP AT LT_PERWS WHERE DATUM BETWEEN I_BEGDA AND I_ENDDA.
    IF LT_PERWS-TPROG = 'OFF'.
      OT_REST-PERNR = I_PERNR.
      OT_REST-BEGDA = LT_PERWS-DATUM.
      OT_REST-TYPE  = '1'.   "休息日
      APPEND OT_REST.CLEAR OT_REST.
    ENDIF.
    IF LT_PERWS-TAGTY = '1'.
      OT_REST-PERNR = I_PERNR.
      OT_REST-BEGDA = LT_PERWS-DATUM.
      OT_REST-TYPE  = '2'.   "法定节假日
      APPEND OT_REST.CLEAR OT_REST.
    ENDIF.
  ENDLOOP.

 

 

保存

HRP

FORM SAVE .
  DATA: REC_O_RETURN     TYPE BAPIRET1,
        LS_O_RETURN      TYPE BAPIRETURN1,
        LS_KEY           TYPE BAPIPAKEY,
        LV_VALIDITYBEGIN LIKE BAPIPAKEY-VALIDBEGIN.
  DATA:LT_HRP9102 LIKE TABLE OF HRP9102 WITH HEADER LINE.
  DATA:INNN LIKE TABLE OF P9102 WITH HEADER LINE.
  DATA: O_RETURN LIKE TABLE OF   BAPIRETURN1 WITH HEADER LINE.
  LOOP AT RESULT.
    CLEAR:REC_O_RETURN, LS_O_RETURN, LS_KEY, LV_VALIDITYBEGIN.
*    LOOP AT RESULT.
    CLEAR:LT_HRP9102,LT_HRP9102[].
    SELECT * INTO CORRESPONDING FIELDS OF TABLE LT_HRP9102 FROM HRP9102 WHERE OBJID = RESULT-OBJID.
    IF LT_HRP9102[] IS NOT INITIAL.
      LOOP AT LT_HRP9102.
        CLEAR:INNN,INNN[].
*          MOVE-CORRESPONDING RESULT TO INNN.
*          INNN-ZXZDZJJ = RESULT-DZJJ.
        INNN-OBJID = RESULT-OBJID.
        INNN-AEDTM = SY-DATUM.
        INNN-PLVAR = '01'.
        INNN-MANDT = SY-MANDT.
        INNN-UNAME = SY-UNAME.
        INNN-BEGDA =  LT_HRP9102-BEGDA.
        INNN-ENDDA =  LT_HRP9102-ENDDA.
        INNN-OTYPE =   'O'.
        INNN-ISTAT =   '1'.
        INNN-INFTY =   '9102'.
*          INNN-SUBTY =   '9104'.
        APPEND INNN.CLEAR INNN.
        CALL FUNCTION 'RH_DELETE_INFTY'
          EXPORTING
*           LOAD                = 'X'
            VTASK               = 'D'
*           ORDER_FLG           = 'X'
*           COMMIT_FLG          = 'X'
*           AUTHY               = 'X'
*           PPPAR_IMP           =
*           KEEP_LUPD           =
*           WORKF_ACTV          = 'X'
          TABLES
            INNNN               = INNN[]
*           ILFCODE             =
          EXCEPTIONS
            ERROR_DURING_DELETE = 1
            NO_AUTHORIZATION    = 2
            DELETE_FIRST_RECORD = 3
            CORR_EXIT           = 4
            OTHERS              = 5.
        IF SY-SUBRC <> 0.
* Implement suitable error handling here
        ENDIF.

      ENDLOOP.
    ENDIF.

    CLEAR:INNN,INNN[].
*      MOVE-CORRESPONDING RESULT TO INNN.
    INNN-OBJID = RESULT-OBJID.
    INNN-AEDTM = SY-DATUM.
    INNN-PLVAR = '01'.
    INNN-MANDT = SY-MANDT.
    INNN-UNAME = SY-UNAME.
    INNN-BEGDA =  TIME1.
*    INNN-ENDDA =  TIME2.
    INNN-ENDDA =   '99991231'.
    INNN-ZMDDJWB =  RESULT-MDDJ.
    INNN-ZMDMJ =  RESULT-ZMDMJ.
    IF RESULT-MDDJ = 'A1'.
      INNN-ZMDDJ =   '01'.
    ELSEIF   RESULT-MDDJ = 'A2'.
      INNN-ZMDDJ =   '02'.
    ELSEIF   RESULT-MDDJ = 'A3'.
      INNN-ZMDDJ =   '03'.
    ELSEIF   RESULT-MDDJ = 'B1'.
      INNN-ZMDDJ =   '04'.
    ELSEIF   RESULT-MDDJ = 'B2'.
      INNN-ZMDDJ =   '05'.
    ELSEIF   RESULT-MDDJ = 'B3'.
      INNN-ZMDDJ =   '06'.
    ELSEIF   RESULT-MDDJ = 'C1'.
      INNN-ZMDDJ =   '07'.
    ENDIF.
    INNN-OTYPE =   'O'.
    INNN-ISTAT =   '1'.
    INNN-INFTY =   '9102'.
*          INNN-SUBTY =   '9104'.
    APPEND INNN.CLEAR INNN.


    CALL FUNCTION 'RH_INSERT_INFTY'
      EXPORTING
        FCODE               = 'INSE'
        VTASK               = 'D'
        ORDER_FLG           = 'X'
        COMMIT_FLG          = 'X'
        AUTHY               = 'X'
*       PPPAR_IMP           =
*       OLD_TABNR           = ' '
*       REPID               = ' '
*       FORM                = ' '
*       KEEP_LUPD           =
        WORKF_ACTV          = 'X'
      TABLES
        INNNN               = INNN[]
*       ILFCODE             =
      EXCEPTIONS
        NO_AUTHORIZATION    = 1
        ERROR_DURING_INSERT = 2
        REPID_FORM_INITIAL  = 3
        CORR_EXIT           = 4
        BEGDA_GREATER_ENDDA = 5
        OTHERS              = 6.
    IF  SY-SUBRC = 0.
      O_RETURN-MESSAGE_V1 = '门店等级,保存成功'.
**********************
      O_RETURN-TYPE    = 'S'.                   "消息类型
      O_RETURN-ID      = RESULT-OBJID.     "员工编号
***************
      APPEND O_RETURN.CLEAR O_RETURN.
    ELSE.
      O_RETURN-MESSAGE_V1 = '门店等级,保存失败'.
**********************
      O_RETURN-TYPE    = 'S'.                   "消息类型
      O_RETURN-ID      = RESULT-OBJID.     "员工编号
***************
      APPEND O_RETURN.CLEAR O_RETURN.
    ENDIF.
    CLEAR:INNN,INNN[].
*    ENDLOOP.
  ENDLOOP.

ENDFORM.

 

PA

DATA:LT_PA0015 LIKE TABLE OF PA0015 WITH HEADER LINE.
    DATA:LS_PA0015        TYPE P0015,
         REC_RETURN       TYPE BAPIRET1,
         LS_RETURN        TYPE BAPIRETURN1,
         LS_KEY           TYPE BAPIPAKEY,
         LV_VALIDITYBEGIN LIKE BAPIPAKEY-VALIDBEGIN.

    DATA:LT_0015 TYPE P0015.

    SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_ZNJ_GLJLB  FROM  ZNJ_GLJLB ."where

    LOOP AT IN_RESULT.  "鼓励奖明细
*      CLEAR LT_PA0015.CLEAR LT_PA0015[].

      CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
        EXPORTING
          NUMBER = IN_RESULT-PERNR
        IMPORTING
          RETURN = REC_RETURN.
      IF REC_RETURN IS INITIAL .   "人员没有被锁定
        MOVE-CORRESPONDING IN_RESULT TO LS_PA0015.
*************************
        IF IN_RESULT-ZWJB_1 IS NOT INITIAL.
          CONCATENATE IN_DATE+0(4) '0623' INTO TIMES1.
          LS_PA0015-BEGDA = TIMES1.
          LS_PA0015-ENDDA = TIMES1.
        ELSE.
          CONCATENATE IN_DATE+0(4) '1223' INTO TIMES2.
          LS_PA0015-BEGDA = TIMES2.
          LS_PA0015-ENDDA = TIMES2.
        ENDIF.

        LS_PA0015-PERNR = IN_RESULT-PERNR.
        LS_PA0015-SUBTY = '3024'.
*        LS_PA0015-SUBTY = '0015'.
        LS_PA0015-SEQNR = '000'.
        LS_PA0015-AEDTM =  SY-DATUM.
        LS_PA0015-UNAME =  SY-UNAME.
        LS_PA0015-LGART =  '3024'.  "3024工资项
        LS_PA0015-BETRG =  IN_RESULT-SHJE. "享受金额
        LS_PA0015-WAERS = 'CNY'.

        CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
          EXPORTING
            NUMBER = LS_PA0015-PERNR
          IMPORTING
            RETURN = REC_RETURN.

*        IF REC_RETURN IS INITIAL .   "人员未被锁定

        CALL FUNCTION 'HR_INFOTYPE_OPERATION'
          EXPORTING
            INFTY         = '0015'
            NUMBER        = LS_PA0015-PERNR
            VALIDITYEND   = LS_PA0015-ENDDA
            VALIDITYBEGIN = LS_PA0015-BEGDA
            RECORD        = LS_PA0015
            OPERATION     = 'INS'
          IMPORTING
            RETURN        = LS_RETURN
            KEY           = LS_KEY.

        CALL FUNCTION 'BAPI_EMPLOYEET_DEQUEUE'       "解锁
          EXPORTING
            NUMBER        = LS_PA0015-PERNR
            VALIDITYBEGIN = LV_VALIDITYBEGIN.
        IF LS_RETURN IS   INITIAL.
          OT_MESS-TYPE    = 'S'.                   "消息类型
          OT_MESS-MESSAGE = '保存成功'.            "消息文本
          OT_MESS-ID      = IN_RESULT-PERNR.     "员工编号
          APPEND OT_MESS. CLEAR OT_MESS.

        ELSE.

          OT_MESS-TYPE    = LS_RETURN-TYPE.       "消息类型
          OT_MESS-MESSAGE = LS_RETURN-MESSAGE.    "消息文本
          OT_MESS-ID      = IN_RESULT-PERNR.    "员工编号
*            ot_mess-message_v1      = ls_pa0015-endda.    "日期
          APPEND OT_MESS. CLEAR OT_MESS.
        ENDIF.
      ELSE.  "人员没有被锁定
        OT_MESS-TYPE    = REC_RETURN-TYPE.       "消息类型
        OT_MESS-MESSAGE_V1 = REC_RETURN-MESSAGE.    "消息文本
        OT_MESS-ID      = IN_RESULT-PERNR.     "员工编号
        APPEND OT_MESS. CLEAR OT_MESS.
        ROLLBACK WORK.
        CALL FUNCTION 'BAPI_EMPLOYEET_DEQUEUE'       "解锁
          EXPORTING
            NUMBER        = LT_PA0015-PERNR
            VALIDITYBEGIN = LV_VALIDITYBEGIN.
      ENDIF.
      CLEAR:LT_PA0015[],LT_PA0015.

    ENDLOOP.
***********************
    LOOP AT OT_MESS.
      IF OT_MESS-TYPE =  'S'.
        DELETE OT_MESS .
      ELSE.
      ENDIF.
    ENDLOOP.

 逻辑数据库

双击回车 后

 

posted @ 2019-01-15 15:54  蜡哲图  阅读(561)  评论(0编辑  收藏  举报
目录内容