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

Posted jimi520

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PA30时间事件获取+删除操作相关的知识,希望对你有一定的参考价值。

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

*& 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时间事件获取+删除操作的主要内容,如果未能解决你的问题,请参考以下文章

检查设备更改(添加/删除)事件

在事件日志中获取特定任务的开始结束时间

在 onChange 事件中引用可操作的网格

30 jQuery——操作事件

删除匿名事件处理程序 [重复]

Android 事件分发ItemTouchHandler 实现侧滑删除 ( 设置滑动方向 | 启用滑动操作 | 滑动距离判定 | 滑动速度判定 | 设置动画时间 | 设置侧滑触发操作 )