HR--一个奖金模拟试算的程序,仅供参考

************************************************************************
* Copyright 2004  Wuhan                                          *
* All Rights Reserved                                                  *
*----------------------------------------------------------------------*
* Program Name : ZHRR0001                                              *
* Project      :  SAP Implementation Project                     *
* Program Title: 员工奖金模拟明细表                                   *
* Created by   :                                                  *
* Created on   : 2004/09/20                                            *
* Version      : 1.0                                                   *
*----------------------------------------------------------------------*
* Function Description:                                                *
* 员工工龄工资的计算及显示                                             *
*----------------------------------------------------------------------*
* Data Table List:                                                     *
* PA0001: 人力资源主记录:信息类型0001 (原始分配)                       *
* PA0041: HR 主记录: 信息类型0041 (日期详细说明)                       *
* PA0014: HR主记录: 信息类型 0014 (经常性收益/折减)                    *
*----------------------------------------------------------------------*
* Refrence Table List:                                                 *
* cskt: 成本中心说明文本                                               *
* hrp1000: 信息类型 1000 数据库                                        *
*----------------------------------------------------------------------*
* Modification Log:                                                    *
* Date        Programmer     Correction Number                         *
************************************************************************
REPORT zhrr0027 MESSAGE-ID zdev.
*----------------------------------------------------------------------*
* TABLES                                                               *
*----------------------------------------------------------------------*
TABLES: pa0001,pa0009,zhr_jjdr.

*----------------------------------------------------------------------*
* TYPES OR TYPE-POOLS                                                  *
*----------------------------------------------------------------------*
TYPE-POOLS: slis.

*----------------------------------------------------------------------*
* INCLUDE                                                              *
*----------------------------------------------------------------------*

*----------------------------------------------------------------------*
* INTERNAL TABLES AND WORK AREAS                                       *
*----------------------------------------------------------------------*
* 人事范围帮助内表
DATA: BEGIN OF gt_werks_h OCCURS 0,
        persa LIKE t500p-persa,    "人事范围编号
        name1 LIKE t500p-name1,    "人事范围描述
      END OF gt_werks_h.

* 部门(组织单元)-成本中心关系内表
DATA: BEGIN OF gt_orgeh_kostl OCCURS 0,
        werks LIKE pa0001-werks,   "人事范围
        orgeh LIKE pa0001-orgeh,   "组织单元
        kostl LIKE pa0001-kostl,   "成本中心
      END OF gt_orgeh_kostl.

* 部门(组织单元)帮助内表
DATA: BEGIN OF gt_orgeh_h OCCURS 0,
        orgeh LIKE pa0001-orgeh,    "部门(组织单元)
        stext LIKE hrp1000-stext,   "部门文本
      END OF gt_orgeh_h.

* 成本中心帮助内表
DATA: BEGIN OF gt_kostl_h OCCURS 0,
        kostl LIKE cskt-kostl,  "成本中心编号
        ktext LIKE cskt-ktext,  "成本中心描述
      END OF gt_kostl_h.

* 获得员工编号帮助内表
DATA: BEGIN OF gt_pernr_h OCCURS 0,
        pernr LIKE pa0001-pernr,  "员工编号
        ename LIKE pa0001-ename,  "员工姓名
      END OF gt_pernr_h.

*   获得银行帮助内表
DATA: BEGIN OF gt_bnka OCCURS 0,
        bankl LIKE pa0009-bankl,  "编号
        banka LIKE bnka-banka,    "名称
      END OF gt_bnka.

* 员工工龄工资计算结果内表
DATA: BEGIN OF gt_list OCCURS 0,
        orgeh  LIKE pa0001-orgeh,       "部门
        orgtx  LIKE t527x-orgtx,        "组织单元文本
        pernr  LIKE pa0001-pernr,       "员工编号
        ename  LIKE pa0001-ename,       "员工姓名
        yfjj   TYPE p DECIMALS 2,       "应发奖金
        zfgjjg TYPE p DECIMALS 2,       "住房公积金
        zfgjjd TYPE p DECIMALS 2,       "住房公积金(单位)
        sqkk   TYPE p DECIMALS 2,       "税前扣款
*        ynse   type p DECIMALS 2,       "应纳税额
        se     TYPE p DECIMALS 2,       "税额
        shkk   TYPE p DECIMALS 2,       "税后扣款
        qthj   TYPE p DECIMALS 2,       "其他金额
        qt     TYPE p DECIMALS 2,       "其他金额
        byj    TYPE p DECIMALS 2,       "备用金
        sfhj    TYPE p DECIMALS 2,       "实发合计
        bankl  LIKE p0009-bankl,        "发卡行
        banka  LIKE bnka_bf-banka,      "发卡行
        bankn  TYPE p0009-bankn,        "银行帐号
        lx(6)  TYPE c,                  "是否留现
      END OF gt_list.
**计算中间表
*T7CN33免除税额信息内表
DATA: gt_t7cn33 LIKE t7cn33 OCCURS 0 WITH HEADER LINE.
*信息类型0530员工住房公积金信息内表
DATA: gt_pa0530 LIKE pa0530 OCCURS 0 WITH HEADER LINE.
*pa0267人力资源主记录: 信息类型 0267 (循环外一次性支付)
DATA: gt_pa0267 LIKE pa0267 OCCURS 0 WITH HEADER LINE.
* 信息类型0000员工状态信息内表
DATA: gt_pa0000 LIKE pa0000 OCCURS 0 WITH HEADER LINE.
* 信息类型0014员工工龄工资信息内表
DATA: gt_pa0014 LIKE pa0014 OCCURS 0 WITH HEADER LINE.
* 信息类型1000(组织单元文本)信息内表
DATA: gt_hrp1000 LIKE hrp1000 OCCURS 0 WITH HEADER LINE.
* 成本中心文本信息内表
DATA: gt_cskt LIKE cskt OCCURS 0 WITH HEADER LINE.
* 信息类型0001员工状态信息内表
DATA: BEGIN OF gt_pa0001 OCCURS 0,
        pernr  LIKE pa0001-pernr,       "员工编号
        ename  LIKE pa0001-ename,       "员工姓名
        orgeh  LIKE pa0001-orgeh,       "组织单元
        orgtx  LIKE t527x-orgtx,        "组织单元文本
        bankl  LIKE p0009-bankl,        "发卡行
        banka  LIKE bnka_bf-banka,      "发卡行
        bankn  TYPE p0009-bankn,        "银行帐号
        lx(6)  TYPE c,                  "是否留现
      END OF gt_pa0001.
* 信息类型0009员工卡信息内表
DATA: BEGIN OF gt_pa00091 OCCURS 0,
        pernr  LIKE pa0001-pernr,       "员工编号
        subty  LIKE pa0009-subty,       "子类型
      END OF gt_pa00091.
DATA: BEGIN OF gt_pa00092 OCCURS 0,
        pernr  LIKE pa0001-pernr,       "员工编号
        subty  LIKE pa0009-subty,       "子类型
        bankl  LIKE pa0009-bankl,       "银行代码
        bankn  LIKE pa0009-bankn,       "银行帐户编号
        banka  LIKE bnka-banka,         "银行名称
      END OF gt_pa00092.
*----------------------------------------------------------------------*
* GLOBAL VARIABLES                                                     *
*----------------------------------------------------------------------*
DATA: g_repid LIKE sy-repid,                 "当前程序
      g_dynnum LIKE sy-dynnr.                "当前屏幕
DATA: gt_fieldcat TYPE slis_t_fieldcat_alv,
      gt_sort     TYPE slis_t_sortinfo_alv.
DATA: g_sdate LIKE sy-datum,                  "时间计算中间变量
      g_edate LIKE sy-datum,
      g_ktext LIKE cskt-ktext,                "单个成本中心文本
       g_orgtx LIKE t527x-orgtx .             "单个组织单元
*----------------------------------------------------------------------*
* PARAMETERS AND SELECT-OPTIONS                                        *
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b_2 WITH FRAME TITLE text-002.
SELECT-OPTIONS: s_werks FOR pa0001-werks,             "人事范围
                s_btrtl FOR pa0001-btrtl,             "人事子范围
                s_persg FOR pa0001-persg,             "员工组
                s_persk FOR pa0001-persk,             "员工子组
                s_orgeh FOR pa0001-orgeh,             "部门(组织单元)
                s_kostl FOR pa0001-kostl,             "成本中心
                s_pernr FOR pa0001-pernr.             "员工编号
SELECTION-SCREEN END OF BLOCK b_2.
SELECTION-SCREEN BEGIN OF BLOCK b_1 WITH FRAME TITLE text-001.
PARAMETERS: p_mon RADIOBUTTON GROUP tst1 DEFAULT 'X',
            p_ann RADIOBUTTON GROUP tst1.
PARAMETERS: p_cxsj LIKE sy-datum  DEFAULT sy-datum.   "查询时间
SELECTION-SCREEN END OF BLOCK b_1.

SELECTION-SCREEN BEGIN OF BLOCK b_0 WITH FRAME TITLE text-003.
PARAMETERS:  p_quan RADIOBUTTON GROUP gr1 DEFAULT 'X',    "发放方式-全部
             p_show RADIOBUTTON GROUP gr1,    "发放方式-银行卡
             p_calc RADIOBUTTON GROUP gr1.    "发放方式-留现
SELECT-OPTIONS: s_bankl FOR pa0009-bankl."发卡行选择
SELECTION-SCREEN END OF BLOCK b_0.

*----------------------------------------------------------------------*
* INITIALIZATION                                                       *
*----------------------------------------------------------------------*
INITIALIZATION.
  g_repid = sy-repid.
  g_dynnum = sy-dynnr.

* 获得人事范围帮助内表
  REFRESH gt_werks_h.
  SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_werks_h
    FROM t500p
   WHERE persa IN ('1002','3001').

* 部门文本信息内表
  REFRESH gt_hrp1000.
  SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_hrp1000
    FROM hrp1000
   WHERE otype = 'O'
     AND langu = '1'
   ORDER BY objid.

* 成本中心文本信息内表
  REFRESH gt_cskt.
  SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_cskt
    FROM cskt
   WHERE spras = '1'
     AND datbi = '99991231'
   ORDER BY kostl.

* 获得部门(组织单元)与成本中心的对应关系内表
  REFRESH gt_orgeh_kostl.
  SELECT DISTINCT werks orgeh kostl
    INTO CORRESPONDING FIELDS OF TABLE gt_orgeh_kostl
    FROM pa0001
   WHERE endda = '99991231'
   ORDER BY werks orgeh kostl.

*银行信息内表
  REFRESH gt_bnka.
  SELECT DISTINCT bankl banka INTO TABLE gt_bnka
   FROM bnka
  WHERE banks = 'CN' AND bankl IN ('0000000999','0000000888','0000000111').
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN                                                  *
*----------------------------------------------------------------------*
* 人事范围帮助选择
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_werks-low.
  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield    = 'PERSA'
      dynpprog    = g_repid
      dynpnr      = g_dynnum
      dynprofield = 'S_WERKS'
      value_org   = 'S'
    TABLES
      value_tab   = gt_werks_h.
  PERFORM clear_orgeh.
  PERFORM clear_kostl.
  PERFORM clear_pernr.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_werks-high.
  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield    = 'PERSA'
      dynpprog    = g_repid
      dynpnr      = g_dynnum
      dynprofield = 'S_WERKS'
      value_org   = 'S'
    TABLES
      value_tab   = gt_werks_h.
  PERFORM clear_orgeh.
  PERFORM clear_kostl.
  PERFORM clear_pernr.

* 获得部门(组织单元)选择帮助
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_orgeh-low.
  PERFORM read_werks_value.
  PERFORM get_orgeh_h.
  PERFORM clear_kostl.
  PERFORM clear_pernr.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_orgeh-high.
  PERFORM read_werks_value.
  PERFORM get_orgeh_h.
  PERFORM clear_kostl.
  PERFORM clear_pernr.

* 获得成本中心选择帮助
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_kostl-low.
  PERFORM read_werks_value.
  PERFORM read_orgeh_value.
  PERFORM get_kostl_h.
  PERFORM clear_pernr.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_kostl-high.
  PERFORM read_werks_value.
  PERFORM read_orgeh_value.
  PERFORM get_kostl_h.
  PERFORM clear_pernr.

* 获得员工选择帮助
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_pernr-low.
  PERFORM read_werks_value.
  PERFORM read_orgeh_value.
  PERFORM read_kostl_value.
  PERFORM get_pernr_h.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_pernr-high.
  PERFORM read_werks_value.
  PERFORM read_orgeh_value.
  PERFORM read_kostl_value.
  PERFORM get_pernr_h.

*获得银行选择帮助
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_bankl-low.
  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield    = 'BANKL'
      dynpprog    = g_repid
      dynpnr      = g_dynnum
      dynprofield = 'S_BANKL'
      value_org   = 'S'
    TABLES
      value_tab   = gt_bnka.
*获得银行选择帮助
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_bankl-high.
  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield    = 'BANKL'
      dynpprog    = g_repid
      dynpnr      = g_dynnum
      dynprofield = 'S_BANKL'
      value_org   = 'S'
    TABLES
      value_tab   = gt_bnka.

*----------------------------------------------------------------------*
*AT SELECTION-SCREEN.                                                *
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
  CONCATENATE  p_cxsj+0(6)  '01' INTO g_sdate.
  CALL FUNCTION 'LAST_DAY_OF_MONTHS'
    EXPORTING
      day_in            = g_sdate
    IMPORTING
      last_day_of_month = g_edate.
*----------------------------------------------------------------------*
* START-OF-SELECTION                                                   *
*----------------------------------------------------------------------*
START-OF-SELECTION.
*提取数据
  PERFORM select_data.
*计算数据
  PERFORM calc_data.
*----------------------------------------------------------------------*
* END-OF-SELECTION                                                     *
*----------------------------------------------------------------------*
END-OF-SELECTION.
  PERFORM f_fieldcat_init USING gt_fieldcat[] gt_sort[].
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program = g_repid
      it_fieldcat        = gt_fieldcat[]
      it_sort            = gt_sort[]
*      it_events          = event_top_of_page[]
      i_callback_html_top_of_page = 'HTML_TOP_OF_PAGE'
    TABLES
      t_outtab           = gt_list.
************************************************************************
* Form Name    : html_top_of_page                                     *
* Created by   :                                                  *
* Created on   : 2004/09/01                                            *
*----------------------------------------------------------------------*
* Function Description:                                                *
* 设置HTML报表页头                                                     *
*----------------------------------------------------------------------*
* 参数说明                                                            *
*  document:报表页头设置参数                                          *
*----------------------------------------------------------------------*
* Date        Programmer   Description                              *
*                                                                      *
************************************************************************
FORM html_top_of_page USING document TYPE REF TO cl_dd_document.
  DATA: text TYPE sdydo_text_element.
  CALL METHOD document->add_gap
    EXPORTING
      width = 50.
  text =  '员工奖金模拟明细表'.
  CALL METHOD document->add_text
    EXPORTING
      text      = text
      sap_style = 'HEADING'.

  CALL METHOD document->new_line.

  text = '部门(组织单元):'.
  CALL METHOD document->add_text
    EXPORTING
      text         = text
      sap_emphasis = 'Strong'.
*  CALL METHOD document->add_gap
*    EXPORTING
*      width = 6.
*
  text = g_orgtx.
  CALL METHOD document->add_text
    EXPORTING
      text      = text
      sap_style = 'Key'.

  CALL METHOD document->new_line.
  text = '所属成本中心 : '.
  CALL METHOD document->add_text
    EXPORTING
      text         = text
      sap_emphasis = 'Strong'.
*  CALL METHOD document->add_gap
*    EXPORTING
*      width = 6.
  text = g_ktext.
  CALL METHOD document->add_text
    EXPORTING
      text      = text
      sap_style = 'Key'.
  CALL METHOD document->new_line.
  IF p_mon ='X'.
    text = '月奖发放时间 : '.
  ELSE.
    text = '年终奖发放时间:'.
  ENDIF.
  CALL METHOD document->add_text
    EXPORTING
      text         = text
      sap_emphasis = 'Strong'.
  text =  p_cxsj .
  CALL METHOD document->add_text
    EXPORTING
      text      = text
      sap_style = 'Key'.
  CALL METHOD document->add_gap
    EXPORTING
      width = 100.
  text = '奖金所属时间:'.
  CALL METHOD document->add_text
    EXPORTING
      text         = text
      sap_emphasis = 'Strong'.
  CONCATENATE  zhr_jjdr-zksyf '-'  zhr_jjdr-zjsyf INTO text.
  CALL METHOD document->add_text
    EXPORTING
      text      = text
      sap_style = 'Key'.
  CALL METHOD document->new_line.
ENDFORM.                    "HTML_TOP_OF_PAGE
************************************************************************
* Form Name    : f_fieldcat_init                                       *
* Created by   :                                                  *
* Created on   : 2004/09/01                                            *
*----------------------------------------------------------------------*
* Function Description:                                                *
* 定义报表格式                                                         *
*----------------------------------------------------------------------*
* 参数说明                                                            *
* im_fieldcat:报表格式设置参数                                        *
*----------------------------------------------------------------------*
* Date        Programmer   Description               *
*                                                                      *
************************************************************************
FORM f_fieldcat_init USING im_fieldcat TYPE slis_t_fieldcat_alv
                           im_sort TYPE slis_t_sortinfo_alv.
  DATA: ls_fieldcat TYPE slis_fieldcat_alv,
        ls_sort TYPE slis_sortinfo_alv.

  REFRESH im_fieldcat.
  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname = 'ORGEH'.
  ls_fieldcat-seltext_l = '部门'.
  ls_fieldcat-outputlen = '10'.
  APPEND ls_fieldcat TO im_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname = 'ORGYX'.
  ls_fieldcat-seltext_l = '部门名称'.
  ls_fieldcat-outputlen = '10'.
  APPEND ls_fieldcat TO im_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname = 'PERNR'.
  ls_fieldcat-seltext_l = '员工编号'.
  ls_fieldcat-outputlen = '8'.
  APPEND ls_fieldcat TO im_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname = 'ENAME'.
  ls_fieldcat-seltext_l = '员工姓名'.
  ls_fieldcat-outputlen = '10'.
  APPEND ls_fieldcat TO im_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname = 'YFJJ'.
  ls_fieldcat-seltext_l = '应发奖金'.
  ls_fieldcat-outputlen = '10'.
  ls_fieldcat-do_sum = 'X'.
  ls_fieldcat-no_zero = 'X'.
  APPEND ls_fieldcat TO gt_fieldcat.
  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname = 'ZFGJJG'.
  ls_fieldcat-seltext_l = '住房公积金(个)'.
  ls_fieldcat-outputlen = '10'.
  ls_fieldcat-do_sum = 'X'.
  ls_fieldcat-no_zero = 'X'.
  APPEND ls_fieldcat TO gt_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname = 'ZFGJJD'.
  ls_fieldcat-seltext_l = '住房公积金(单)'.
  ls_fieldcat-outputlen = '10'.
  ls_fieldcat-do_sum = 'X'.
  ls_fieldcat-no_zero = 'X'.
  APPEND ls_fieldcat TO gt_fieldcat.
  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname = 'SQKK'.
  ls_fieldcat-seltext_l = '税前扣款'.
  ls_fieldcat-outputlen = '10'.
  ls_fieldcat-do_sum = 'X'.
  ls_fieldcat-no_zero = 'X'.
  APPEND ls_fieldcat TO gt_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname = 'SE'.
  ls_fieldcat-seltext_l = '税额'.
  ls_fieldcat-outputlen = '10'.
  ls_fieldcat-do_sum = 'X'.
  ls_fieldcat-no_zero = 'X'.
  APPEND ls_fieldcat TO gt_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname = 'SHKK'.
  ls_fieldcat-seltext_l = '税后扣款'.
  ls_fieldcat-outputlen = '10'.
  ls_fieldcat-do_sum = 'X'.
  ls_fieldcat-no_zero = 'X'.
  APPEND ls_fieldcat TO gt_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname = 'QT'.
  ls_fieldcat-seltext_l = '其他'.
  ls_fieldcat-outputlen = '10'.
  ls_fieldcat-do_sum = 'X'.
  ls_fieldcat-no_zero = 'X'.
  APPEND ls_fieldcat TO gt_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname = 'BYJ'.
  ls_fieldcat-seltext_l = '备用金'.
  ls_fieldcat-outputlen = '10'.
  ls_fieldcat-do_sum = 'X'.
  ls_fieldcat-no_zero = 'X'.
  APPEND ls_fieldcat TO gt_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname = 'SFHJ'.
  ls_fieldcat-seltext_l = '实发合计'.
  ls_fieldcat-outputlen = '8'.
  ls_fieldcat-do_sum = 'X'.
  ls_fieldcat-no_zero = 'X'.
  APPEND ls_fieldcat TO gt_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname = 'BANKL'.
  ls_fieldcat-seltext_l = '发卡行'.
  ls_fieldcat-outputlen = '12'.
  APPEND ls_fieldcat TO gt_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname = 'BANKA'.
  ls_fieldcat-seltext_l = '银行名称'.
  ls_fieldcat-outputlen = '15'.
  APPEND ls_fieldcat TO gt_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname = 'BANKN'.
  ls_fieldcat-seltext_l = '银行帐号'.
  ls_fieldcat-outputlen = '15'.
  APPEND ls_fieldcat TO gt_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname = 'LX'.
  ls_fieldcat-seltext_l = '是否留现'.
  ls_fieldcat-outputlen = '4'.
  APPEND ls_fieldcat TO gt_fieldcat.

  CLEAR ls_sort.
  ls_sort-fieldname = 'ORGEH'.
  ls_sort-spos      = 1.
  ls_sort-up        = 'X'.
  ls_sort-subtot    = 'X'.
  APPEND ls_sort TO gt_sort.

  CLEAR ls_sort.
  ls_sort-fieldname = 'PERNR'.
  ls_sort-spos      = 2.
  ls_sort-up        = 'X'.
* ls_sort-subtot    = 'X'.
  APPEND ls_sort TO gt_sort.
ENDFORM.                    "f_fieldcat_init
************************************************************************
* Form Name    : select_data                                           *
* Created by   :                                                  *
* Created on   : 2004/09/21                                            *
*----------------------------------------------------------------------*
* Function Description:                                                *
* 对员工进行提取数据                                                   *
*----------------------------------------------------------------------*
* 参数说明                                                            *
*                                                                      *
*----------------------------------------------------------------------*
* Date        Programmer   Description                         *
*                                                                      *
************************************************************************
FORM select_data .
  DATA:    l_count    TYPE i.
*读取成本中心
  SELECT COUNT( * ) INTO (l_count)
    FROM csks
    WHERE  csks~kostl IN s_kostl
      AND datbi >= p_cxsj AND datab <= p_cxsj.
  IF l_count = 1.
    SELECT SINGLE cskt~ktext INTO (g_ktext)
      FROM csks
        LEFT JOIN cskt
         ON cskt~spras = '1' AND csks~kokrs =  cskt~kokrs
           AND csks~kostl = cskt~kostl
    WHERE  csks~kostl IN s_kostl
      AND csks~datbi >= p_cxsj AND csks~datab <= p_cxsj.
  ELSE.
    g_ktext  = space.
  ENDIF.
* 部门文本信息内表
  SELECT COUNT( * ) INTO (l_count)
    FROM t527x
    WHERE  t527x~orgeh IN s_orgeh
      AND endda >= p_cxsj AND begda <= p_cxsj.
  IF l_count = 1.
    SELECT SINGLE orgtx INTO (g_orgtx)
      FROM t527x
      WHERE sprsl = '1' AND  t527x~orgeh IN s_orgeh
        AND endda >= p_cxsj AND begda <= p_cxsj.
  ELSE.
    g_orgtx  = space.
  ENDIF.

*提取员工
  REFRESH gt_pa0001.
  CLEAR gt_pa0001.
  SELECT pa0001~pernr pa0001~ename pa0001~orgeh t527x~orgtx
    INTO CORRESPONDING FIELDS OF TABLE gt_pa0001
    FROM pa0001
      INNER JOIN t527x
        ON  t527x~sprsl = '1' AND pa0001~orgeh = t527x~orgeh
     WHERE pa0001~werks IN s_werks
     AND pa0001~btrtl IN s_btrtl
     AND pa0001~persg IN s_persg
     AND pa0001~persk IN s_persk
     AND pa0001~orgeh IN s_orgeh
     AND pa0001~kostl IN s_kostl
     AND pa0001~pernr IN s_pernr
     AND pa0001~endda >=  p_cxsj AND pa0001~begda <= p_cxsj
     AND t527x~endda >=  p_cxsj AND t527x~begda <= p_cxsj.
*删除不符合卡条件的人员
*  判断员工是否留现
  REFRESH  gt_pa00091.
  CLEAR  gt_pa00091.
  SELECT pernr subty
     INTO CORRESPONDING FIELDS OF TABLE gt_pa00091
  FROM pa0009
     FOR ALL ENTRIES IN gt_pa0001
   WHERE pernr = gt_pa0001-pernr
    AND pa0009~subty = '0'
    AND pa0009~begda <= p_cxsj AND pa0009~endda >= p_cxsj.
*  获得员工工资发卡行及银行帐号
  REFRESH gt_pa00092.
  CLEAR gt_pa00092.
  IF p_calc = space.
    SELECT pa0009~pernr pa0009~subty pa0009~bankl pa0009~bankn bnka~banka
         INTO CORRESPONDING FIELDS OF TABLE gt_pa00092
     FROM  pa0009
      INNER JOIN bnka ON pa0009~bankl = bnka~bankl AND bnka~banks = 'CN'
      FOR ALL entries IN gt_pa0001
     WHERE pernr = gt_pa0001-pernr
      AND pa0009~begda <= sy-datum AND pa0009~endda >= sy-datum
      AND pa0009~bankl IN s_bankl.
  ENDIF.
  SORT gt_pa00092 BY pernr.
  DELETE ADJACENT DUPLICATES FROM gt_pa00092 COMPARING pernr.
  SORT gt_pa00091 BY pernr.
  DELETE ADJACENT DUPLICATES FROM gt_pa00091 COMPARING pernr.
  LOOP AT gt_pa0001.
    READ TABLE  gt_pa00091 WITH KEY pernr = gt_pa0001-pernr BINARY SEARCH.
    IF sy-subrc = 0.
      IF p_calc = 'X'."只显示留现
        DELETE gt_pa0001.
        CONTINUE.
      ENDIF.
    ELSE.
      IF p_show = 'X'."只显示留现
        DELETE gt_pa0001.
        CONTINUE.
      ELSE.
        gt_pa0001-lx = '留现'.
      ENDIF.
    ENDIF.
    IF p_calc = 'X'."只显示留现
      READ TABLE  gt_pa00092 WITH KEY pernr = gt_pa0001-pernr BINARY SEARCH.
      IF sy-subrc = 0.
        gt_pa0001-bankl = gt_pa00092-bankl.
        gt_pa0001-banka = gt_pa00092-banka.
        gt_pa0001-bankn = gt_pa00092-bankn.
      ENDIF.
    ENDIF.
    MODIFY gt_pa0001.
  ENDLOOP.
*获得员工免除税额信息
  REFRESH gt_t7cn33.
  CLEAR gt_t7cn33.
  SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_t7cn33 FROM t7cn33
   WHERE endda >= p_cxsj AND begda <= p_cxsj.
  SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_pa0530 FROM pa0530
    FOR ALL ENTRIES IN gt_pa0001
  WHERE pernr = gt_pa0001-pernr
   AND endda >= p_cxsj AND begda <= p_cxsj.
*提取奖金项
  IF p_mon ='X'.
    SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_pa0267
    FROM pa0267
      FOR ALL ENTRIES IN gt_pa0001
    WHERE pernr = gt_pa0001-pernr
      AND endda = p_cxsj
        AND lgart IN ('6100','6200','6600','6600','6900','6510',
                      '6520','6530','6540','6550','6560','6570',
                      '6580','6590','6500','6710','6720').
*获取公积金
    REFRESH gt_pa0014.
    CLEAR gt_pa0014.
    SELECT *
      INTO  CORRESPONDING FIELDS OF TABLE  gt_pa0014
      FROM pa0014
    FOR ALL ENTRIES IN gt_pa0001
      WHERE pernr = gt_pa0001-pernr
        AND endda >= p_cxsj AND begda <= p_cxsj
        AND lgart = '2920'.
  ELSE.
    SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_pa0267
    FROM pa0267
      FOR ALL ENTRIES IN gt_pa0001
    WHERE pernr = gt_pa0001-pernr
      AND endda = p_cxsj
        AND lgart IN ('9100','9510','9520','9530','9540','9550',
                      '9560','9570','9580','9590','9500','9710',
                      '9720').
  ENDIF.
**获取导入数据
  CLEAR zhr_jjdr.
  SELECT SINGLE * INTO zhr_jjdr
    FROM zhr_jjdr
   WHERE  begda = p_cxsj.
ENDFORM.                    " select_data
************************************************************************
* Form Name    : calc_data                                             *
* Created by   :                                                  *
* Created on   : 2004/09/03                                            *
*----------------------------------------------------------------------*
* Function Description:                                                *
* 对员工进行工龄工资的计算                                             *
*----------------------------------------------------------------------*
* 参数说明                                                            *
*                                                                      *
*----------------------------------------------------------------------*
* Date        Programmer   Description                         *
*                                                                      *
************************************************************************
FORM calc_data .
  DATA: l_i0014 TYPE i VALUE 0, l_i0267 TYPE i VALUE 0.
  DATA: l_dis(1),l_div(1).
  DATA: l_ynse  TYPE p DECIMALS 2,
        l_ffje  TYPE p DECIMALS 2,
        l_ffse  TYPE p DECIMALS 2.
  SORT gt_pa0001 BY pernr.
  SORT gt_pa0267 BY pernr.
  SORT gt_pa0014 BY pernr.

  LOOP AT gt_pa0001.
    CLEAR gt_list.
    l_dis = space.
    l_div = space.
    MOVE-CORRESPONDING gt_pa0001 TO gt_list.
    LOOP AT gt_pa0267  FROM l_i0267.
      IF gt_pa0267-pernr > gt_pa0001-pernr.
        l_i0014 = sy-tabix.
        EXIT.
      ELSEIF gt_pa0267-pernr = gt_pa0001-pernr.
        CASE gt_pa0267-lgart .
          WHEN '6100'.
            gt_list-yfjj = gt_list-yfjj + gt_pa0267-betrg.
            l_dis = 'X'.
          WHEN '6200'.
            gt_list-yfjj = gt_list-yfjj + gt_pa0267-betrg.
            l_dis = 'X'.
            l_div = 'X'.
          WHEN '6600'.
            gt_list-yfjj = gt_list-yfjj + gt_pa0267-betrg.
          WHEN '6900'.
            gt_list-yfjj = gt_list-yfjj + gt_pa0267-betrg.
          WHEN '9100'.
            gt_list-yfjj = gt_list-yfjj + gt_pa0267-betrg.
          WHEN '6510' OR '6520' OR '6530' OR '6540' OR '6550' OR
               '6560' OR '6570' OR '6580' OR '6590' OR '6500' OR
               '9510' OR '9520' OR '9530' OR '9540' OR '9550' OR
               '9560' OR '9570' OR '9580' OR '9590' OR '9500'.
            gt_list-sqkk = gt_list-sqkk + gt_pa0267-betrg.
          WHEN '6710' OR '9710'.
            gt_list-byj = gt_list-byj + gt_pa0267-betrg.
            gt_list-shkk = gt_list-shkk + gt_pa0267-betrg.
          WHEN '6720' OR '9720'.
            gt_list-qt = gt_list-qt + gt_pa0267-betrg.
            gt_list-shkk = gt_list-shkk + gt_pa0267-betrg.
        ENDCASE.
      ENDIF.
    ENDLOOP.
    LOOP AT gt_pa0014  FROM l_i0014.
      IF gt_pa0014-pernr > gt_pa0001-pernr.
        l_i0014 = sy-tabix.
        EXIT.
      ELSEIF gt_pa0014-pernr = gt_pa0001-pernr.
        CASE gt_pa0014-lgart .
          WHEN '2920'.
            gt_list-zfgjjg = gt_list-zfgjjg + gt_pa0014-betrg.
            gt_list-zfgjjd = gt_list-zfgjjd + gt_pa0014-betrg.
        ENDCASE.
      ENDIF.
    ENDLOOP.
    IF l_dis = space.
      gt_list-zfgjjg = 0.
      gt_list-zfgjjd = 0.
    ELSEIF l_div = 'X'.
      gt_list-zfgjjg = gt_list-zfgjjg / 2.
      gt_list-zfgjjd = gt_list-zfgjjg / 2.
    ENDIF.
    APPEND gt_list.
  ENDLOOP.
  LOOP AT gt_list.
    l_ynse = 0.
    l_ffje = 0.
    l_ffse = 0.
    READ TABLE gt_pa0530 WITH KEY pernr = gt_list-pernr.
    IF sy-subrc = 0.
      READ TABLE gt_t7cn33 WITH KEY txare = gt_pa0530-conar .
      IF sy-subrc = 0.
        IF p_mon = 'X'.
          PERFORM calc_payroll USING gt_list-pernr l_ffje l_ffse.
          l_ynse = gt_list-yfjj + l_ffje - gt_list-sqkk - gt_list-zfgjjg - gt_list-zfgjjd.
          l_ynse = l_ynse - gt_t7cn33-expam.
          IF l_ynse <= gt_t7cn33-expam.
            gt_list-se = 0.
          ELSEIF l_ynse > gt_t7cn33-expam.
            IF ( l_ynse > '0.01'  AND  l_ynse < '500.01' ) .
              gt_list-se = l_ynse * '0.05' - l_ffse.
            ELSEIF ( l_ynse >= '500.01' AND l_ynse < '2000.01').
              gt_list-se = l_ynse * '0.1' - 25 - l_ffse.
            ELSEIF ( l_ynse >= '2000.01' AND l_ynse < '5000.01').
              gt_list-se = l_ynse * '0.15' - 125 - l_ffse.
            ELSEIF ( l_ynse >= '5000.01' AND l_ynse < '20000.01').
              gt_list-se = l_ynse * '0.20' - 375 - l_ffse.
            ELSEIF ( l_ynse >= '20000.01' AND l_ynse < '40000.01').
              gt_list-se = l_ynse * '0.25' - 1375 - l_ffse.
            ELSEIF ( l_ynse >= '40000.01' AND l_ynse < '60000.01').
              gt_list-se = l_ynse * '0.30' - 3375 - l_ffse.
            ELSEIF ( l_ynse >= '60000.01' AND l_ynse < '80000.01').
              gt_list-se = l_ynse * '0.35' - 6375 - l_ffse.
            ELSEIF ( l_ynse >= '80000.01' AND l_ynse < '100000.01').
              gt_list-se = l_ynse * '0.40' - 10375 - l_ffse.
            ELSEIF ( l_ynse >= '100000.01' ).
              gt_list-se = l_ynse * '0.45' - 15375 - l_ffse.
            ENDIF.
          ENDIF.
        ELSE.
          l_ynse = ( gt_list-yfjj - gt_list-sqkk ) / '12.0'.
*          l_ynse = l_ynse - gt_t7cn33-expam.
          IF l_ynse <= gt_t7cn33-expam.
            gt_list-se = 0.
          ELSEIF l_ynse > gt_t7cn33-expam.
            IF ( l_ynse > '0.01'  AND  l_ynse < '500.01' ) .
              gt_list-se = l_ynse * '0.05' .
            ELSEIF ( l_ynse >= '500.01' AND l_ynse < '2000.01').
              gt_list-se = l_ynse * '0.1' - 25 .
            ELSEIF ( l_ynse >= '2000.01' AND l_ynse < '5000.01').
              gt_list-se = l_ynse * '0.15' - 125.
            ELSEIF ( l_ynse >= '5000.01' AND l_ynse < '20000.01').
              gt_list-se = l_ynse * '0.20' - 375 .
            ELSEIF ( l_ynse >= '20000.01' AND l_ynse < '40000.01').
              gt_list-se = l_ynse * '0.25' - 1375.
            ELSEIF ( l_ynse >= '40000.01' AND l_ynse < '60000.01').
              gt_list-se = l_ynse * '0.30' - 3375 .
            ELSEIF ( l_ynse >= '60000.01' AND l_ynse < '80000.01').
              gt_list-se = l_ynse * '0.35' - 6375 .
            ELSEIF ( l_ynse >= '80000.01' AND l_ynse < '100000.01').
              gt_list-se = l_ynse * '0.40' - 10375 .
            ELSEIF ( l_ynse >= '100000.01' ).
              gt_list-se = l_ynse * '0.45' - 15375 .
            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDIF.
    gt_list-sfhj =  gt_list-yfjj - gt_list-sqkk - gt_list-se * 12 - gt_list-shkk.
    MODIFY gt_list.
  ENDLOOP.
  DELETE gt_list WHERE yfjj = 0.
ENDFORM.                    " calc_data
************************************************************************
* Form Name    : calc_payroll                                          *
* Created by   :                                                  *
* Created on   : 2004/09/24                                            *
*----------------------------------------------------------------------*
* Function Description:                                                *
* 对员工进行计算已经发放金额和扣税金额
*----------------------------------------------------------------------*
* 参数说明                                                            *
*-->IM_pernr:人员编号
*<--EX_ffje:应扣税金额合计
*<--EX_ffse: 扣税合计
*----------------------------------------------------------------------*
* Date        Programmer   Description                         *
*                                                                      *
************************************************************************
FORM calc_payroll  USING    im_pernr
                            ex_ffje
                            ex_ffse.
  DATA:BEGIN OF lt_rgdir OCCURS 100.
          INCLUDE STRUCTURE pc261.
  DATA:END OF lt_rgdir.
  DATA:lt_result1 TYPE pay99_result.
  DATA:wa_rt_header TYPE LINE OF hrpay99_rt,
        l_country LIKE t001p-molga,
        l_number LIKE pc261-seqnr.
*  计算工资核算记录
  REFRESH lt_rgdir.
  CALL FUNCTION 'CU_READ_RGDIR'
    EXPORTING
      persnr          = im_pernr
*      importing
*        molga           = g_country
    TABLES
      in_rgdir        = lt_rgdir
    EXCEPTIONS
      no_record_found = 1
      OTHERS          = 2.
*  根据用户输入的工资核算月份,提取该员工工资RT的NUMBER
  LOOP AT lt_rgdir WHERE srtza = 'A' AND  payty = space
     AND fpbeg BETWEEN g_sdate AND g_edate.
    CLEAR l_number.
    l_number = lt_rgdir-seqnr.
    REFRESH lt_result1-inter-rt.
    CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT'
      EXPORTING
        employeenumber               = im_pernr
        sequencenumber               = l_number
        read_only_international      = 'X'
        client                       = 'CN'
      CHANGING
        payroll_result               = lt_result1
      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
        OTHERS                       = 8.
    LOOP AT lt_result1-inter-rt INTO wa_rt_header.
      IF wa_rt_header-lgart = '/103'.
        ex_ffje = ex_ffje + wa_rt_header-betrg.
      ENDIF.
      IF wa_rt_header-lgart = '/403'.
        ex_ffse = ex_ffse + wa_rt_header-betrg.
      ENDIF.
      CLEAR wa_rt_header.
    ENDLOOP.
    CLEAR lt_rgdir.
  ENDLOOP.
ENDFORM.                    " calc_payroll
************************************************************************
* Form Name    : clear_orgeh                                           *
* Created by   :                                                  *
* Created on   : 2004/09/17                                            *
*----------------------------------------------------------------------*
* Function Description:                                                *
* 清除部门(组织单元)选项值                                             *
*----------------------------------------------------------------------*
* 参数说明                                                            *
*                                                                      *
*----------------------------------------------------------------------*
* Date        Programmer   Description                         *
*                                                                      *
************************************************************************
FORM clear_orgeh .
  DATA: dynpro_values TYPE TABLE OF dynpread,
        field_value LIKE LINE OF dynpro_values.

* 清空部门选项值
  CLEAR s_orgeh.
  REFRESH s_orgeh.
  field_value-fieldname = 'S_ORGEH-LOW'.
  field_value-fieldvalue = ''.
  APPEND field_value TO dynpro_values.
  field_value-fieldname = 'S_ORGEH-HIGH'.
  field_value-fieldvalue = ''.
  APPEND field_value TO dynpro_values.

  CALL FUNCTION 'DYNP_VALUES_UPDATE'
    EXPORTING
      dyname     = g_repid
      dynumb     = g_dynnum
    TABLES
      dynpfields = dynpro_values.

  REFRESH gt_orgeh_h.
ENDFORM.                    " clear_orgeh.
************************************************************************
* Form Name    : get_orgeh_h                                           *
* Created by   :                                                  *
* Created on   : 2004/09/17                                            *
*----------------------------------------------------------------------*
* Function Description:                                                *
* 获得部门帮助选择                                                     *
*----------------------------------------------------------------------*
* 参数说明                                                            *
*                                                                      *
*----------------------------------------------------------------------*
* Date        Programmer   Description                         *
*                                                                      *
************************************************************************
FORM get_orgeh_h .

  REFRESH gt_orgeh_h.
  LOOP AT gt_orgeh_kostl WHERE werks IN s_werks.
    CLEAR gt_orgeh_h.
    gt_orgeh_h-orgeh = gt_orgeh_kostl-orgeh.

    READ TABLE gt_hrp1000 WITH KEY objid = gt_orgeh_h-orgeh.
    IF sy-subrc = 0.
      gt_orgeh_h-stext = gt_hrp1000-stext.
      COLLECT gt_orgeh_h.
    ENDIF.
  ENDLOOP.

  SORT gt_orgeh_h BY orgeh.

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield    = 'ORGEH'
      dynpprog    = g_repid
      dynpnr      = g_dynnum
      dynprofield = 'S_ORGEH'
      value_org   = 'S'
    TABLES
      value_tab   = gt_orgeh_h.
ENDFORM.                    " get_orgeh_h
************************************************************************
* Form Name    : clear_kostl                                           *
* Created by   :                                                  *
* Created on   : 2004/09/25                                            *
*----------------------------------------------------------------------*
* Function Description:                                                *
* 清除成本中心选项值                                                   *
*----------------------------------------------------------------------*
* 参数说明                                                            *
*                                                                      *
*----------------------------------------------------------------------*
* Date        Programmer   Description                         *
*                                                                      *
************************************************************************
FORM clear_kostl .
  DATA: dynpro_values TYPE TABLE OF dynpread,
        field_value LIKE LINE OF dynpro_values.

* 清空成本中心选项值
  CLEAR s_kostl.
  REFRESH s_kostl.
  field_value-fieldname = 'S_KOSTL-LOW'.
  field_value-fieldvalue = ''.
  APPEND field_value TO dynpro_values.
  field_value-fieldname = 'S_KOSTL-HIGH'.
  field_value-fieldvalue = ''.
  APPEND field_value TO dynpro_values.

  CALL FUNCTION 'DYNP_VALUES_UPDATE'
    EXPORTING
      dyname     = g_repid
      dynumb     = g_dynnum
    TABLES
      dynpfields = dynpro_values.

  REFRESH gt_kostl_h.
ENDFORM.                    " clear_kostl
************************************************************************
* Form Name    : clear_pernr                                           *
* Created by   :                                                  *
* Created on   : 2004/09/25                                            *
*----------------------------------------------------------------------*
* Function Description:                                                *
* 清除员工选项值                                                       *
*----------------------------------------------------------------------*
* 参数说明                                                            *
*                                                                      *
*----------------------------------------------------------------------*
* Date        Programmer   Description                         *
*                                                                      *
************************************************************************
FORM clear_pernr .
  DATA: dynpro_values TYPE TABLE OF dynpread,
        field_value LIKE LINE OF dynpro_values.

* 清空成本中心选项值
  CLEAR s_pernr.
  REFRESH s_pernr.
  field_value-fieldname = 'S_PERNR-LOW'.
  field_value-fieldvalue = ''.
  APPEND field_value TO dynpro_values.
  field_value-fieldname = 'S_PERNR-HIGH'.
  field_value-fieldvalue = ''.
  APPEND field_value TO dynpro_values.

  CALL FUNCTION 'DYNP_VALUES_UPDATE'
    EXPORTING
      dyname     = g_repid
      dynumb     = g_dynnum
    TABLES
      dynpfields = dynpro_values.

  REFRESH gt_pernr_h.
ENDFORM.                    " clear_pernr
************************************************************************
* Form Name    : get_kostl_h                                           *
* Created by   :                                                  *
* Created on   : 2004/09/25                                            *
*----------------------------------------------------------------------*
* Function Description:                                                *
* 获得成本中心帮助选择                                                 *
*----------------------------------------------------------------------*
* 参数说明                                                            *
*                                                                      *
*----------------------------------------------------------------------*
* Date        Programmer   Description                         *
*                                                                      *
************************************************************************
FORM get_kostl_h .

  REFRESH gt_kostl_h.
  LOOP AT gt_orgeh_kostl WHERE werks IN s_werks
                           AND orgeh IN s_orgeh.
    CLEAR gt_kostl_h.
    gt_kostl_h-kostl = gt_orgeh_kostl-kostl.

    READ TABLE gt_cskt WITH KEY kostl = gt_kostl_h-kostl.
    IF sy-subrc = 0.
      gt_kostl_h-ktext = gt_cskt-ktext.
      COLLECT gt_kostl_h.
    ENDIF.
  ENDLOOP.

  SORT gt_kostl_h BY kostl.

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield    = 'KOSTL'
      dynpprog    = g_repid
      dynpnr      = g_dynnum
      dynprofield = 'S_KOSTL'
      value_org   = 'S'
    TABLES
      value_tab   = gt_kostl_h.
ENDFORM.                    " get_kostl_h
************************************************************************
* Form Name    : get_pernr_h                                           *
* Created by   :                                                  *
* Created on   : 2004/09/25                                            *
*----------------------------------------------------------------------*
* Function Description:                                                *
* 获得员工帮助选择                                                     *
*----------------------------------------------------------------------*
* 参数说明                                                            *
*                                                                      *
*----------------------------------------------------------------------*
* Date        Programmer   Description                         *
*                                                                      *
************************************************************************
FORM get_pernr_h .

  REFRESH gt_pernr_h.
  SELECT DISTINCT pernr ename INTO CORRESPONDING FIELDS OF TABLE gt_pernr_h
    FROM pa0001
   WHERE werks IN s_werks
     AND btrtl IN s_btrtl
     AND persg IN s_persg
     AND persk IN s_persk
     AND orgeh IN s_orgeh
     AND kostl IN s_kostl
     AND endda = '99991231'
   ORDER BY pernr.

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield    = 'PERNR'
      dynpprog    = g_repid
      dynpnr      = g_dynnum
      dynprofield = 'S_PERNR'
      value_org   = 'S'
    TABLES
      value_tab   = gt_pernr_h.
ENDFORM.                    " get_pernr_h
************************************************************************
* Form Name    : read_werks_value                                      *
* Created by   :                                                  *
* Created on   : 2004/09/25                                            *
*----------------------------------------------------------------------*
* Function Description:                                                *
* 将用户输入的人事范围值读入到条件范围变量中                           *
*----------------------------------------------------------------------*
* 参数说明                                                            *
*                                                                      *
*----------------------------------------------------------------------*
* Date        Programmer   Description                         *
*                                                                      *
************************************************************************
FORM read_werks_value .
  DATA: dynpro_values TYPE TABLE OF dynpread,
        field_value LIKE LINE OF dynpro_values,
        field_value_low LIKE LINE OF dynpro_values,
        field_value_high LIKE LINE OF dynpro_values,
        l_werks_l LIKE pa0001-werks,
        l_werks_h LIKE pa0001-werks.

  REFRESH dynpro_values.
  field_value-fieldname = 'S_WERKS-LOW'.
  APPEND field_value TO dynpro_values.
  field_value-fieldname = 'S_WERKS-HIGH'.
  APPEND field_value TO dynpro_values.

  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname             = g_repid
      dynumb             = g_dynnum
      translate_to_upper = 'X'
    TABLES
      dynpfields         = dynpro_values.

  READ TABLE dynpro_values INDEX 1 INTO field_value_low.
  READ TABLE dynpro_values INDEX 2 INTO field_value_high.
  REFRESH s_werks.
  IF field_value_low-fieldvalue <> space.
    l_werks_l = field_value_low-fieldvalue.
    IF field_value_high-fieldvalue <> space.
      l_werks_h = field_value_high-fieldvalue.
      s_werks-sign   = 'I'.
      s_werks-option = 'BT'.
      s_werks-low    = l_werks_l.
      s_werks-high   = l_werks_h.
      COLLECT s_werks.
    ELSE.
      s_werks-sign   = 'I'.
      s_werks-option = 'EQ'.
      s_werks-low    = l_werks_l.
      COLLECT s_werks.
    ENDIF.
  ELSEIF field_value_high-fieldvalue <> space.
    MESSAGE s037.
    EXIT.
  ENDIF.

ENDFORM.                    " read_werks_value
************************************************************************
* Form Name    : read_orgeh_value                                      *
* Created by   :                                                  *
* Created on   : 2004/09/17                                            *
*----------------------------------------------------------------------*
* Function Description:                                                *
* 将用户输入的部门读入到条件范围变量中                                 *
*----------------------------------------------------------------------*
* 参数说明                                                            *
*                                                                      *
*----------------------------------------------------------------------*
* Date        Programmer   Description                         *
*                                                                      *
************************************************************************
FORM read_orgeh_value .
  DATA: dynpro_values TYPE TABLE OF dynpread,
        field_value LIKE LINE OF dynpro_values,
        field_value_low LIKE LINE OF dynpro_values,
        field_value_high LIKE LINE OF dynpro_values,
        l_orgeh_l LIKE pa0001-orgeh,
        l_orgeh_h LIKE pa0001-orgeh.

  REFRESH dynpro_values.
  field_value-fieldname = 'S_ORGEH-LOW'.
  APPEND field_value TO dynpro_values.
  field_value-fieldname = 'S_ORGEH-HIGH'.
  APPEND field_value TO dynpro_values.

  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname             = g_repid
      dynumb             = g_dynnum
      translate_to_upper = 'X'
    TABLES
      dynpfields         = dynpro_values.

  READ TABLE dynpro_values INDEX 1 INTO field_value_low.
  READ TABLE dynpro_values INDEX 2 INTO field_value_high.
  REFRESH s_orgeh.
  IF field_value_low-fieldvalue <> space.
    l_orgeh_l = field_value_low-fieldvalue.
    IF field_value_high-fieldvalue <> space.
      l_orgeh_h = field_value_high-fieldvalue.
      s_orgeh-sign   = 'I'.
      s_orgeh-option = 'BT'.
      s_orgeh-low    = l_orgeh_l.
      s_orgeh-high   = l_orgeh_h.
      COLLECT s_orgeh.
    ELSE.
      s_orgeh-sign   = 'I'.
      s_orgeh-option = 'EQ'.
      s_orgeh-low    = l_orgeh_l.
      COLLECT s_orgeh.
    ENDIF.
  ELSEIF field_value_high-fieldvalue <> space.
    MESSAGE s037.
    EXIT.
  ENDIF.
ENDFORM.                    " read_orgeh_value
************************************************************************
* Form Name    : read_kostl_value                                      *
* Created by   :                                                  *
* Created on   : 2004/09/20                                            *
*----------------------------------------------------------------------*
* Function Description:                                                *
* 将用户输入的成本中心读入到条件范围变量中                             *
*----------------------------------------------------------------------*
* 参数说明                                                            *
*                                                                      *
*----------------------------------------------------------------------*
* Date        Programmer   Description                         *
*                                                                      *
************************************************************************
FORM read_kostl_value .
  DATA: dynpro_values TYPE TABLE OF dynpread,
        field_value LIKE LINE OF dynpro_values,
        field_value_low LIKE LINE OF dynpro_values,
        field_value_high LIKE LINE OF dynpro_values,
        l_kostl_l LIKE pa0001-kostl,
        l_kostl_h LIKE pa0001-kostl.

  REFRESH dynpro_values.
  field_value-fieldname = 'S_KOSTL-LOW'.
  APPEND field_value TO dynpro_values.
  field_value-fieldname = 'S_KOSTL-HIGH'.
  APPEND field_value TO dynpro_values.

  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname             = g_repid
      dynumb             = g_dynnum
      translate_to_upper = 'X'
    TABLES
      dynpfields         = dynpro_values.

  READ TABLE dynpro_values INDEX 1 INTO field_value_low.
  READ TABLE dynpro_values INDEX 2 INTO field_value_high.
  REFRESH s_kostl.
  IF field_value_low-fieldvalue <> space.
    l_kostl_l = field_value_low-fieldvalue.
    IF field_value_high-fieldvalue <> space.
      l_kostl_h = field_value_high-fieldvalue.
      s_kostl-sign   = 'I'.
      s_kostl-option = 'BT'.
      s_kostl-low    = l_kostl_l.
      s_kostl-high   = l_kostl_h.
      COLLECT s_kostl.
    ELSE.
      s_kostl-sign   = 'I'.
      s_kostl-option = 'EQ'.
      s_kostl-low    = l_kostl_l.
      COLLECT s_kostl.
    ENDIF.
  ELSEIF field_value_high-fieldvalue <> space.
    MESSAGE s037.
    EXIT.
  ENDIF.
ENDFORM.                    " read_kostl_value 

posted on 2007-09-25 14:35  毛小娃  阅读(302)  评论(0编辑  收藏  举报

导航