SAP 采购订单EKPO-AEDAT的用处

2023-10-13 14:16:36 浏览数 (1)

采购订单项目表中的更改日期妙用——EKPO-AEDAT.

1.记录删除的日期

一开始用户要此信息,我都使用跟踪查找到CDPOS更改凭证项目表,使用此表勉强可以得到正确的信息,但是如果CLIENT COPY做得不好,此类信息会丢失,所以在开发的CLIENT却很难测试正确。方法如下:

代码语言:javascript复制
 LOOP AT ITAB_100 WHERE LOEKZ = 'L'.
    CONCATENATE  ‘%' ITAB_100-EBELN ITAB_100-EBELP INTO ITAB_100-EBENP.
    SELECT SINGLE CHANGENR INTO ITAB_100-CHANGENR FROM CDPOS
    WHERE TABNAME = 'EKPO' AND FNAME = 'LOEKZ' AND VALUE_NEW = 'L' AND TABKEY LIKE ITAB_100-EBENP.
    IF SY-SUBRC = 0.
      SELECT SINGLE VALUE_NEW INTO ITAB_100-MAEDAT FROM CDPOS
      WHERE TABNAME = 'EKPO' AND FNAME = 'AEDAT' AND CHANGENR = ITAB_100-CHANGENR .
    ENDIF.
    MODIFY ITAB_100.
    CLEAR ITAB_100.
  ENDLOOP.

***注意MAEDAT必须LIKE CDPOS-VALUE_NEW

但是事后才发觉,这些代码都是多此一举,仅仅EKPO-AEDAT这个字段就记录了删除日期,只要抓取它就可以了。方法如下:

代码语言:javascript复制
    IF ITAB_100-LOEKZ = 'L'.
      ITAB_100-STATE = '删除'.
      ITAB_100-MAEDAT = ITAB_100-AEDATP.
    ELSE.
      IF ITAB_100-AEDATP IS INITIAL.
        ITAB_100-STATE = '错误'.
      ELSE.
        ITAB_100-STATE = '正常'.
      ENDIF.
    ENDIF.

2.记录采购订单暂存状态

当采购订单的项目前有个红色的圆点状,表示此订单为暂存状态,也可以用这个EKPO-AEDAT来识别。

当EKPO-AEDAT为空的情况,表示此采购订单的此项为暂存状态,有部分信息需要填充,否则不能正常使用。

方法如下:

代码语言:javascript复制
IF ITAB_100-AEDATP IS INITIAL.
        ITAB_100-STATE = '错误'.
      ELSE.
        ITAB_100-STATE = '正常'.
      ENDIF.

整个报表范例:

代码语言:javascript复制
REPORT  ×××××× no standard page heading MESSAGE-ID zjxydmessage.
*--------------------------------------------------------------*
*Defind include for ALV output.
*--------------------------------------------------------------*
TYPE-POOLS: SLIS.
INCLUDE .
INCLUDE .
*--------------------------------------------------------------*
*Data definition
*--------------------------------------------------------------*
CONSTANTS:
GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
      GS_LAYOUT   TYPE SLIS_LAYOUT_ALV,
      GT_SP_GROUP TYPE SLIS_T_SP_GROUP_ALV,
      GT_EVENTS   TYPE SLIS_T_EVENT.
DATA: G_SAVE(1) TYPE C,
      G_DEFAULT(1) TYPE C,
      G_EXIT(1) TYPE C,
      GX_VARIANT LIKE DISVARIANT,
      G_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND',
      G_VARIANT LIKE DISVARIANT,
      G_REPID LIKE SY-REPID,
      V_ANSWER,
      v_program(40),
      v_printdate(60),
      v_tcode(20),
      V_ERRORFLAG TYPE N.
DATA: GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
*----------------------------------------------------------------------*
*定义TABLE
*---------------------------------------------------------------------*
tables: EKKO,                                            "采购凭证抬头
        EKPO,                                            "采购凭证项目
        MEPO_TOPLINE,
        T007S.                                           "税收代码
data: begin of itab_100 occurs 1,
      WERKS          LIKE          EKPO-WERKS,          "工厂
      LIFNR          LIKE          EKKO-LIFNR,          "供应商帐号
      NAME1          LIKE          LFA1-NAME1,          "供应商帐号
      EBELN          LIKE          EKKO-EBELN,          "采购凭证号
      EBELP          LIKE          EKPO-EBELP,          "项目编号
      EBENP(14)      TYPE          C,                   "订单号+项目号
      EBELN1         LIKE          EKKO-EBELN,          "采购凭证号
      BSART          LIKE          EKKO-BSART,          "采购凭证类型
      BATXT          LIKE          T161T-BATXT,         "采购凭证类型
      KNUMV          LIKE          EKKO-KNUMV,          "采购凭证类型
      KWERT          LIKE          KONV-KWERT,          "采购凭证类型
      AEDAT          LIKE          EKKO-AEDAT,          "记录创建日期
      AEDAT1         LIKE          EKKO-AEDAT,          "记录创建日期
      GDATU          LIKE          TCURR-GDATU,         "记录创建日期
      TXZ01          LIKE          EKPO-TXZ01,          "短文本
      NETWR          LIKE          EKPO-NETWR,          "采购金额(不含税)
      WAERS          LIKE          EKKO-WAERS,          "货币代码
      UKURS          LIKE          TCURR-UKURS,         "汇率
      MWSKZ          LIKE          EKPO-MWSKZ,          "税代码
      TEXT1          LIKE          T007S-TEXT1,         "比例
      EFFWR          LIKE          EKPO-EFFWR,          "项目的有效值
      LOEKZ          LIKE          EKPO-LOEKZ,          "采购凭证删除标识
      NETWR1         LIKE          EKPO-NETWR,          "采购金额(含税)
      NETWR2         LIKE          EKPO-NETWR,          "运费金额(不含税)
      NETWR3         LIKE          EKPO-NETWR,          "运费金额(含税)
      NETWR4         LIKE          EKPO-NETWR,          "金额合计(含税)
      CHANGENR       LIKE          CDPOS-CHANGENR,      "文档更改编号
      SHOU(2)        TYPE          C,                   "是否收货
      STATE(4)       TYPE          C,                   "订单状态
      MAEDAT         LIKE          EKKO-AEDAT,          "删除日期
      BI(2)          TYPE          C,                   "税比例
      OTHER(20)      TYPE          C,                   "订单状态
      end of itab_100.
*-----检查权限控制
data: begin of itab_tvko occurs 0,
       vkorg like tvko-vkorg,       "销售组织
      end of itab_tvko.
data: v_auth.                        "检查权限
data:  VTEXT(30)       TYPE          C,                "部门名称
       v_bukrs         LIKE          TVKO-bukrs,       "部门名称
       t_bukrs         like          t001-butxt,       "公司名称
       VKUNNR          LIKE          VBAK-KUNNR,       "售达方
       OUT_NO(20)      TYPE         C,                "HEAD文本用来填定出厂编号
       V_NETWR          LIKE          EKPO-NETWR,          "采购金额(含税)
       VNAME(60)       TYPE          C.                "客户名称
DATA:xname like thead-tdname,        "文本名称
    xvbadr like vbadr,              "vbadr短文本地址工作区结构
    xtline like tline occurs 10 with header line,
    xflag(1),
    xtemp like sy-tabix.
*--------------------------------------------------------------*
selection-screen begin of block b1 with frame title text-001.
parameters: P_BUKRS like EKKO-BUKRS obligatory .              "公司代码
select-options: S_WERKS for EKPO-WERKS obligatory .           "工厂
select-options: S_BSART for MEPO_TOPLINE-BSART .                      "订单类型
select-options: S_EBELN for EKKO-EBELN .                      "订单类型
select-options: S_AEDAT for  EKKO-AEDAT  obligatory .          "订单创建日期
selection-screen end of block b1.
*--------------------------------------------------------------*
*Initiallize for ALV output
*--------------------------------------------------------------*
INITIALIZATION.
  G_REPID = SY-REPID.
  G_SAVE = 'A'.
  CLEAR G_VARIANT.
  G_VARIANT-REPORT = G_REPID.
at selection-screen on S_WERKS.
  select single bukrs into v_bukrs from TVKO
              where VKORG IN S_WERKS.
  if v_bukrs ne P_bukrs.
    message e021  with '请选择正确的工厂'.
  endif.
*--------------------------------------------------------------*
start-of-selection.
  perform author_check.
  if v_auth ne 'X'.
    perform get_data.
    perform sort_data.
    perform prepare_alv.
    perform list_data.
  endif.
*&-------------------------------------------------------------*
*&      Form  get_data
*&-------------------------------------------------------------*
*       text
*--------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*--------------------------------------------------------------*
FORM get_data.
  SELECT EKPO~WERKS EKKO~LIFNR EKKO~EBELN EKKO~BSART EKKO~KNUMV EKKO~AEDAT EKKO~WAERS
         EKPO~TXZ01 EKPO~NETWR EKPO~MWSKZ EKPO~EFFWR EKPO~LOEKZ EKPO~EBELP
     into corresponding fields of itab_100
     FROM EKKO INNER JOIN EKPO ON EKKO~EBELN = EKPO~EBELN
     WHERE EKKO~EBELN IN S_EBELN AND
           EKKO~BUKRS = P_BUKRS AND
           EKPO~WERKS IN S_WERKS AND
           EKKO~BSART IN S_BSART AND
           EKKO~AEDAT IN S_AEDAT .
**取供应商名称
    SELECT SINGLE NAME1  INTO ITAB_100-NAME1 FROM LFA1 WHERE LIFNR = ITAB_100-LIFNR.
**取税描述
    SELECT SINGLE TEXT1  INTO ITAB_100-TEXT1 FROM T007S
    WHERE SPRAS = '1' AND KALSM = 'TAXCN' AND MWSKZ = ITAB_100-MWSKZ.
**取税比例
    SPLIT ITAB_100-TEXT1 AT '%' INTO ITAB_100-BI ITAB_100-OTHER.
**取采购金额(含税)
    ITAB_100-NETWR1 = ITAB_100-NETWR   ITAB_100-NETWR * ITAB_100-BI.
**取订单类型描述
    SELECT SINGLE BATXT  INTO ITAB_100-BATXT FROM T161T WHERE BSART = ITAB_100-BSART.
**取汇率(月初的汇率)
    CONCATENATE  ITAB_100-AEDAT(6) '01' INTO ITAB_100-AEDAT1.
    CONVERT DATE ITAB_100-AEDAT1 INTO INVERTED-DATE ITAB_100-GDATU.
    ITAB_100-UKURS = 1.
    SELECT  SINGLE UKURS INTO ITAB_100-UKURS  FROM TCURR
       WHERE KURST = 'M' AND FCURR = ITAB_100-WAERS AND  TCURR = 'CNY' AND GDATU =  ITAB_100-GDATU.
**取金额合计(含税)
    ITAB_100-NETWR4 = ( ITAB_100-NETWR1   ITAB_100-NETWR3 ) * ITAB_100-UKURS.
**判断是否有收货
    SELECT SINGLE EBELN INTO ITAB_100-EBELN1 FROM EKBE WHERE EBELN = ITAB_100-EBELN AND BEWTP = 'E'.
    IF SY-SUBRC = 0.
      ITAB_100-SHOU = '是'.
    ELSE.
      ITAB_100-SHOU = '否'.
    ENDIF.
**判断是删除
    IF ITAB_100-LOEKZ = 'L'.
      ITAB_100-STATE = '删除'.
    ELSE.
      ITAB_100-STATE = '正常'.
    ENDIF.
    APPEND ITAB_100.
    CLEAR ITAB_100.
  ENDSELECT.
**取运费
  LOOP AT ITAB_100 .
    IF ITAB_100-EFFWR NE ITAB_100-NETWR.
      SELECT  KWERT  INTO V_NETWR  FROM KONV
         WHERE KNUMV = ITAB_100-KNUMV AND ( KSCHL = 'FRC1' OR KSCHL = 'FRC2').
        ITAB_100-NETWR2 = ITAB_100-NETWR2   V_NETWR .
        V_NETWR = 0.
      ENDSELECT.
**取运费金额(含税)
      ITAB_100-NETWR3 = ITAB_100-NETWR2 * 100 / 93 .
**取金额合计(含税)
      ITAB_100-NETWR4 = ( ITAB_100-NETWR1   ITAB_100-NETWR3 ) * ITAB_100-UKURS.
      MODIFY ITAB_100.
      CLEAR ITAB_100.
    ENDIF.
  ENDLOOP.
**取删除日期
  LOOP AT ITAB_100 WHERE LOEKZ = 'L'.
    CONCATENATE  ITAB_100-EBELN ITAB_100-EBELP INTO ITAB_100-EBENP.
    SELECT SINGLE CHANGENR INTO ITAB_100-CHANGENR FROM CDPOS
    WHERE TABNAME = 'EKPO' AND FNAME = 'LOEKZ' AND VALUE_NEW = 'L' AND TABKEY = ITAB_100-EBENP.
    IF SY-SUBRC = 0.
      SELECT SINGLE VALUE_NEW INTO ITAB_100-MAEDAT FROM CDPOS
      WHERE TABNAME = 'EKPO' AND FNAME = 'AEDAT' AND CHANGENR = ITAB_100-CHANGENR .
    ENDIF.
    MODIFY ITAB_100.
    CLEAR ITAB_100.
  ENDLOOP.
ENDFORM.                    " get_data
*&---------------------------------------------------------------------*
*&      Form  sort_data
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM sort_data .
  sort itab_100 by AEDAT EBELN.
ENDFORM.                    " sort_data
*&-------------------------------------------------------------*
*&      Form  list_data
*&-------------------------------------------------------------*
*       text
*--------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*--------------------------------------------------------------*
FORM list_data.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'             "output via ALV
         EXPORTING
              I_CALLBACK_PROGRAM      = G_REPID
              IT_FIELDCAT             = GT_FIELDCAT[]
              IT_EVENTS               = GT_EVENTS[]
              I_SAVE = 'A'
         TABLES
              T_OUTTAB                = ITAB_100.
ENDFORM.                    " list_data
*---------------------------------------------------------------------*
*       FORM TOP_OF_PAGE                                              *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM TOP_OF_PAGE.
*---prepare ALV header output
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      i_logo             = 'ENJOYSAP_LOGO'
      IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
ENDFORM.                    "list_data
*&---------------------------------------------------------------------*
*&      Form  prepare_alv
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM prepare_alv .
  PERFORM E01_FIELDCAT_INIT  USING GT_FIELDCAT[].
  PERFORM E03_EVENTTAB_BUILD USING GT_EVENTS[].
  PERFORM E04_COMMENT_BUILD  USING GT_LIST_TOP_OF_PAGE[].
ENDFORM.                    " prepare_alv
*&---------------------------------------------------------------------*
*&      Form  E01_FIELDCAT_INIT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_GT_FIELDCAT[]  text
*----------------------------------------------------------------------*
FORM E01_FIELDCAT_INIT USING E01_LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
  DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
*---Populate ALV field structure
  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-TABNAME       = 'ITAB_100'.
  LS_FIELDCAT-FIELDNAME     = 'WERKS'.
  LS_FIELDCAT-COL_POS       = '1'.
  LS_FIELDCAT-SELTEXT_L     = '工厂'.
  LS_FIELDCAT-DDICTXT       = 'L'.
  LS_FIELDCAT-outputlen     = '4'.
  LS_FIELDCAT-just          = 'C'.
  APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-TABNAME       = 'ITAB_100'.
  LS_FIELDCAT-FIELDNAME     = 'EBELN'.
  LS_FIELDCAT-COL_POS       = '2'.
  LS_FIELDCAT-SELTEXT_L     = '订单号码'.
  LS_FIELDCAT-DDICTXT       = 'L'.
  LS_FIELDCAT-outputlen     = '10'.
  LS_FIELDCAT-just          = 'L'.
  APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-TABNAME       = 'ITAB_100'.
  LS_FIELDCAT-FIELDNAME     = 'LIFNR'.
  LS_FIELDCAT-COL_POS       = '3'.
  LS_FIELDCAT-SELTEXT_L     = '供应商代码'.
  LS_FIELDCAT-DDICTXT       = 'L'.
  LS_FIELDCAT-outputlen     = '10'.
  LS_FIELDCAT-just          = 'L'.
  APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-TABNAME       = 'ITAB_100'.
  LS_FIELDCAT-FIELDNAME     = 'NAME1'.
  LS_FIELDCAT-COL_POS       = '4'.
  LS_FIELDCAT-SELTEXT_L     = '供应商名称'.
  LS_FIELDCAT-DDICTXT       = 'L'.
  LS_FIELDCAT-outputlen     = '35'.
  LS_FIELDCAT-just          = 'L'.
  APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-TABNAME       = 'ITAB_100'.
  LS_FIELDCAT-FIELDNAME     = 'AEDAT'.
  LS_FIELDCAT-COL_POS       = '5'.
  LS_FIELDCAT-SELTEXT_L     = '订单创建日期'.
  LS_FIELDCAT-DDICTXT       = 'L'.
  LS_FIELDCAT-outputlen     = '10'.
  LS_FIELDCAT-just          = 'L'.
  APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-TABNAME       = 'ITAB_100'.
  LS_FIELDCAT-FIELDNAME     = 'TXZ01'.
  LS_FIELDCAT-COL_POS       = '6'.
  LS_FIELDCAT-SELTEXT_L     = '物料(工程)名称'.
  LS_FIELDCAT-DDICTXT       = 'L'.
  LS_FIELDCAT-outputlen     = '40'.
  LS_FIELDCAT-just          = 'L'.
  APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-TABNAME       = 'ITAB_100'.
  LS_FIELDCAT-FIELDNAME     = 'NETWR'.
  LS_FIELDCAT-COL_POS       = '7'.
  LS_FIELDCAT-SELTEXT_L     = '采购(工程)金额(不含税)'.
  LS_FIELDCAT-DDICTXT       = 'L'.
  LS_FIELDCAT-outputlen     = '24'.
  LS_FIELDCAT-just          = 'R'.
  APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-TABNAME       = 'ITAB_100'.
  LS_FIELDCAT-FIELDNAME     = 'MWSKZ'.
  LS_FIELDCAT-COL_POS       = '8'.
  LS_FIELDCAT-SELTEXT_L     = '税码'.
  LS_FIELDCAT-DDICTXT       = 'L'.
  LS_FIELDCAT-outputlen     = '4'.
  LS_FIELDCAT-just          = 'L'.
  APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-TABNAME       = 'ITAB_100'.
  LS_FIELDCAT-FIELDNAME     = 'NETWR1'.
  LS_FIELDCAT-COL_POS       = '9'.
  LS_FIELDCAT-SELTEXT_L     = '采购(工程)金额(含税)'.
  LS_FIELDCAT-DDICTXT       = 'L'.
  LS_FIELDCAT-outputlen     = '22'.
  LS_FIELDCAT-just          = 'R'.
  APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-TABNAME       = 'ITAB_100'.
  LS_FIELDCAT-FIELDNAME     = 'NETWR2'.
  LS_FIELDCAT-COL_POS       = '10'.
  LS_FIELDCAT-SELTEXT_L     = '运费金额(不含税)'.
  LS_FIELDCAT-DDICTXT       = 'L'.
  LS_FIELDCAT-outputlen     = '16'.
  LS_FIELDCAT-just          = 'R'.
  APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-TABNAME       = 'ITAB_100'.
  LS_FIELDCAT-FIELDNAME     = 'NETWR3'.
  LS_FIELDCAT-COL_POS       = '11'.
  LS_FIELDCAT-SELTEXT_L     = '运费金额(含税)'.
  LS_FIELDCAT-DDICTXT       = 'L'.
  LS_FIELDCAT-outputlen     = '14'.
  LS_FIELDCAT-just          = 'R'.
  APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-TABNAME       = 'ITAB_100'.
  LS_FIELDCAT-FIELDNAME     = 'WAERS'.
  LS_FIELDCAT-COL_POS       = '12'.
  LS_FIELDCAT-SELTEXT_L     = '币别'.
  LS_FIELDCAT-DDICTXT       = 'L'.
  LS_FIELDCAT-outputlen     = '4'.
  LS_FIELDCAT-just          = 'C'.
  APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-TABNAME       = 'ITAB_100'.
  LS_FIELDCAT-FIELDNAME     = 'UKURS'.
  LS_FIELDCAT-COL_POS       = '12'.
  LS_FIELDCAT-SELTEXT_L     = '汇率'.
  LS_FIELDCAT-DDICTXT       = 'L'.
  LS_FIELDCAT-outputlen     = '10'.
  LS_FIELDCAT-just          = 'R'.
  APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-TABNAME       = 'ITAB_100'.
  LS_FIELDCAT-FIELDNAME     = 'NETWR4'.
  LS_FIELDCAT-COL_POS       = '13'.
  LS_FIELDCAT-SELTEXT_L     = '金额(含税)合计'.
  LS_FIELDCAT-DDICTXT       = 'L'.
  LS_FIELDCAT-outputlen     = '14'.
  LS_FIELDCAT-just          = 'R'.
  APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-TABNAME       = 'ITAB_100'.
  LS_FIELDCAT-FIELDNAME     = 'SHOU'.
  LS_FIELDCAT-COL_POS       = '14'.
  LS_FIELDCAT-SELTEXT_L     = '是否收货'.
  LS_FIELDCAT-DDICTXT       = 'L'.
  LS_FIELDCAT-outputlen     = '8'.
  LS_FIELDCAT-just          = 'L'.
  APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-TABNAME       = 'ITAB_100'.
  LS_FIELDCAT-FIELDNAME     = 'STATE'.
  LS_FIELDCAT-COL_POS       = '15'.
  LS_FIELDCAT-SELTEXT_L     = '订单状态'.
  LS_FIELDCAT-DDICTXT       = 'L'.
  LS_FIELDCAT-outputlen     = '8'.
  LS_FIELDCAT-just          = 'L'.
  APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-TABNAME       = 'ITAB_100'.
  LS_FIELDCAT-FIELDNAME     = 'MAEDAT'.
  LS_FIELDCAT-COL_POS       = '16'.
  LS_FIELDCAT-SELTEXT_L     = '删除日期'.
  LS_FIELDCAT-DDICTXT       = 'L'.
  LS_FIELDCAT-outputlen     = '8'.
  LS_FIELDCAT-just          = 'L'.
  APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
  CLEAR LS_FIELDCAT.
  LS_FIELDCAT-TABNAME       = 'ITAB_100'.
  LS_FIELDCAT-FIELDNAME     = 'BATXT'.
  LS_FIELDCAT-COL_POS       = '17'.
  LS_FIELDCAT-SELTEXT_L     = '订单类型'.
  LS_FIELDCAT-DDICTXT       = 'L'.
  LS_FIELDCAT-outputlen     = '20'.
  LS_FIELDCAT-just          = 'L'.
  APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
ENDFORM.                    " E01_FIELDCAT_INIT
*&---------------------------------------------------------------------*
*&      Form  E03_EVENTTAB_BUILD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_GT_EVENTS[]  text
*----------------------------------------------------------------------*
FORM E03_EVENTTAB_BUILD USING E03_LT_EVENTS TYPE SLIS_T_EVENT.
  DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
      I_LIST_TYPE = 0
    IMPORTING
      ET_EVENTS   = E03_LT_EVENTS.
  READ TABLE E03_LT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
                             INTO LS_EVENT.
  IF SY-SUBRC = 0.
    MOVE GC_FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.
    APPEND LS_EVENT TO E03_LT_EVENTS.
  ENDIF.
ENDFORM.                    " E03_EVENTTAB_BUILD
*&---------------------------------------------------------------------*
*&      Form  E04_COMMENT_BUILD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_GT_LIST_TOP_OF_PAGE[]  text
*----------------------------------------------------------------------*
FORM E04_COMMENT_BUILD USING E04_LT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
  DATA: LS_LINE TYPE SLIS_LISTHEADER.
  CLEAR LS_LINE.
  LS_LINE-TYP  = 'H'.
  select single butxt into t_bukrs from t001 where bukrs eq P_bukrs.
  LS_LINE-INFO = t_bukrs.
  APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
*
  CLEAR LS_LINE.
  LS_LINE-TYP  = 'S'.
  LS_LINE-KEY  = '采购及工程订单明细表'.
  APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
  CLEAR LS_LINE.
   CONCATENATE '工厂:'  S_WERKS-LOW  '-' S_WERKS-HIGH    INTO v_program.
   CONCATENATE '程式编号:××××××' '     ' '印表时间:' SY-DATUM(4) '/' SY-DATUM 4(2)
              '/' SY-DATUM 6(2) '/'  SY-UZEIT(2) ':' SY-UZEIT 2(2) ':' SY-UZEIT 4(2)  INTO V_PRINTDATE.
  LS_LINE-TYP  = 'S'.
  LS_LINE-KEY  = v_program.
  LS_LINE-INFO = V_PRINTDATE.
  APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
ENDFORM.                    " E04_COMMENT_BUILD
*&---------------------------------------------------------------------*
*       检查权限
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM author_check .
  select * into corresponding fields of table itab_tvko
          from tvko
        where vkorg = S_WERKS.
  loop at itab_tvko.
    AUTHORITY-CHECK OBJECT 'M_MSEG_WMB'
       ID 'WERKS' FIELD itab_tvko-vkorg
       ID 'ACTVT' DUMMY.
    IF SY-SUBRC NE 0.
      v_auth = 'X'.
      message s015 with '工厂' itab_tvko-vkorg.
    ENDIF.
  ENDLOOP.
ENDFORM.                    " author_check

0 人点赞