HR之PCH逻辑数据库的使用

PCH逻辑数据库,一般用于组织查询。和PNP很相像,如果非要说有不同,1、他的screen界面不是通过报告类进行控制的;2、他的查询逻辑是可以通过评估路径进行控制的

下面给一个代码:计算编制人数的程序,由于是本人第一次用PCH写程序,可能逻辑上不是很优化,望指正,如有问题可以留言或者加QQ:632055983进行探讨;

程序代码:

REPORT  ZHR_BZ_DISPLAY_DEPT.
INCLUDE ZHR_BZ_DISPLAY_DEPT_D01.
INCLUDE ZHR_BZ_DISPLAY_DEPT_S01.
INCLUDE ZHR_BZ_DISPLAY_DEPT_E01.
INCLUDE ZHR_BZ_DISPLAY_DEPT_F01.

*&---------------------------------------------------------------------*
*&  包括                ZHR_BZ_DISPLAY_DEPT_D01
*&---------------------------------------------------------------------*
TYPE-POOLS :SLIS.
TABLES: OBJEC,GDSTR,ZHR_PERSKTYPE ,PA0001.
INFOTYPES : 1000,  "员工子组
            1001,  "信息类型 1001:关系
            1002,  "描述
            1011,
            1015,
            1028.  "职级.

TYPES: BEGIN OF GX_MAIN,
  BYEAR(4),
  OBJID   TYPE HROBJID,  "岗位
  STEXT   TYPE STEXT,
  OBJID1  TYPE HROBJID,  "部门
  STEXT1  TYPE STEXT,
  CBZX    TYPE MAST_CCTR,
  CBZXMC  TYPE STEXT,
  BZRS    TYPE I,
  ZGRS    TYPE P DECIMALS 2,
  QRZRS   TYPE I,
  FQRZRS  TYPE I,
  CBRS    TYPE I,
  CBL     TYPE P DECIMALS 2,
  JB_A    TYPE I,  "副总监以上
  JB_B    TYPE I,  " 店长
  JB_C    TYPE I,  " 高级经理
  JB_D    TYPE I,  "经理
  JB_E    TYPE I,  "副经理
  JB_F    TYPE I,  " 主管/课长
  JB_G    TYPE I,   "资深
  JB_H    TYPE I,   "员工
  JB_O    TYPE I,    "qita
  END OF GX_MAIN.

DATA: GT_MAIN TYPE TABLE OF GX_MAIN,
      GS_MAIN TYPE GX_MAIN.

DATA: GT_YGZZ TYPE TABLE OF     ZHR_PERSKTYPE,  "员工子组
      GS_YGZZ TYPE     ZHR_PERSKTYPE.
DATA: GT_YGZJ TYPE TABLE OF ZHR_M_PLOMC,  "员工职级
      GS_YGZJ TYPE ZHR_M_PLOMC.

TYPES: BEGIN OF GX_P0001,
  PERNR TYPE PERNR_D,
  PERSK TYPE PERSK,
      END OF GX_P0001.
DATA: GT_P0001 TYPE TABLE OF GX_P0001,
      GS_P0001 TYPE GX_P0001.

TYPES: BEGIN OF GX_P0024,
  PERNR TYPE PERNR_D,
  ZWMC TYPE ZHR_ZWMC,
  END OF GX_P0024.
DATA: GT_P0024 TYPE TABLE OF GX_P0024,
      GS_P0024 TYPE GX_P0024.


DATA: G_IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV ,
      G_WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV ,
      G_TITLE    LIKE SY-TITLE.

TYPES: BEGIN OF GX_HRP1001,
   OTYPE TYPE OTYPE,
  OBJID TYPE HROBJID,
  RSIGN TYPE RSIGN,
  RELAT TYPE RELAT,
  SOBID TYPE SOBID,
  END OF GX_HRP1001.

DATA: GT_HRP1001 TYPE TABLE OF GX_HRP1001,
      GS_HRP1001 TYPE GX_HRP1001.

DATA: GT_ZRLBZ TYPE TABLE OF ZRLBZ,
      GS_ZRLBZ TYPE ZRLBZ.

DATA: LT_BZAGW TYPE TABLE OF ZHRM_BZAGW,
      GS_ITAB_OUT TYPE ZHRM_BZAGW.

*&---------------------------------------------------------------------*
*&  包括                ZHR_BZ_DISPLAY_DEPT_S01
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-S01.
SELECT-OPTIONS: P_CBZX FOR PA0001-KOSTL,
                P_GW   FOR PA0001-PLANS.
PARAMETERS      P_SSNID(50).
SELECTION-SCREEN END OF BLOCK B1.

*&---------------------------------------------------------------------*
*&  包括                ZHR_BZ_DISPLAY_DEPT_E01
*&---------------------------------------------------------------------*
INITIALIZATION.
  PERFORM INIT.

START-OF-SELECTION.

  DATA OBJID1 TYPE HROBJID.
  PERFORM GET_YGZZ.
  PERFORM GET_YGZJ.
  PERFORM GET_P0001.
  PERFORM GET_HRP1001. "得到关系表  主要为得到成本中心
  PERFORM GET_P0024.  "获取p0024 数据
  PERFORM GETMAIN.  "获取维护的编制数据

*  RP-SEL-EIN-AUS-INIT.            "选择屏幕默认就业状态不等于0
***如果查询人员没有相应信息类型的权限,将无权查看此表***
*  PNP_SW_SKIP_PERNR = ‘N‘.

GET OBJEC.
  PERFORM GET_OBJEC.

  OBJID1 = P1000-OBJID.

  IF SY-SUBRC <> 0.

  ENDIF.

END-OF-SELECTION.
  IF  LINES( GT_MAIN ) = 0.
    MESSAGE TEXT-S02 TYPE ‘E‘.
  ENDIF.
  PERFORM MAINTAIN.
  PERFORM SET_OUTPUT.

*&---------------------------------------------------------------------*
*&  包括                ZHR_BZ_DISPLAY_DEPT_F01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Form  GETMAIN
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM GETMAIN .
  FIELD-SYMBOLS: <FS1> TYPE ANY.
  DATA L_COUM(6).
  FIELD-SYMBOLS : <FS> TYPE  ZRLBZ.
  SELECT *
    INTO CORRESPONDING FIELDS OF TABLE GT_ZRLBZ
    FROM ZRLBZ WHERE BYEAR =  SY-DATUM+(4).

  DATA: LM(2) .
  LM = PCHBEGDA+4(2).
  CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_OUTPUT‘
    EXPORTING
      INPUT  = LM
    IMPORTING
      OUTPUT = LM.
  DATA LNAME(7).
  CONCATENATE ‘BZNUB‘ LM INTO  LNAME.
  LOOP AT GT_ZRLBZ ASSIGNING <FS>.
    ASSIGN COMPONENT LNAME OF STRUCTURE <FS> TO <FS1>.
    <FS>-BZNUB2 = <FS1>.
  ENDLOOP.
  CLEAR GS_MAIN.
*  LOOP AT GT_ZRLBZ INTO GS_ZRLBZ.
*
*  ENDLOOP.

ENDFORM.                    " GETMAIN
*&---------------------------------------------------------------------*
*&      Form  INIT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM INIT .
*  CLEAR : PCHOTYPE,PCHWEGID.
  PCHOTYPE = ‘O‘.
  IF PCHBEGDA IS INITIAL.
    PCHBEGDA = SY-DATUM.
  ENDIF.
  IF PCHENDDA IS INITIAL.
    PCHENDDA = PCHBEGDA.
  ENDIF.
  PCHWEGID = ‘O-S-P‘.

ENDFORM.                    " INIT
*&---------------------------------------------------------------------*
*&      Form  GET_OBJEC
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM GET_OBJEC .
  IF OBJEC-BEGDA < SY-DATUM AND OBJEC-ENDDA > SY-DATUM.
    CASE OBJEC-OTYPE.
      WHEN  ‘O‘.
        REJECT.
      WHEN ‘S‘.
        PERFORM APPEND_MAIN.
      WHEN OTHERS.
        REJECT.
    ENDCASE.
  ELSE.
    REJECT.
  ENDIF.
ENDFORM.                    " GET_OBJEC
*&---------------------------------------------------------------------*
*&      Form  APPEND_MAIN
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM APPEND_MAIN .
  DATA LS_MAIN TYPE  GX_MAIN.
  DATA LS_P1001 TYPE P1001.
  DATA: L_NUM_QRZ TYPE I,
        L_NUM_FQRZ TYPE I.
  DATA L_CBZX_IS.
  DATA L_CBZX TYPE MAST_CCTR.


  LS_MAIN-OBJID = OBJEC-OBJID.
********此处循环关系表P1001 取出S标志下 A 03 对应的上级部门O和 A 08 对应的P员工之后判断员工是全日制还是飞全日制岗位
  LOOP AT P1001  INTO LS_P1001  WHERE BEGDA <= PCHBEGDA AND ENDDA >= PCHBEGDA AND RSIGN = ‘A‘.
    CASE LS_P1001-RELAT.
      WHEN ‘003‘.
        LS_MAIN-OBJID1 = LS_P1001-SOBID.
      WHEN ‘008‘.
*********根据员工子组判断是全日制还是非全日制*****************************
        READ TABLE GT_P0001 INTO GS_P0001 WITH KEY PERNR = LS_P1001-SOBID+(8).
        IF SY-SUBRC = 0.
          READ TABLE GT_YGZZ INTO GS_YGZZ WITH KEY PERSK = GS_P0001-PERSK.
          IF SY-SUBRC = 0.
            CASE GS_YGZZ-ZPERSKTYPE.
              WHEN ‘A‘.
                L_NUM_QRZ = L_NUM_QRZ + 1.

              WHEN ‘B‘.
                L_NUM_FQRZ = L_NUM_FQRZ + 1.
            ENDCASE.
            IF GS_YGZZ-ZPERSKTYPE = ‘A‘ OR GS_YGZZ-ZPERSKTYPE = ‘B‘.
**********根据员工职级 *对各阶层员工数据进行分配**************************************
              READ TABLE GT_P0024 INTO GS_P0024 WITH KEY PERNR = LS_P1001-SOBID+(8).
              IF SY-SUBRC = 0 .
                READ TABLE GT_YGZJ INTO GS_YGZJ WITH KEY ZHR_ZWMC = GS_P0024-ZWMC.
                IF SY-SUBRC = 0.
                  CASE GS_YGZJ-ZSTELLTYPE.
                    WHEN ‘A‘.
                      LS_MAIN-JB_A = LS_MAIN-JB_A + 1.
                    WHEN ‘B‘.
                      LS_MAIN-JB_B = LS_MAIN-JB_B + 1.
                    WHEN ‘C‘.
                      LS_MAIN-JB_C = LS_MAIN-JB_C + 1.
                    WHEN ‘D‘.
                      LS_MAIN-JB_D = LS_MAIN-JB_D + 1.
                    WHEN ‘E‘.
                      LS_MAIN-JB_E = LS_MAIN-JB_E + 1.
                    WHEN ‘F‘.
                      LS_MAIN-JB_F = LS_MAIN-JB_F + 1.
                    WHEN ‘G‘.
                      LS_MAIN-JB_G = LS_MAIN-JB_G + 1.
                    WHEN ‘H‘.
                      LS_MAIN-JB_H = LS_MAIN-JB_H + 1.
                    WHEN OTHERS.
                      LS_MAIN-JB_O = LS_MAIN-JB_O + 1.
                  ENDCASE.
                ELSE.
                  LS_MAIN-JB_O = LS_MAIN-JB_O + 1.
                ENDIF.
              ELSE.
                LS_MAIN-JB_O = LS_MAIN-JB_O + 1.
              ENDIF.
            ENDIF.
          ENDIF.
        ENDIF.
        CLEAR : GS_P0001,GS_YGZZ.
      WHEN ‘011‘.
        LS_MAIN-CBZX = LS_P1001-SOBID+(10).
        L_CBZX_IS = ‘X‘.
      WHEN OTHERS.
    ENDCASE.
  ENDLOOP.
  IF L_CBZX_IS <> ‘X‘. "获取成本中心
    PERFORM GET_CBZX USING LS_MAIN-OBJID1 CHANGING  L_CBZX_IS L_CBZX .
    LS_MAIN-CBZX = L_CBZX .
  ENDIF.
  LS_MAIN-QRZRS = L_NUM_QRZ. "全日制人数
  LS_MAIN-FQRZRS = L_NUM_FQRZ.  "非全日制人数

  APPEND LS_MAIN TO GT_MAIN.
  IF SY-SUBRC = 0 .

  ENDIF.


ENDFORM.                    " APPEND_MAIN
*&---------------------------------------------------------------------*
*&      Form  GET_YGZZ
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM GET_YGZZ .
  SELECT * INTO  CORRESPONDING FIELDS OF TABLE GT_YGZZ
    FROM ZHR_PERSKTYPE WHERE ZPERSKTYPE = ‘A‘ OR ZPERSKTYPE = ‘B‘.
ENDFORM.                    " GET_YGZZ
*&---------------------------------------------------------------------*
*&      Form  GET_P0001
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM GET_P0001 .
  SELECT PERNR PERSK INTO CORRESPONDING FIELDS OF TABLE GT_P0001
    FROM PA0001 WHERE BEGDA <= PCHBEGDA AND ENDDA >= PCHBEGDA.
ENDFORM.                                                    " GET_P0001
*&---------------------------------------------------------------------*
*&      Form  DISPLAY
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM DISPLAY .
  PERFORM SUB_SET_FIELD.
  PERFORM DIS_ITAB.

ENDFORM.                    " DISPLAY
*&---------------------------------------------------------------------*
*&      Form  SUB_SET_FIELD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM SUB_SET_FIELD .
  DEFINE MARCO_ADDFIELD .
    G_WA_FIELDCAT-FIELDNAME  = &1.
    G_WA_FIELDCAT-SELTEXT_M  = &2.
    APPEND G_WA_FIELDCAT TO G_IT_FIELDCAT.
  END-OF-DEFINITION .

  MARCO_ADDFIELD: ‘CBZX‘ ‘成本中心‘,
                  ‘CBZXMC‘ ‘成本中心名称‘,
                  ‘OBJID1‘ ‘部门‘,
                  ‘STEXT1‘ ‘部门名称‘,
                  ‘OBJID‘ ‘岗位‘,
                  ‘STEXT‘ ‘岗位名称‘,
                  ‘BZRS‘ ‘编制人数‘,
                  ‘ZGRS‘ ‘总共人数‘,
                  ‘QRZRS‘ ‘全日制人数‘,
                  ‘FQRZRS‘ ‘非全日制人数‘,
                  ‘CBRS‘ ‘超编人数‘,
                  ‘CBL‘ ‘超编率‘,
                  ‘JB_A‘ ‘副总监以上‘,
                  ‘JB_B‘ ‘店长‘,
                  ‘JB_C‘ ‘高级经理‘,
                  ‘JB_D‘ ‘经理‘,
                  ‘JB_E‘ ‘副经理‘,
                  ‘JB_F‘ ‘主管/课长‘,
                  ‘JB_G‘ ‘资深‘,
                  ‘JB_H‘ ‘员工‘,
                  ‘JB_O‘ ‘其他级别‘
                  .
ENDFORM.                    " SUB_SET_FIELD
*&---------------------------------------------------------------------*
*&      Form  DIS_ITAB
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM DIS_ITAB .
  CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY‘
   EXPORTING
*   I_INTERFACE_CHECK                 = ‘ ‘
*   I_BYPASSING_BUFFER                = ‘ ‘
*   I_BUFFER_ACTIVE                   = ‘ ‘
*   I_CALLBACK_PROGRAM                = ‘ ‘
*   I_CALLBACK_PF_STATUS_SET          = ‘ ‘
*   I_CALLBACK_USER_COMMAND           = ‘ ‘
*   I_CALLBACK_TOP_OF_PAGE            = ‘ ‘
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ‘ ‘
*   I_CALLBACK_HTML_END_OF_LIST       = ‘ ‘
*   I_STRUCTURE_NAME                  = I_STRUCTURE_NAME
*   I_BACKGROUND_ID                   = ‘ ‘
*   I_GRID_TITLE                      = I_GRID_TITLE
*   I_GRID_SETTINGS                   = I_GRID_SETTINGS
*   IS_LAYOUT                         = IS_LAYOUT
     IT_FIELDCAT                       =  G_IT_FIELDCAT[]
*   IT_EXCLUDING                      = IT_EXCLUDING
*   IT_SPECIAL_GROUPS                 = IT_SPECIAL_GROUPS
*   IT_SORT                           = IT_SORT
*   IT_FILTER                         = IT_FILTER
*   IS_SEL_HIDE                       = IS_SEL_HIDE
*   I_DEFAULT                         = ‘X‘
*   I_SAVE                            = ‘ ‘
*   IS_VARIANT                        = IS_VARIANT
*   IT_EVENTS                         = IT_EVENTS
*   IT_EVENT_EXIT                     = IT_EVENT_EXIT
*   IS_PRINT                          = IS_PRINT
*   IS_REPREP_ID                      = IS_REPREP_ID
*   I_SCREEN_START_COLUMN             = 0
*   I_SCREEN_START_LINE               = 0
*   I_SCREEN_END_COLUMN               = 0
*   I_SCREEN_END_LINE                 = 0
*   I_HTML_HEIGHT_TOP                 = 0
*   I_HTML_HEIGHT_END                 = 0
*   IT_ALV_GRAPHICS                   = IT_ALV_GRAPHICS
*   IT_HYPERLINK                      = IT_HYPERLINK
*   IT_ADD_FIELDCAT                   = IT_ADD_FIELDCAT
*   IT_EXCEPT_QINFO                   = IT_EXCEPT_QINFO
*   IR_SALV_FULLSCREEN_ADAPTER        = IR_SALV_FULLSCREEN_ADAPTER
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           = E_EXIT_CAUSED_BY_CALLER
*   ES_EXIT_CAUSED_BY_USER            = ES_EXIT_CAUSED_BY_USER
    TABLES
      T_OUTTAB                          = LT_BZAGW[]
   EXCEPTIONS
     PROGRAM_ERROR                     = 1
            .

ENDFORM.                    " DIS_ITAB
*&---------------------------------------------------------------------*
*&      Form  GET_HRP1001
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM GET_HRP1001 .
  SELECT  OTYPE OBJID   RSIGN  RELAT   SOBID
    INTO CORRESPONDING FIELDS OF TABLE  GT_HRP1001
    FROM HRP1001
    WHERE RSIGN  = ‘A‘ AND ( RELAT = ‘003‘ OR RELAT = ‘011‘ OR RELAT = ‘002‘ ).
ENDFORM.                    " GET_HRP1001
*&---------------------------------------------------------------------*
*&      Form  GET_CBZX
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_L_CBZX  text
*      -->P_LS_MAIN_OBJID1  text
*----------------------------------------------------------------------*
FORM GET_CBZX  USING      P_LS_MAIN_OBJID1  TYPE HROBJID
               CHANGING   P_L_CBZX_IS TYPE C
                          P_L_CBZX TYPE MAST_CCTR.
  DATA: LS_HRP1001_1 TYPE GX_HRP1001,
        LS_HRP1001_2 TYPE GX_HRP1001,
        LS_HRP1001_3 TYPE GX_HRP1001,
        LS_HRP1001_4 TYPE GX_HRP1001.
  SORT GT_HRP1001 BY OTYPE OBJID RELAT.
  READ TABLE  GT_HRP1001 INTO LS_HRP1001_1 WITH KEY OBJID = P_LS_MAIN_OBJID1 RELAT = ‘011‘ BINARY SEARCH.
  IF SY-SUBRC = 0. " 第一层组织
    P_L_CBZX    = LS_HRP1001_1-SOBID+0(10).
    P_L_CBZX_IS = ‘X‘.
  ELSE.
    READ TABLE  GT_HRP1001 INTO LS_HRP1001_1 WITH KEY  OTYPE = ‘O‘ OBJID = P_LS_MAIN_OBJID1 RELAT = ‘002‘   BINARY SEARCH .
    IF SY-SUBRC = 0.  "第二层组织
      READ TABLE  GT_HRP1001 INTO LS_HRP1001_2 WITH KEY  OTYPE = ‘O‘ OBJID = LS_HRP1001_1-SOBID(8) RELAT = ‘011‘  BINARY SEARCH.
      IF SY-SUBRC = 0.
        P_L_CBZX    = LS_HRP1001_2-SOBID+0(10).
        P_L_CBZX_IS = ‘X‘.
      ELSE.
        READ TABLE  GT_HRP1001 INTO LS_HRP1001_2 WITH KEY  OTYPE = ‘O‘ OBJID = LS_HRP1001_1-SOBID(8) RELAT = ‘002‘    BINARY SEARCH.
        IF SY-SUBRC = 0. "第三层组织
          READ TABLE  GT_HRP1001 INTO LS_HRP1001_3 WITH KEY  OTYPE = ‘O‘ OBJID = LS_HRP1001_2-SOBID(8) RELAT = ‘011‘    BINARY SEARCH.
          IF SY-SUBRC = 0.
            P_L_CBZX    = LS_HRP1001_3-SOBID+0(10).
            P_L_CBZX_IS = ‘X‘.
          ELSE.
            READ TABLE  GT_HRP1001 INTO LS_HRP1001_3 WITH KEY  OTYPE = ‘O‘ OBJID = LS_HRP1001_2-SOBID(8) RELAT = ‘002‘    BINARY SEARCH.
            IF SY-SUBRC = 0.
              READ TABLE  GT_HRP1001 INTO LS_HRP1001_4 WITH KEY  OTYPE = ‘O‘ OBJID = LS_HRP1001_3-SOBID(8) RELAT = ‘011‘    BINARY SEARCH.
              IF SY-SUBRC = 0.
                P_L_CBZX    = LS_HRP1001_4-SOBID+0(10).
                P_L_CBZX_IS = ‘X‘.
              ENDIF.
            ENDIF.
          ENDIF.
          P_L_CBZX_IS = ‘X‘.
        ELSE.
          P_L_CBZX_IS = ‘X‘.
          EXIT.
        ENDIF.
      ENDIF.
    ELSE.
      P_L_CBZX_IS = ‘X‘.
      EXIT.
    ENDIF.
  ENDIF.

ENDFORM.                    " GET_CBZX
*&---------------------------------------------------------------------*
*&      Form  MAINTAIN
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM MAINTAIN .
  "组织名称
  TYPES: BEGIN OF LX_ORGTX,
  ORGEH TYPE ORGEH,
  ORGTX TYPE ORGTX,
  END OF LX_ORGTX.
  DATA: LT_ORGTX TYPE TABLE OF LX_ORGTX,
        LS_ORGTX TYPE LX_ORGTX.
  "成本中心
  TYPES: BEGIN OF LX_CBZX,
    KOSTL TYPE KOSTL,
    KTEXT TYPE KTEXT,
    END OF LX_CBZX.
  DATA: LT_CBZX TYPE TABLE OF LX_CBZX,
        LS_CBZX TYPE LX_CBZX.
  "组织名称
  TYPES: BEGIN OF LX_PLSTX,
  PLANS TYPE PLANS,
  PLSTX TYPE PLSTX,
  END OF LX_PLSTX.
  FIELD-SYMBOLS <FS> TYPE GX_MAIN.
  DATA: LT_PLSTX TYPE TABLE OF LX_PLSTX,
        LS_PLSTX TYPE LX_PLSTX.
  "组织名称
  SELECT   ORGEH ORGTX
     INTO CORRESPONDING FIELDS OF TABLE LT_ORGTX
     FROM T527X   WHERE ENDDA >= PCHENDDA AND BEGDA <= PCHBEGDA.

  SELECT  KOSTL  KTEXT INTO CORRESPONDING FIELDS OF TABLE LT_CBZX
    FROM  CSKT WHERE SPRAS = ‘1‘.

  "职位名称
  SELECT  PLANS PLSTX
    INTO CORRESPONDING FIELDS OF TABLE LT_PLSTX
    FROM T528T WHERE ENDDA >= PCHENDDA AND BEGDA <= PCHBEGDA.

  SORT LT_ORGTX BY ORGEH. "bumen
  SORT LT_CBZX  BY KOSTL.  "chengbenzhongxin
  SORT LT_PLSTX BY PLANS.  "zhiwei
  SORT GT_ZRLBZ BY OBJID.
  LOOP AT GT_MAIN ASSIGNING <FS>.
    READ TABLE LT_ORGTX INTO LS_ORGTX  WITH KEY ORGEH = <FS>-OBJID1 BINARY SEARCH.
    IF SY-SUBRC = 0.
      <FS>-STEXT1 = LS_ORGTX-ORGTX .
    ENDIF.
    READ TABLE LT_CBZX INTO LS_CBZX WITH KEY KOSTL = <FS>-CBZX BINARY SEARCH.
    IF SY-SUBRC = 0.
      <FS>-CBZXMC = LS_CBZX-KTEXT.
    ENDIF.
    READ TABLE LT_PLSTX INTO LS_PLSTX WITH KEY PLANS = <FS>-OBJID BINARY SEARCH.
    IF SY-SUBRC = 0 .
      <FS>-STEXT = LS_PLSTX-PLSTX.
    ENDIF.
    READ TABLE GT_ZRLBZ INTO GS_ZRLBZ WITH KEY OBJID = <FS>-OBJID.
    IF SY-SUBRC = 0.
      <FS>-BZRS = GS_ZRLBZ-BZNUB1.
    ENDIF.

    <FS>-ZGRS = <FS>-QRZRS + <FS>-FQRZRS / ‘1.5‘ .
    <FS>-CBRS = <FS>-ZGRS - <FS>-BZRS.
    IF <FS>-BZRS <> 0.
      <FS>-CBL  = <FS>-CBRS / <FS>-BZRS.
    ENDIF.
  ENDLOOP.
  sort  GT_MAIN by OBJID1  OBJID.
  DELETE ADJACENT DUPLICATES FROM GT_MAIN COMPARING OBJID1  OBJID.

ENDFORM.                    " MAINTAIN
*&---------------------------------------------------------------------*
*&      Form  GET_P0024
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM GET_P0024 .
  SELECT PERNR ZHR_ZWMC AS ZWMC INTO CORRESPONDING FIELDS OF TABLE GT_P0024
    FROM PA0024 WHERE  BEGDA <= PCHBEGDA AND ENDDA >= PCHBEGDA.

ENDFORM.                                                    " GET_P0024
*&---------------------------------------------------------------------*
*&      Form  GET_YGZJ
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM GET_YGZJ .
  SELECT ZHR_ZWMC ZSTELLTYPE
     INTO CORRESPONDING FIELDS OF TABLE GT_YGZJ
     FROM ZHR_M_PLOMC .
ENDFORM.                    " GET_YGZJ
*&---------------------------------------------------------------------*
*&      Form  SET_OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM SET_OUTPUT .
  LOOP AT GT_MAIN INTO GS_MAIN WHERE OBJID IN P_GW AND CBZX IN P_CBZX .
    MOVE-CORRESPONDING GS_MAIN TO GS_ITAB_OUT .
    APPEND GS_ITAB_OUT TO LT_BZAGW.
  ENDLOOP.
  IF P_SSNID IS NOT INITIAL .
    EXPORT LT_BZAGW TO MEMORY ID P_SSNID.
  ELSE.
    PERFORM DISPLAY.
  ENDIF.
ENDFORM.                    " SET_OUTPUT


HR之PCH逻辑数据库的使用

上一篇:(转)asp.net基础-HttpModule


下一篇:Spring的整体架构