码迷,mamicode.com
首页 > 其他好文 > 详细

PA30时间事件获取+删除操作

时间:2019-12-26 17:58:38      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:param   ike   event   read   update   inner   occurs   wait   func   

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

*& Report  ZHR16012

*&                  huangjm 2016.12.19

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

*&

*&

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

 

REPORT  zhr16012.

TABLES:sscrfields,pa0001,pa0531,t100,teven,pa0007.

DATA: BEGIN OF itab OCCURS 0,

   pernr LIKE pa0007-pernr,           "人员编号

 END OF itab.

 

 

DATA: BEGIN OF hr_data1 OCCURS 0.

        INCLUDE STRUCTURE teven.

DATA:zaob(1) TYPE c .

DATA: END OF hr_data1.

 

DATA:hr_data TYPE tim_tmw_teven_tab.

 

 

 

 

DATA: BEGIN OF del_teven OCCURS 0.

        INCLUDE STRUCTURE teven.

DATA: END OF del_teven.

 

DATA: BEGIN OF del_teven_more OCCURS 0.

        INCLUDE STRUCTURE teven_more.

DATA: END OF del_teven_more.

DATA: zdata LIKE sy-datum ,

      zdata1 LIKE sy-datum .

 

LOAD-OF-PROGRAM.

  zdata = sy-datum - 1.

  zdata1 = sy-datum - 1.

 

  SELECTION-SCREEN BEGIN OF BLOCK b02 WITH FRAME  TITLE text-001.

  SELECT-OPTIONS:s_pernr FOR pa0001-pernr.

  PARAMETERS:s_begda LIKE pa0007-begda DEFAULT  zdata.

  PARAMETERS:s_endda LIKE pa0007-endda DEFAULT ‘99991231‘.

  SELECTION-SCREEN END OF BLOCK b02.

***********************************************************************

*SELECT-OF-SELECTION

***********************************************************************

START-OF-SELECTION.

  PERFORM sub_get_data ."获取数据

  PERFORM sub_process_data ."处理数据

************************************************************************

*END-OF-SELECTION

************************************************************************

END-OF-SELECTION .

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

*&      Form  sub_get_data

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

*       text

*----------------------------------------------------------------------*

FORM sub_get_data .

 

  SELECT

       pa0007~pernr

   INTO CORRESPONDING FIELDS OF TABLE itab

   FROM pa0007

   INNER JOIN pa0001 ON pa0001~pernr = pa0007~pernr

   WHERE

         pa0007~pernr IN s_pernr AND

         pa0007~schkz = ‘N825‘   AND

         ( pa0001~persk = ‘A0‘ OR pa0001~persk = ‘A2‘ ).

 

 

  SORT itab BY pernr.

  DELETE ADJACENT DUPLICATES FROM itab COMPARING pernr .

 

ENDFORM .                    "sub_get_data

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

*&      Form  sub_process_data

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

*       text

*----------------------------------------------------------------------*

FORM sub_process_data .

  DATA:s_time LIKE teven-ltime ,           "打卡时间

       s_time1 LIKE teven-ltime .          "打卡时间

  DATA:s_date LIKE teven-ldate .           "打卡时间

 

  LOOP AT itab .

    FREE hr_data .

    FREE hr_data1 .

    FREE hr_data1[] .

    CALL FUNCTION ‘HR_TMW_DB_READ_TEVENT‘

      EXPORTING

        pernr    = itab-pernr

        fromdate = s_begda

        todate   = s_endda

      IMPORTING

        RESULT   = hr_data.

 

    hr_data1[] = hr_data[].

    SORT hr_data1 BY pernr ldate ltime.

**时间在7:00——8:30之间的打卡数据

**先确认该期间的打卡次数是否大于1,小于或等于1的,不做处理;大于1的,再判断是否存在上班卡,

**无上班卡的不做处理;有上班卡的,只保留第一次上班卡数据。

**判断早上打卡重复数据

    s_time = ‘070000‘.

    s_time1 = ‘083000‘.

    FREE s_date .

    LOOP AT hr_data1 WHERE satza = ‘P10‘.

      IF s_date =  hr_data1-ldate .

        IF hr_data1-ltime >= s_time AND hr_data1-ltime <= s_time1 .

          hr_data1-zaob = ‘X‘ .                     "代表出现重复打卡记录

        ENDIF .

        s_date = hr_data1-ldate .

      ELSE .

        s_date = hr_data1-ldate .

      ENDIF .

      MODIFY hr_data1 .

      CLEAR hr_data1 .

    ENDLOOP .

 

 

**时间在18:00——24:00之间的打卡数据

**先确认该期间的打卡次数是否大于1,小于或等于1的,不做处理;大于1的,

**再判断是否存在下班卡,无下班卡的不做处理;有下班卡的,只保留第一次下班卡数据。

    s_time = ‘180000‘.

    s_time1 = ‘240000‘.

    FREE s_date .

    LOOP AT hr_data1 WHERE satza = ‘P20‘.

      IF s_date =  hr_data1-ldate .

        IF hr_data1-ltime >= s_time AND hr_data1-ltime <= s_time1 .

          hr_data1-zaob = ‘X‘ .                     "代表出现重复打卡记录

        ENDIF .

        s_date = hr_data1-ldate .

      ELSE .

        s_date = hr_data1-ldate .

      ENDIF .

      MODIFY hr_data1 .

      CLEAR hr_data1 .

    ENDLOOP .

 

 

*有标记则为需要去掉的数据

    LOOP AT hr_data1 WHERE zaob = ‘X‘ .   "最终需要去重的数据

 

      del_teven-pdsnr = hr_data1-pdsnr.

      del_teven-pernr = hr_data1-pernr.

      APPEND del_teven .

      CALL FUNCTION ‘HR_TMW_DB_UPDATE_TEVENT‘           "去重函数

        TABLES

          del_teven         = del_teven

          del_teven_more    = del_teven_more.

 

      CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT‘

        EXPORTING

          wait = ‘X‘.

 

      CLEAR del_teven .

      CLEAR del_teven[] .

      CLEAR hr_data1 .

    ENDLOOP .

 

  ENDLOOP .

 

 

 

  MESSAGE ‘执行完毕!‘ TYPE ‘I‘ .

 

 

ENDFORM .                    "sub_process_data

PA30时间事件获取+删除操作

标签:param   ike   event   read   update   inner   occurs   wait   func   

原文地址:https://www.cnblogs.com/jimi520/p/12103190.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!