SAP ABAP HR 日期拆分(范围日期拆分,要考虑开始/结束时间)

SAP ABAP HR 日期拆分(范围日期拆分,要考虑开始/结束时间)_第1张图片

DATA:ltt_query TYPE STANDARD TABLE OF zhrs02401.
DATA:ls_query TYPE zhrs02401.
DATA:lss_query TYPE zhrs02401.
DATA:li_day TYPE i.
DATA:li_uzeit TYPE i.
DATA:lv_datum TYPE sy-datum.

DATA(lt_query) = it_query[].

REFRESH ltt_query.
LOOP AT it_query INTO lss_query .

CLEAR ls_query.
MOVE-CORRESPONDING lss_query TO ls_query.

IF ls_query-begda <> ls_query-endda.

  CLEAR li_day.
  li_day = ls_query-endda - ls_query-begda.
  lv_datum = ls_query-begda.

  DO.
    IF li_day = 1.
      EXIT.
    ENDIF.

    li_day = li_day - 1.

    ls_query-begda = lv_datum + li_day.
    ls_query-beguz = '080000'.
    ls_query-endda = lv_datum + li_day.
    ls_query-enduz = '173000'.
    ls_query-zccsc = '8.5'.

    APPEND ls_query TO ltt_query.

  ENDDO.
  IF sy-subrc = 0.

    "第一条
    CLEAR li_uzeit.
    ls_query-begda = lss_query-begda.
    ls_query-beguz = lss_query-beguz.
    ls_query-endda = lss_query-begda.
    ls_query-enduz = '173000'.
    li_uzeit = ls_query-enduz - ls_query-beguz.
  •    ls_query-zccsc = li_uzeit / 3600.
      APPEND ls_query TO ltt_query.
    
      "最后一条
      CLEAR li_uzeit.
      ls_query-begda = lss_query-endda.
      ls_query-beguz = '080000'.
      ls_query-endda = lss_query-endda.
      ls_query-enduz = lss_query-enduz.
      li_uzeit = ls_query-enduz - ls_query-beguz.
    
  •    ls_query-zccsc = li_uzeit / 3600.
      APPEND ls_query TO ltt_query.
    
    ENDIF.
    

    ELSE.
    APPEND ls_query TO ltt_query.

    ENDIF.

    ENDLOOP.

你可能感兴趣的:(ABAP,SAP,HR,abap)