ITPub博客

首页 > Linux操作系统 > Linux操作系统 > ZR_FI_017

ZR_FI_017

原创 Linux操作系统 作者:williamzhou 时间:2019-07-12 17:57:06 0 删除 编辑

*===============================基本信息===============================*
* 标题:GR/IR明细表
* 创建日期:2005-08-05       
*===============================定    义===============================*

************************************************************************
* 基本代码
************************************************************************
REPORT ZR_FI_017
NO STANDARD PAGE HEADING
LINE-COUNT 65
LINE-SIZE  174
MESSAGE-ID ZFI1.

************************************************************************
* INCLUDE:包含文件
************************************************************************
INCLUDE OLE2INCL.

************************************************************************
* TABLE: 定义TABLE
************************************************************************
TABLES: T001,  "公司代码
        MAKT,  "物料描述
        BKPF,  "会计核算凭证标题(主表)
        BSEG,  "会计核算凭证段(从表)
        MSEG,  "凭证段:物料
        RBKP,
        RSEG,
        RKWA,  "委托领取
        EKPO,  "采购从表
        EKBE,  "采购凭证历史
        VBKPF, "预制凭证的凭证抬头
        SKAT.  "总帐科目主记录(科目表:说明)
************************************************************************
*INTERNAL TABLES
************************************************************************
*定义内表ITABS
*报表最后输出时使用的数据
DATA: BEGIN OF IT_PRINT_001 OCCURS 0.
        DATA FLAG.
        DATA BUKRS LIKE BKPF-BUKRS.    "公司代码
        DATA GJAHR LIKE BKPF-GJAHR.    "会计年度

        DATA BLART LIKE BKPF-BLART.    "凭证类型
        DATA CTYPE LIKE MAKT-MAKTX.    "凭证类型名
        DATA KOART LIKE BSEG-KOART.    "帐户类型
        DATA SHKZG LIKE BSEG-SHKZG.    "借方/贷方
        DATA BLDAT LIKE BKPF-BLDAT.    "凭证中的凭证日期
        DATA BUDAT LIKE BKPF-BUDAT.    "凭证中的记帐日期
        DATA AUGDT LIKE BSEG-AUGDT.    "清账日期
        DATA BELNR LIKE BKPF-BELNR.    "会计凭证号码
        DATA DMBTR LIKE BSEG-DMBTR.    "按本位币计的金额
        DATA LIFNR LIKE BSEG-LIFNR.    "供应商编号
        DATA EBELN LIKE BSEG-EBELN.    "采购凭证号
        DATA EBELP LIKE BSEG-EBELP.    "采购凭证的项目编号
        DATA ZEKKN LIKE BSEG-ZEKKN.    "序列号帐户分配
        DATA MBLNR LIKE MSEG-MBLNR.    "物料凭证号
        DATA MBLNR2 LIKE MSEG-MBLNR.   "发票凭证号
        DATA SGTXT LIKE BSEG-SGTXT.    "项目文本
        DATA MATNR LIKE BSEG-MATNR.    "物料号
        DATA MAKTX LIKE MAKT-MAKTX.    "物料描述
        DATA MENGE LIKE BSEG-MENGE.    "出入库数量
        DATA MEINS LIKE BSEG-MEINS.    "计量单位
        "DATA NETPR LIKE EKPO-NETPR.   "采购凭证中的净价格(以凭证货币计)
        DATA NETPR TYPE P DECIMALS 4.  "价格
        DATA PEINH LIKE EKPO-PEINH.    "价格单位

        DATA HKONT LIKE BSEG-HKONT.    "总分类帐帐目
        DATA AWKEY LIKE BKPF-AWKEY.    "对象关键字
        DATA ZUONR LIKE BSEG-ZUONR.    "分配
DATA: END OF IT_PRINT_001.

DATA: ITAB_01 LIKE IT_PRINT_001 OCCURS 10 WITH HEADER LINE.
DATA: ITAB_02 LIKE IT_PRINT_001 OCCURS 10 WITH HEADER LINE.

*往数据库增加运行日志
  DATA: BEGIN OF IT_ZREPORTLOG OCCURS  0.
    INCLUDE TYPE ZREPORTLOG.
  DATA: END OF IT_ZREPORTLOG.
************************************************************************
* CONSTANTS : 定义常量
************************************************************************

************************************************************************
* TYPE : 定义数据类型
************************************************************************
TYPE-POOLS: SLIS.

************************************************************************
* DATA : 定义变量
************************************************************************
DATA: NAME_LAST LIKE USER_ADDR-NAME_LAST,
      NAME_FIRST LIKE USER_ADDR-NAME_FIRST,
      NAME(16).

*用于ALV控件双击事件
DATA: G_SELECTED_FIELD_VALUE(80).

*ALV控件构造时需要的参数
DATA: G_ALV_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
      G_ALV_FIELDCAT_LINE LIKE LINE OF G_ALV_FIELDCAT,
      G_ALV_EVENT         TYPE SLIS_T_EVENT.

*ALV控件输出的表头
DATA: G_ALV_LISTHEADER TYPE SLIS_T_LISTHEADER.

*指定ALV控件触发TOP_OF_PAGE事件时调用的子程序
DATA: G_ALV_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME
             VALUE 'F_ALV_EVENT_TOP_OF_PAGE'.
DATA: G_ALV_FORMNAME_END_OF_LIST TYPE SLIS_FORMNAME
             VALUE 'F_ALV_EVENT_END_OF_LIST'.

*指定ALV控件的显示特征
DATA : G_ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
************************************************************************
* DEFINE: 定义宏
************************************************************************

************************************************************************
*  SELECTION SCREEN : 定义报表筛选条件
************************************************************************
*确定过滤参数
SELECTION-SCREEN BEGIN OF BLOCK BLK_001 WITH FRAME. TITLE BLK_001 .
    PARAMETERS: P_GJAHR LIKE BKPF-GJAHR OBLIGATORY MEMORY ID 117_1.    "会计年度
    PARAMETERS: P_BUKRS LIKE BKPF-BUKRS OBLIGATORY MEMORY ID 117_2.    "公司代码
    PARAMETERS: P_SAKNR LIKE BSEG-SAKNR OBLIGATORY DEFAULT '12010000'
                                                   MEMORY ID 117_3.    "G/L科目
    SELECT-OPTIONS P_BUDAT FOR BKPF-BUDAT MEMORY ID 117_4.             "凭证记帐日期
    SELECT-OPTIONS P_BELNR FOR BKPF-BELNR MEMORY ID 117_5.             "财务凭证编号
    SELECT-OPTIONS P_LIFNR FOR BSEG-LIFNR MEMORY ID 117_6.             "供应商编号
    SELECT-OPTIONS P_EBELN FOR BSEG-EBELN MEMORY ID 117_7.             "采购凭证
    SELECT-OPTIONS P_EBELP FOR BSEG-EBELP MEMORY ID 117_8.             "采购凭证项目
SELECTION-SCREEN END OF BLOCK BLK_001.

*特殊汇总类型参数
SELECTION-SCREEN BEGIN OF BLOCK BLK_003 WITH FRAME. TITLE BLK_003 .
    PARAMETERS: P_TYPE1 AS CHECKBOX DEFAULT 'X'.
    PARAMETERS: P_TYPE2 AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK BLK_003.

*选择报表类型
SELECTION-SCREEN BEGIN OF BLOCK BLK_002 WITH FRAME. TITLE BLK_002 .
PARAMETERS: P_REPORT RADIOBUTTON GROUP R1,
            P_ALV RADIOBUTTON GROUP R1 DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK BLK_002.


*===============================事    件===============================*
************************************************************************
* INITIALIZATION.启动程序开始执行
************************************************************************
INITIALIZATION.
  BLK_001 = '检索参数'.
  BLK_002 = '报表类型'.
  BLK_003 = '特殊参数处理'.
************************************************************************
* AT SELECTION SCREEN:
************************************************************************
AT SELECTION-SCREEN.
  PERFORM. F_CHECK_INPUT.          "检查用户输入
************************************************************************
* START OF SELECTION:
************************************************************************
START-OF-SELECTION.
*往数据库增加运行日志
  IT_ZREPORTLOG-MANDT = SY-MANDT.
  IT_ZREPORTLOG-TCODE = SY-TCODE.
  IT_ZREPORTLOG-DATUM = SY-DATUM.
  IT_ZREPORTLOG-UZEIT = SY-UZEIT.
  IT_ZREPORTLOG-UNAME = SY-UNAME.
  IT_ZREPORTLOG-TITLE = SY-TITLE.
  APPEND IT_ZREPORTLOG.
  INSERT INTO ZREPORTLOG VALUES IT_ZREPORTLOG .

  PERFORM. F_READ_DATA.

  IF P_REPORT = 'X'.
    PERFORM. F_PRINT_REPORT.
  ELSEIF P_ALV = 'X'.
    PERFORM. F_PRINT_ALV.
  ENDIF.
************************************************************************
* END OF SELECTION
************************************************************************
END-OF-SELECTION.

************************************************************************
* TOP OF PAGE
************************************************************************
TOP-OF-PAGE.
  PERFORM. SUB_HEAD.
************************************************************************
* END OF PAGE
************************************************************************
END-OF-PAGE.
  PERFORM. SUB_BOTTOM.


*===============================子 例 程===============================*
*&---------------------------------------------------------------------*
*过滤条件有效性检查
*&---------------------------------------------------------------------*
FORM. F_CHECK_INPUT.
  "判断是否输入GR/IR或GR/IR调整科目
  IF ( P_SAKNR <> '0012010000' ) AND ( P_SAKNR <> '0012100000' )
   AND ( P_SAKNR <> '0012019999' ).
    MESSAGE E055.
  ENDIF.

  "判断是否存在该凭证记录
  SELECT SINGLE *
    FROM BKPF
    WHERE BUKRS = P_BUKRS AND GJAHR = P_GJAHR
      AND BELNR IN P_BELNR   "会计凭证号码
      AND BUDAT IN P_BUDAT.  "凭证中的记帐日期

  IF SY-SUBRC <> 0.
    MESSAGE E054.
  ENDIF.

ENDFORM.                    " F_CHECK_INPUT
*&---------------------------------------------------------------------*
*从数据库中读取数据,填充报表输出时所用的内表
*&---------------------------------------------------------------------*
FORM. F_READ_DATA .
DATA: L_MBLNR2 LIKE MSEG-MBLNR.   "发票凭证号
DATA: ITAB_TEMP LIKE IT_PRINT_001 OCCURS 10 WITH HEADER LINE.

*----主记录处理
  IF P_TYPE2 = 'X'.
    SELECT BUKRS         "公司代码
           GJAHR         "会计年度
           BELNR         "会计凭证号码
           BLART         "凭证类型
           BLDAT         "凭证中的凭证日期
           BUDAT         "凭证中的记帐日期
           AWKEY         "对象关键字
      FROM BKPF
      INTO CORRESPONDING FIELDS OF TABLE ITAB_01
      WHERE BUKRS = P_BUKRS
        AND GJAHR = P_GJAHR
        AND BELNR IN P_BELNR
        AND BUDAT IN P_BUDAT
        AND ( BLART = 'WA' OR BLART = 'WE' OR BLART = 'RE'  ).
   ELSE.
    SELECT BUKRS         "公司代码
           GJAHR         "会计年度
           BELNR         "会计凭证号码
           BLART         "凭证类型
           BLDAT         "凭证中的凭证日期
           BUDAT         "凭证中的记帐日期
           AWKEY         "对象关键字
      FROM BKPF
      INTO CORRESPONDING FIELDS OF TABLE ITAB_01
      WHERE BUKRS = P_BUKRS
        AND GJAHR = P_GJAHR
        AND BELNR IN P_BELNR
        AND BUDAT IN P_BUDAT.
   ENDIF.

*----从记录处理
   LOOP AT ITAB_01.
     REFRESH ITAB_02.
     CLEAR ITAB_02.
     IF P_TYPE1 = 'X'.
       SELECT BUKRS      "公司代码
              GJAHR      "会计年度
              BELNR      "会计凭证号码
              KOART      "帐户类型
              SHKZG      "借方/贷方
              DMBTR      "按本位币计的金额
              SGTXT      "项目文本
              HKONT      "总分类帐帐目
              LIFNR      "供应商或债权人的帐号
              EBELN      "采购单号
              EBELP      "采购凭证的项目编号
              MATNR      "物料号
              MENGE      "数量
              MEINS      "基本单位
              ZEKKN      "序列号帐户分配
              AUGDT      "清帐日期
              ZUONR      "分配
         FROM BSEG
         INTO CORRESPONDING FIELDS OF TABLE ITAB_02
         WHERE BUKRS = ITAB_01-BUKRS
           AND GJAHR = ITAB_01-GJAHR
           AND BELNR = ITAB_01-BELNR
           AND BUZEI <> ''
*           AND LIFNR IN P_LIFNR   "直接取BSEG上的供应商,这种方法不全面,有些记录上不含记录.
           AND EBELN IN P_EBELN
           AND EBELP IN P_EBELP
           AND HKONT = P_SAKNR
           AND AUGDT = '00000000'.     "清帐日期
     ELSE.
       SELECT BUKRS      "公司代码
              GJAHR      "会计年度
              BELNR      "会计凭证号码
              KOART      "帐户类型
              SHKZG      "借方/贷方
              DMBTR      "按本位币计的金额
              SGTXT      "项目文本
              HKONT      "总分类帐帐目
              LIFNR      "供应商或债权人的帐号
              EBELN      "采购单号
              EBELP      "采购凭证的项目编号
              MATNR      "物料号
              MENGE      "数量
              MEINS      "基本单位
              ZEKKN      "序列号帐户分配
              AUGDT      "清帐日期
              ZUONR      "分配
         FROM BSEG
         INTO CORRESPONDING FIELDS OF TABLE ITAB_02
         WHERE BUKRS = ITAB_01-BUKRS
           AND GJAHR = ITAB_01-GJAHR
           AND BELNR = ITAB_01-BELNR
           AND BUZEI <> ''
*           AND LIFNR IN P_LIFNR
           AND EBELN IN P_EBELN
           AND EBELP IN P_EBELP
           AND HKONT = P_SAKNR.
     ENDIF.

     "将ITAB_01表的相关记录赋值到ITAB_02内表
     LOOP AT ITAB_02.
       ITAB_02-BLART = ITAB_01-BLART.
       ITAB_02-BLDAT = ITAB_01-BLDAT.
       ITAB_02-BUDAT = ITAB_01-BUDAT.
       "非寄售产生的GR/IR
       IF ITAB_02-BLART <> 'RE'.
         ITAB_02-MBLNR = ITAB_01-AWKEY(10).   "取物料凭证号
       ELSE.
         ITAB_02-MBLNR2 = ITAB_01-AWKEY(10).  "取发票凭证号
       ENDIF.
       "寄售产生的GR/IR
       IF ITAB_02-BLART = 'WA'.
         ITAB_02-MBLNR = ITAB_02-ZUONR(10).   "取物料凭证号
       ENDIF.
       "寄售开票产生的GR/IR
       IF ITAB_02-BLART = 'RE' AND ITAB_02-EBELN = ''.
         ITAB_02-MBLNR = ITAB_02-ZUONR(10).   "取物料凭证号
       ENDIF.

       MODIFY ITAB_02.
     ENDLOOP.

     "将ITAB_02表的相关记录COPY到IT_PRINT_001内表
     LOOP AT ITAB_02.
       IT_PRINT_001-BUKRS = ITAB_02-BUKRS.
       IT_PRINT_001-GJAHR = ITAB_02-GJAHR.
       IT_PRINT_001-BELNR = ITAB_02-BELNR.
       IT_PRINT_001-KOART = ITAB_02-KOART.
       IT_PRINT_001-AUGDT = ITAB_02-AUGDT.
       IT_PRINT_001-SHKZG = ITAB_02-SHKZG.
       IF ITAB_02-SHKZG = 'S'.
         IT_PRINT_001-DMBTR = ITAB_02-DMBTR.
       ELSE.
         IT_PRINT_001-DMBTR = 0 - ITAB_02-DMBTR.
       ENDIF.
       IT_PRINT_001-SGTXT = ITAB_02-SGTXT.
       IT_PRINT_001-HKONT = ITAB_02-HKONT.
       IT_PRINT_001-LIFNR = ITAB_02-LIFNR.
       IT_PRINT_001-EBELN = ITAB_02-EBELN.
       IT_PRINT_001-EBELP = ITAB_02-EBELP.
       IT_PRINT_001-MATNR = ITAB_02-MATNR.
       IT_PRINT_001-MENGE = ITAB_02-MENGE.
       IT_PRINT_001-MEINS = ITAB_02-MEINS.
       IT_PRINT_001-ZEKKN = ITAB_02-ZEKKN.
       IT_PRINT_001-BLART = ITAB_02-BLART.
       IT_PRINT_001-BLDAT = ITAB_02-BLDAT.
       IT_PRINT_001-BUDAT = ITAB_02-BUDAT.
       IT_PRINT_001-MBLNR = ITAB_02-MBLNR.
       IT_PRINT_001-MBLNR2 = ITAB_02-MBLNR2.
       APPEND IT_PRINT_001.
     ENDLOOP.
   ENDLOOP.

*--取非寄售的发票号
  LOOP AT IT_PRINT_001.
    L_MBLNR2 = ''.
    "如果是发票凭证的取其发票号
    IF IT_PRINT_001-BLART = 'WE'.
      SELECT BELNR
        INTO L_MBLNR2
        FROM EKBE
        WHERE EBELN = IT_PRINT_001-EBELN
          AND EBELP = IT_PRINT_001-EBELP
          AND ZEKKN = IT_PRINT_001-ZEKKN
          AND VGABE = '2'
          AND GJAHR = P_GJAHR
          AND BELNR <> ''
          AND BUZEI <> ''
          AND LFBNR = IT_PRINT_001-MBLNR.
      ENDSELECT.

      "如果是物料凭证的通过以下方法取其发票号
      IF L_MBLNR2 = ''.
        SELECT BELNR
          INTO L_MBLNR2
          FROM EKBE
          WHERE EBELN = IT_PRINT_001-EBELN
            AND EBELP = IT_PRINT_001-EBELP
            AND ZEKKN = IT_PRINT_001-ZEKKN
            AND VGABE = '2'
            AND GJAHR = P_GJAHR
            AND BELNR <> ''
            AND BUZEI <> ''
            AND LFBNR IN (
                  SELECT LFBNR                           "参考凭证的凭证号
                     FROM EKBE
                     WHERE EBELN = IT_PRINT_001-EBELN    "采购凭证
                       AND EBELP = IT_PRINT_001-EBELP    "采购凭证项目
                       AND ZEKKN = IT_PRINT_001-ZEKKN
                       AND VGABE = '1'
                       AND GJAHR = P_GJAHR
                       AND BELNR = IT_PRINT_001-MBLNR     "物料凭证号
                       AND BUZEI <> ''
                           ).
        ENDSELECT.
      ENDIF.

      IT_PRINT_001-MBLNR2 = L_MBLNR2.
      MODIFY IT_PRINT_001.
    ENDIF.
  ENDLOOP.

*--取寄售的发票号
  LOOP AT IT_PRINT_001.
    IF IT_PRINT_001-BLART = 'WA'.
      SELECT BELNR
        INTO IT_PRINT_001-MBLNR2
        FROM RKWA
        WHERE MBLNR = IT_PRINT_001-MBLNR
          AND MJAHR = P_GJAHR
          AND ZEILE <> ''
          AND LIFNR = IT_PRINT_001-LIFNR
          AND WERKS = IT_PRINT_001-BUKRS
          AND MATNR = IT_PRINT_001-MATNR.
        ENDSELECT.

      MODIFY IT_PRINT_001.
    ENDIF.
  ENDLOOP.

*--判断该记录是否开票过否,若开过,则删除该记录
  IF P_TYPE2 = 'X'.
    LOOP AT IT_PRINT_001.
      IF IT_PRINT_001-MBLNR2 <> ''.
        DELETE IT_PRINT_001.
      ENDIF.
    ENDLOOP.
  ENDIF.

*--取发票检验的物料凭证号
  LOOP AT IT_PRINT_001.
    IF IT_PRINT_001-BLART = 'RE'.
      SELECT LFBNR
        INTO IT_PRINT_001-MBLNR
        FROM EKBE
        WHERE EBELN = IT_PRINT_001-EBELN
          AND EBELP = IT_PRINT_001-EBELP
          AND ZEKKN = IT_PRINT_001-ZEKKN
          AND VGABE = '2'
          AND GJAHR = P_GJAHR
          AND BELNR = IT_PRINT_001-MBLNR2
          AND BUZEI <> ''.
        ENDSELECT.

      MODIFY IT_PRINT_001.
    ENDIF.
  ENDLOOP.

*--取价格
  LOOP AT IT_PRINT_001.
    IF IT_PRINT_001-MENGE <> 0.
      IT_PRINT_001-NETPR = IT_PRINT_001-DMBTR * 100 / IT_PRINT_001-MENGE.
      IT_PRINT_001-PEINH = 100.
    ELSE.
      IT_PRINT_001-NETPR = 0.
      IT_PRINT_001-PEINH = 0.
    ENDIF.

    MODIFY IT_PRINT_001.
  ENDLOOP.

*--取供应商编号(根据采购订单号)
  LOOP AT IT_PRINT_001.
    IF IT_PRINT_001-EBELN <> ''.
      SELECT LIFNR
        INTO IT_PRINT_001-LIFNR
        FROM EKKO
        WHERE EBELN = IT_PRINT_001-EBELN.
      ENDSELECT.
    ELSE.
      SELECT LIFNR
        INTO IT_PRINT_001-LIFNR
        FROM BSEG
        WHERE BUKRS = IT_PRINT_001-BUKRS
          AND BELNR = IT_PRINT_001-MBLNR
          AND GJAHR = IT_PRINT_001-GJAHR
          AND BUZEI = 1
          AND BUZID = 'K'.
      ENDSELECT.
    ENDIF.

    MODIFY IT_PRINT_001.
  ENDLOOP.

*--供应商过滤
  LOOP AT IT_PRINT_001.
    IF IT_PRINT_001-LIFNR NOT IN P_LIFNR.
      DELETE IT_PRINT_001.
    ENDIF.
  ENDLOOP.

*--取物料描述
  LOOP AT IT_PRINT_001.
    SELECT MAKTX
      INTO IT_PRINT_001-MAKTX
      FROM MAKT
      WHERE SPRAS = '1'
        AND MATNR = IT_PRINT_001-MATNR.
    ENDSELECT.
    MODIFY IT_PRINT_001.
  ENDLOOP.

*--记录类型名称处理
  LOOP AT IT_PRINT_001.
    "
    IF IT_PRINT_001-BLART = 'WA'.
      IF IT_PRINT_001-SHKZG = 'H'.
        IT_PRINT_001-CTYPE = '寄售物料-领料'.
      ELSE.
        IT_PRINT_001-CTYPE = '寄售物料-退料'.
      ENDIF.
    ENDIF.
    "
    IF IT_PRINT_001-BLART = 'WE'.
      IF IT_PRINT_001-SHKZG = 'H'.
        IT_PRINT_001-CTYPE = '采购收货入库'.
      ELSE.
        IT_PRINT_001-CTYPE = '采购退货出库'.
      ENDIF.
    ENDIF.
    "
    IF IT_PRINT_001-BLART = 'RE'.
      IF IT_PRINT_001-EBELN = ''.
        IF IT_PRINT_001-SHKZG = 'H'.
          IT_PRINT_001-CTYPE = '发票检验(寄售物料-退料)'.
        ELSE.
          IT_PRINT_001-CTYPE = '发票检验(寄售物料-领料)'.
        ENDIF.
      ELSE.
        IT_PRINT_001-CTYPE = '发票检验'.
      ENDIF.
    ENDIF.
    "
    IF IT_PRINT_001-BLART = 'AB'.
      IT_PRINT_001-CTYPE = '自动清账'.
    ENDIF.
    "
    IF IT_PRINT_001-BLART = 'SA'.
      IF IT_PRINT_001-SHKZG = 'H'.
        IT_PRINT_001-CTYPE = 'GR/IR调整-冲销'.
      ELSE.
        IT_PRINT_001-CTYPE = 'GR/IR调整'.
      ENDIF.
    ENDIF.

    MODIFY IT_PRINT_001.
  ENDLOOP.

ENDFORM.                    " F_READ_DATA
*&---------------------------------------------------------------------*
*     普通报表格式的打印
*&---------------------------------------------------------------------*
FORM. F_PRINT_REPORT.

ENDFORM.                     " F_PRINT_REPORT
*&---------------------------------------------------------------------*
*A     ALV报表格式的打印
*&---------------------------------------------------------------------*
FORM. F_PRINT_ALV.
  REFRESH G_ALV_LISTHEADER[].
  PERFORM. F_ALV_MODIFY_LISTHEADER .
  REFRESH G_ALV_FIELDCAT.
  PERFORM. F_ALV_BUILD_FIELDCAT.
  PERFORM. F_ALV_BUILD_EVENTCAT.
  PERFORM. F_ALV_DISPLAY.
  STOP.
ENDFORM.                    " F_PRINT_ALV
*&---------------------------------------------------------------------*
*&      设置ALV报表输出时的抬头信息
*&---------------------------------------------------------------------*
FORM. F_ALV_MODIFY_LISTHEADER .
  DATA : L_ALV_LISTHEADER_LINE LIKE LINE OF G_ALV_LISTHEADER.
  L_ALV_LISTHEADER_LINE-TYP = 'H'.
  L_ALV_LISTHEADER_LINE-KEY = ''.
  L_ALV_LISTHEADER_LINE-INFO = 'GR/IR明细表'.
  APPEND L_ALV_LISTHEADER_LINE TO G_ALV_LISTHEADER.
ENDFORM.                    " F_ALV_MODIFY_LISTHEADER
*&---------------------------------------------------------------------*
*&      设置ALV报表输出时的字段 NEED MODIFY
*&---------------------------------------------------------------------*
FORM. F_ALV_BUILD_FIELDCAT .
  DATA : COL_POS TYPE I VALUE 0.
  G_ALV_LAYOUT-GET_SELINFOS      = 'X'.
  G_ALV_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
  G_ALV_LAYOUT-DETAIL_POPUP      = 'X'.
  G_ALV_LAYOUT-BOX_FIELDNAME     = 'FLAG'.
  G_ALV_LAYOUT-NO_KEYFIX         = 'X'.
  G_ALV_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

  ADD 1 TO COL_POS.
  G_ALV_FIELDCAT_LINE-REF_TABNAME = 'BKPF'.
  G_ALV_FIELDCAT_LINE-TABNAME = 'IT_PRINT_001'.
  G_ALV_FIELDCAT_LINE-REF_FIELDNAME = 'BUKRS'.
  G_ALV_FIELDCAT_LINE-FIELDNAME = 'BUKRS'.
  G_ALV_FIELDCAT_LINE-KEY = ''.
  G_ALV_FIELDCAT_LINE-DDICTXT(1)  = 'L'.
  G_ALV_FIELDCAT_LINE-SELTEXT_S = '公司代码'.
  G_ALV_FIELDCAT_LINE-SELTEXT_L = '公司代码'.
  G_ALV_FIELDCAT_LINE-SELTEXT_M = '公司代码'.
  G_ALV_FIELDCAT_LINE-REPTEXT_DDIC = '公司代码'.
  G_ALV_FIELDCAT_LINE-COL_POS = COL_POS.
  APPEND G_ALV_FIELDCAT_LINE TO G_ALV_FIELDCAT.

  ADD 1 TO COL_POS.
  G_ALV_FIELDCAT_LINE-REF_TABNAME = 'BKPF'.
  G_ALV_FIELDCAT_LINE-TABNAME = 'IT_PRINT_001'.
  G_ALV_FIELDCAT_LINE-REF_FIELDNAME = 'BLART'.
  G_ALV_FIELDCAT_LINE-FIELDNAME = 'BLART'.
  G_ALV_FIELDCAT_LINE-KEY = ''.
  G_ALV_FIELDCAT_LINE-DDICTXT(1)  = 'L'.
  G_ALV_FIELDCAT_LINE-SELTEXT_S = '凭证类型'.
  G_ALV_FIELDCAT_LINE-SELTEXT_L = '凭证类型'.
  G_ALV_FIELDCAT_LINE-SELTEXT_M = '凭证类型'.
  G_ALV_FIELDCAT_LINE-REPTEXT_DDIC = '凭证类型'.
  G_ALV_FIELDCAT_LINE-COL_POS = COL_POS.
  APPEND G_ALV_FIELDCAT_LINE TO G_ALV_FIELDCAT.

  ADD 1 TO COL_POS.
  G_ALV_FIELDCAT_LINE-REF_TABNAME = 'MAKT'.
  G_ALV_FIELDCAT_LINE-TABNAME = 'IT_PRINT_001'.
  G_ALV_FIELDCAT_LINE-REF_FIELDNAME = 'MAKTX'.
  G_ALV_FIELDCAT_LINE-FIELDNAME = 'CTYPE'.
  G_ALV_FIELDCAT_LINE-KEY = ''.
  G_ALV_FIELDCAT_LINE-DDICTXT(1)  = 'L'.
  G_ALV_FIELDCAT_LINE-SELTEXT_S = '类型名称'.
  G_ALV_FIELDCAT_LINE-SELTEXT_L = '类型名称'.
  G_ALV_FIELDCAT_LINE-SELTEXT_M = '类型名称'.
  G_ALV_FIELDCAT_LINE-REPTEXT_DDIC = '类型名称'.
  G_ALV_FIELDCAT_LINE-COL_POS = COL_POS.
  APPEND G_ALV_FIELDCAT_LINE TO G_ALV_FIELDCAT.

  ADD 1 TO COL_POS.
  G_ALV_FIELDCAT_LINE-REF_TABNAME = 'BKPF'.
  G_ALV_FIELDCAT_LINE-TABNAME = 'IT_PRINT_001'.
  G_ALV_FIELDCAT_LINE-REF_FIELDNAME = 'BLDAT'.
  G_ALV_FIELDCAT_LINE-FIELDNAME = 'BLDAT'.
  G_ALV_FIELDCAT_LINE-KEY = ''.
  G_ALV_FIELDCAT_LINE-DDICTXT(1)  = 'L'.
  G_ALV_FIELDCAT_LINE-SELTEXT_S = '凭证日期'.
  G_ALV_FIELDCAT_LINE-SELTEXT_L = '凭证日期'.
  G_ALV_FIELDCAT_LINE-SELTEXT_M = '凭证日期'.
  G_ALV_FIELDCAT_LINE-REPTEXT_DDIC = '凭证日期'.
  G_ALV_FIELDCAT_LINE-COL_POS = COL_POS.
  APPEND G_ALV_FIELDCAT_LINE TO G_ALV_FIELDCAT.

  ADD 1 TO COL_POS.
  G_ALV_FIELDCAT_LINE-REF_TABNAME = 'BKPF'.
  G_ALV_FIELDCAT_LINE-TABNAME = 'IT_PRINT_001'.
  G_ALV_FIELDCAT_LINE-REF_FIELDNAME = 'BUDAT'.
  G_ALV_FIELDCAT_LINE-FIELDNAME = 'BUDAT'.
  G_ALV_FIELDCAT_LINE-KEY = ''.
  G_ALV_FIELDCAT_LINE-DDICTXT(1)  = 'L'.
  G_ALV_FIELDCAT_LINE-SELTEXT_S = '记帐日期'.
  G_ALV_FIELDCAT_LINE-SELTEXT_L = '记帐日期'.
  G_ALV_FIELDCAT_LINE-SELTEXT_M = '记帐日期'.
  G_ALV_FIELDCAT_LINE-REPTEXT_DDIC = '记帐日期'.
  G_ALV_FIELDCAT_LINE-COL_POS = COL_POS.
  APPEND G_ALV_FIELDCAT_LINE TO G_ALV_FIELDCAT.

  ADD 1 TO COL_POS.
  G_ALV_FIELDCAT_LINE-REF_TABNAME = 'BKPF'.
  G_ALV_FIELDCAT_LINE-TABNAME = 'IT_PRINT_001'.
  G_ALV_FIELDCAT_LINE-REF_FIELDNAME = 'AUGDT'.
  G_ALV_FIELDCAT_LINE-FIELDNAME = 'AUGDT'.
  G_ALV_FIELDCAT_LINE-KEY = ''.
  G_ALV_FIELDCAT_LINE-DDICTXT(1)  = 'L'.
  G_ALV_FIELDCAT_LINE-SELTEXT_S = '清帐日期'.
  G_ALV_FIELDCAT_LINE-SELTEXT_L = '清帐日期'.
  G_ALV_FIELDCAT_LINE-SELTEXT_M = '清帐日期'.
  G_ALV_FIELDCAT_LINE-REPTEXT_DDIC = '清帐日期'.
  G_ALV_FIELDCAT_LINE-COL_POS = COL_POS.
  APPEND G_ALV_FIELDCAT_LINE TO G_ALV_FIELDCAT.

  ADD 1 TO COL_POS.
  G_ALV_FIELDCAT_LINE-REF_TABNAME = 'BKPF'.
  G_ALV_FIELDCAT_LINE-TABNAME = 'IT_PRINT_001'.
  G_ALV_FIELDCAT_LINE-REF_FIELDNAME = 'BELNR'.
  G_ALV_FIELDCAT_LINE-FIELDNAME = 'BELNR'.
  G_ALV_FIELDCAT_LINE-KEY = ''.
  G_ALV_FIELDCAT_LINE-DDICTXT(1)  = 'L'.
  G_ALV_FIELDCAT_LINE-SELTEXT_S = '会计凭证号码'.
  G_ALV_FIELDCAT_LINE-SELTEXT_L = '会计凭证号码'.
  G_ALV_FIELDCAT_LINE-SELTEXT_M = '会计凭证号码'.
  G_ALV_FIELDCAT_LINE-REPTEXT_DDIC = '会计凭证号码'.
  G_ALV_FIELDCAT_LINE-COL_POS = COL_POS.
  APPEND G_ALV_FIELDCAT_LINE TO G_ALV_FIELDCAT.


  ADD 1 TO COL_POS.
  G_ALV_FIELDCAT_LINE-REF_TABNAME = 'BSEG'.
  G_ALV_FIELDCAT_LINE-TABNAME = 'IT_PRINT_001'.
  G_ALV_FIELDCAT_LINE-REF_FIELDNAME = 'DMBTR'.
  G_ALV_FIELDCAT_LINE-FIELDNAME = 'DMBTR'.
  G_ALV_FIELDCAT_LINE-KEY = ''.
  G_ALV_FIELDCAT_LINE-DDICTXT(1)  = 'L'.
  G_ALV_FIELDCAT_LINE-SELTEXT_S = '本位币计的金额'.
  G_ALV_FIELDCAT_LINE-SELTEXT_L = '本位币计的金额'.
  G_ALV_FIELDCAT_LINE-SELTEXT_M = '本位币计的金额'.
  G_ALV_FIELDCAT_LINE-REPTEXT_DDIC = '本位币计的金额'.
  G_ALV_FIELDCAT_LINE-COL_POS = COL_POS.
  APPEND G_ALV_FIELDCAT_LINE TO G_ALV_FIELDCAT.

  ADD 1 TO COL_POS.
  G_ALV_FIELDCAT_LINE-REF_TABNAME = 'BSEG'.
  G_ALV_FIELDCAT_LINE-TABNAME = 'IT_PRINT_001'.
  G_ALV_FIELDCAT_LINE-REF_FIELDNAME = 'LIFNR'.
  G_ALV_FIELDCAT_LINE-FIELDNAME = 'LIFNR'.
  G_ALV_FIELDCAT_LINE-KEY = ''.
  G_ALV_FIELDCAT_LINE-DDICTXT(1)  = 'L'.
  G_ALV_FIELDCAT_LINE-SELTEXT_S = '供应商编号'.
  G_ALV_FIELDCAT_LINE-SELTEXT_L = '供应商编号'.
  G_ALV_FIELDCAT_LINE-SELTEXT_M = '供应商编号'.
  G_ALV_FIELDCAT_LINE-REPTEXT_DDIC = '供应商编号'.
  G_ALV_FIELDCAT_LINE-COL_POS = COL_POS.
  APPEND G_ALV_FIELDCAT_LINE TO G_ALV_FIELDCAT.

  ADD 1 TO COL_POS.
  G_ALV_FIELDCAT_LINE-REF_TABNAME = 'MSEG'.
  G_ALV_FIELDCAT_LINE-TABNAME = 'IT_PRINT_001'.
  G_ALV_FIELDCAT_LINE-REF_FIELDNAME = 'EBELN'.
  G_ALV_FIELDCAT_LINE-FIELDNAME = 'EBELN'.
  G_ALV_FIELDCAT_LINE-KEY = ''.
  G_ALV_FIELDCAT_LINE-DDICTXT(1)  = 'L'.
  G_ALV_FIELDCAT_LINE-SELTEXT_S = '采购凭证号'.
  G_ALV_FIELDCAT_LINE-SELTEXT_L = '采购凭证号'.
  G_ALV_FIELDCAT_LINE-SELTEXT_M = '采购凭证号'.
  G_ALV_FIELDCAT_LINE-REPTEXT_DDIC = '采购凭证号'.
  G_ALV_FIELDCAT_LINE-COL_POS = COL_POS.
  APPEND G_ALV_FIELDCAT_LINE TO G_ALV_FIELDCAT.

  ADD 1 TO COL_POS.
  G_ALV_FIELDCAT_LINE-REF_TABNAME = 'MSEG'.
  G_ALV_FIELDCAT_LINE-TABNAME = 'IT_PRINT_001'.
  G_ALV_FIELDCAT_LINE-REF_FIELDNAME = 'EBELP'.
  G_ALV_FIELDCAT_LINE-FIELDNAME = 'EBELP'.
  G_ALV_FIELDCAT_LINE-KEY = ''.
  G_ALV_FIELDCAT_LINE-DDICTXT(1)  = 'L'.
  G_ALV_FIELDCAT_LINE-SELTEXT_S = '采购项目号'.
  G_ALV_FIELDCAT_LINE-SELTEXT_L = '采购项目号'.
  G_ALV_FIELDCAT_LINE-SELTEXT_M = '采购项目号'.
  G_ALV_FIELDCAT_LINE-REPTEXT_DDIC = '采购项目号'.
  G_ALV_FIELDCAT_LINE-COL_POS = COL_POS.
  APPEND G_ALV_FIELDCAT_LINE TO G_ALV_FIELDCAT.

  ADD 1 TO COL_POS.
  G_ALV_FIELDCAT_LINE-REF_TABNAME = 'MSEG'.
  G_ALV_FIELDCAT_LINE-TABNAME = 'IT_PRINT_001'.
  G_ALV_FIELDCAT_LINE-REF_FIELDNAME = 'MBLNR'.
  G_ALV_FIELDCAT_LINE-FIELDNAME = 'MBLNR'.
  G_ALV_FIELDCAT_LINE-KEY = ''.
  G_ALV_FIELDCAT_LINE-DDICTXT(1)  = 'L'.
  G_ALV_FIELDCAT_LINE-SELTEXT_S = '物料凭证号'.
  G_ALV_FIELDCAT_LINE-SELTEXT_L = '物料凭证号'.
  G_ALV_FIELDCAT_LINE-SELTEXT_M = '物料凭证号'.
  G_ALV_FIELDCAT_LINE-REPTEXT_DDIC = '物料凭证号'.
  G_ALV_FIELDCAT_LINE-COL_POS = COL_POS.
  APPEND G_ALV_FIELDCAT_LINE TO G_ALV_FIELDCAT.

  ADD 1 TO COL_POS.
  G_ALV_FIELDCAT_LINE-REF_TABNAME = 'MSEG'.
  G_ALV_FIELDCAT_LINE-TABNAME = 'IT_PRINT_001'.
  G_ALV_FIELDCAT_LINE-REF_FIELDNAME = 'MBLNR'.
  G_ALV_FIELDCAT_LINE-FIELDNAME = 'MBLNR2'.
  G_ALV_FIELDCAT_LINE-KEY = ''.
  G_ALV_FIELDCAT_LINE-DDICTXT(1)  = 'L'.
  G_ALV_FIELDCAT_LINE-SELTEXT_S = '发票凭证号'.
  G_ALV_FIELDCAT_LINE-SELTEXT_L = '发票凭证号'.
  G_ALV_FIELDCAT_LINE-SELTEXT_M = '发票凭证号'.
  G_ALV_FIELDCAT_LINE-REPTEXT_DDIC = '发票凭证号'.
  G_ALV_FIELDCAT_LINE-COL_POS = COL_POS.
  APPEND G_ALV_FIELDCAT_LINE TO G_ALV_FIELDCAT.

  ADD 1 TO COL_POS.
  G_ALV_FIELDCAT_LINE-REF_TABNAME = 'EKPO'.
  G_ALV_FIELDCAT_LINE-TABNAME = 'IT_PRINT_001'.
  G_ALV_FIELDCAT_LINE-REF_FIELDNAME = 'MATNR'.
  G_ALV_FIELDCAT_LINE-FIELDNAME = 'MATNR'.
  G_ALV_FIELDCAT_LINE-KEY = ''.
  G_ALV_FIELDCAT_LINE-DDICTXT(1)  = 'L'.
  G_ALV_FIELDCAT_LINE-SELTEXT_S = '物料号'.
  G_ALV_FIELDCAT_LINE-SELTEXT_L = '物料号'.
  G_ALV_FIELDCAT_LINE-SELTEXT_M = '物料号'.
  G_ALV_FIELDCAT_LINE-REPTEXT_DDIC = '物料号'.
  G_ALV_FIELDCAT_LINE-COL_POS = COL_POS.
  APPEND G_ALV_FIELDCAT_LINE TO G_ALV_FIELDCAT.

  ADD 1 TO COL_POS.
  G_ALV_FIELDCAT_LINE-REF_TABNAME = 'MAKT'.
  G_ALV_FIELDCAT_LINE-TABNAME = 'IT_PRINT_001'.
  G_ALV_FIELDCAT_LINE-REF_FIELDNAME = 'MAKTX'.
  G_ALV_FIELDCAT_LINE-FIELDNAME = 'MAKTX'.
  G_ALV_FIELDCAT_LINE-KEY = ''.
  G_ALV_FIELDCAT_LINE-DDICTXT(1)  = 'L'.
  G_ALV_FIELDCAT_LINE-SELTEXT_S = '物料描述'.
  G_ALV_FIELDCAT_LINE-SELTEXT_L = '物料描述'.
  G_ALV_FIELDCAT_LINE-SELTEXT_M = '物料描述'.
  G_ALV_FIELDCAT_LINE-REPTEXT_DDIC = '物料描述'.
  G_ALV_FIELDCAT_LINE-COL_POS = COL_POS.
  APPEND G_ALV_FIELDCAT_LINE TO G_ALV_FIELDCAT.

  ADD 1 TO COL_POS.
  G_ALV_FIELDCAT_LINE-REF_TABNAME = 'MSEG'.
  G_ALV_FIELDCAT_LINE-TABNAME = 'IT_PRINT_001'.
  G_ALV_FIELDCAT_LINE-REF_FIELDNAME = 'MENGE'.
  G_ALV_FIELDCAT_LINE-FIELDNAME = 'MENGE'.
  G_ALV_FIELDCAT_LINE-KEY = ''.
  G_ALV_FIELDCAT_LINE-DDICTXT(1)  = 'L'.
  G_ALV_FIELDCAT_LINE-SELTEXT_S = '出入库数量'.
  G_ALV_FIELDCAT_LINE-SELTEXT_L = '出入库数量'.
  G_ALV_FIELDCAT_LINE-SELTEXT_M = '出入库数量'.
  G_ALV_FIELDCAT_LINE-REPTEXT_DDIC = '出入库数量'.
  G_ALV_FIELDCAT_LINE-COL_POS = COL_POS.
  APPEND G_ALV_FIELDCAT_LINE TO G_ALV_FIELDCAT.

  ADD 1 TO COL_POS.
  G_ALV_FIELDCAT_LINE-REF_TABNAME = 'MSEG'.
  G_ALV_FIELDCAT_LINE-TABNAME = 'IT_PRINT_001'.
  G_ALV_FIELDCAT_LINE-REF_FIELDNAME = 'MEINS'.
  G_ALV_FIELDCAT_LINE-FIELDNAME = 'MEINS'.
  G_ALV_FIELDCAT_LINE-KEY = ''.
  G_ALV_FIELDCAT_LINE-DDICTXT(1)  = 'L'.
  G_ALV_FIELDCAT_LINE-SELTEXT_S = '计量单位'.
  G_ALV_FIELDCAT_LINE-SELTEXT_L = '计量单位'.
  G_ALV_FIELDCAT_LINE-SELTEXT_M = '计量单位'.
  G_ALV_FIELDCAT_LINE-REPTEXT_DDIC = '计量单位'.
  G_ALV_FIELDCAT_LINE-COL_POS = COL_POS.
  APPEND G_ALV_FIELDCAT_LINE TO G_ALV_FIELDCAT.

  ADD 1 TO COL_POS.
  G_ALV_FIELDCAT_LINE-REF_TABNAME = 'EKPO'.
  G_ALV_FIELDCAT_LINE-TABNAME = 'IT_PRINT_001'.
  G_ALV_FIELDCAT_LINE-REF_FIELDNAME = 'NETPR'.
  G_ALV_FIELDCAT_LINE-FIELDNAME = 'NETPR'.
  G_ALV_FIELDCAT_LINE-KEY = ''.
  G_ALV_FIELDCAT_LINE-DDICTXT(1)  = 'L'.
  G_ALV_FIELDCAT_LINE-SELTEXT_S = '净价格'.
  G_ALV_FIELDCAT_LINE-SELTEXT_L = '净价格'.
  G_ALV_FIELDCAT_LINE-SELTEXT_M = '净价格'.
  G_ALV_FIELDCAT_LINE-REPTEXT_DDIC = '净价格'.
  G_ALV_FIELDCAT_LINE-COL_POS = COL_POS.
  APPEND G_ALV_FIELDCAT_LINE TO G_ALV_FIELDCAT.

  ADD 1 TO COL_POS.
  G_ALV_FIELDCAT_LINE-REF_TABNAME = 'EKPO'.
  G_ALV_FIELDCAT_LINE-TABNAME = 'IT_PRINT_001'.
  G_ALV_FIELDCAT_LINE-REF_FIELDNAME = 'PEINH'.
  G_ALV_FIELDCAT_LINE-FIELDNAME = 'PEINH'.
  G_ALV_FIELDCAT_LINE-KEY = ''.
  G_ALV_FIELDCAT_LINE-DDICTXT(1)  = 'L'.
  G_ALV_FIELDCAT_LINE-SELTEXT_S = '价格单位'.
  G_ALV_FIELDCAT_LINE-SELTEXT_L = '价格单位'.
  G_ALV_FIELDCAT_LINE-SELTEXT_M = '价格单位'.
  G_ALV_FIELDCAT_LINE-REPTEXT_DDIC = '价格单位'.
  G_ALV_FIELDCAT_LINE-COL_POS = COL_POS.
  APPEND G_ALV_FIELDCAT_LINE TO G_ALV_FIELDCAT.

  ADD 1 TO COL_POS.
  G_ALV_FIELDCAT_LINE-REF_TABNAME = 'BSEG'.
  G_ALV_FIELDCAT_LINE-TABNAME = 'IT_PRINT_001'.
  G_ALV_FIELDCAT_LINE-REF_FIELDNAME = 'SGTXT'.
  G_ALV_FIELDCAT_LINE-FIELDNAME = 'SGTXT'.
  G_ALV_FIELDCAT_LINE-KEY = ''.
  G_ALV_FIELDCAT_LINE-DDICTXT(1)  = 'L'.
  G_ALV_FIELDCAT_LINE-SELTEXT_S = '项目文本'.
  G_ALV_FIELDCAT_LINE-SELTEXT_L = '项目文本'.
  G_ALV_FIELDCAT_LINE-SELTEXT_M = '项目文本'.
  G_ALV_FIELDCAT_LINE-REPTEXT_DDIC = '项目文本'.
  G_ALV_FIELDCAT_LINE-COL_POS = COL_POS.
  APPEND G_ALV_FIELDCAT_LINE TO G_ALV_FIELDCAT.

  ADD 1 TO COL_POS.
  G_ALV_FIELDCAT_LINE-REF_TABNAME = 'BSEG'.
  G_ALV_FIELDCAT_LINE-TABNAME = 'IT_PRINT_001'.
  G_ALV_FIELDCAT_LINE-REF_FIELDNAME = 'HKONT'.
  G_ALV_FIELDCAT_LINE-FIELDNAME = 'HKONT'.
  G_ALV_FIELDCAT_LINE-KEY = ''.
  G_ALV_FIELDCAT_LINE-DDICTXT(1)  = 'L'.
  G_ALV_FIELDCAT_LINE-SELTEXT_S = '总分类帐帐目'.
  G_ALV_FIELDCAT_LINE-SELTEXT_L = '总分类帐帐目'.
  G_ALV_FIELDCAT_LINE-SELTEXT_M = '总分类帐帐目'.
  G_ALV_FIELDCAT_LINE-REPTEXT_DDIC = '总分类帐帐目'.
  G_ALV_FIELDCAT_LINE-COL_POS = COL_POS.
  APPEND G_ALV_FIELDCAT_LINE TO G_ALV_FIELDCAT.

ENDFORM.                    " F_ALV_BUILD_FIELDCAT
*&---------------------------------------------------------------------*
*&      改变ALV的TOP_OF_PAGE事件处理过程
*&---------------------------------------------------------------------*
FORM. F_ALV_BUILD_EVENTCAT .
  DATA : LS_EVENT TYPE SLIS_ALV_EVENT.
  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
            I_LIST_TYPE = 0
       IMPORTING
            ET_EVENTS   = G_ALV_EVENT.
  READ TABLE G_ALV_EVENT WITH KEY NAME =
       SLIS_EV_TOP_OF_PAGE INTO LS_EVENT.
  IF SY-SUBRC = 0.
    MOVE G_ALV_FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.
    APPEND LS_EVENT TO G_ALV_EVENT.
  ENDIF.
ENDFORM.                    " F_ALV_BUILD_EVENTCAT
*&---------------------------------------------------------------------*
*&      调用ALV控件的输出程序
*&---------------------------------------------------------------------*
FORM. F_ALV_DISPLAY .
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         I_CALLBACK_PROGRAM      = 'ZR_FI_017'
         I_CALLBACK_USER_COMMAND = 'F_ALV_USER_COMMAND'
         IS_LAYOUT               = G_ALV_LAYOUT
         IT_FIELDCAT             = G_ALV_FIELDCAT
         I_SAVE                  = 'A'
         IT_EVENTS               = G_ALV_EVENT
         I_GRID_TITLE            = ''
       TABLES
         T_OUTTAB                = IT_PRINT_001
       EXCEPTIONS
         PROGRAM_ERROR           = 1
         OTHERS                  = 2.
ENDFORM.                    " F_ALV_DISPLAY
*&---------------------------------------------------------------------*
*&      ALV控件双击事件的接口
*&---------------------------------------------------------------------*
FORM. F_ALV_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
                        RS_SELFIELD TYPE SLIS_SELFIELD.
  DATA S_TEMP(100) TYPE C.
  CASE R_UCOMM.
    WHEN '&IC1'.  "NEED MODIFY
      IF RS_SELFIELD-SEL_TAB_FIELD = 'IT_PRINT_001-MATNR'.
        G_SELECTED_FIELD_VALUE =  RS_SELFIELD-VALUE.
       "需调用其它程序。

      ENDIF.
    WHEN OTHERS.
  ENDCASE.
ENDFORM.                    "F_ALV_USER_COMMAND
*&---------------------------------------------------------------------*
*&      调用ALV控件的抬头输出程序
*&---------------------------------------------------------------------*
FORM. F_ALV_EVENT_TOP_OF_PAGE.
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
       EXPORTING
         IT_LIST_COMMENTARY = G_ALV_LISTHEADER.
ENDFORM. "F_ALV_EVENT_TOP_OF_PAGE
*&---------------------------------------------------------------------*
*&      输出ALV的页脚
*&---------------------------------------------------------------------*
FORM. F_ALV_EVENT_END_OF_LIST.
  SKIP.
  WRITE: AT 280 '总计:'.
ENDFORM. "F_ALV_EVENT_END_OF_LIST
*&---------------------------------------------------------------------*
*&      单据表头显示
*&---------------------------------------------------------------------*
FORM. SUB_HEAD.

ENDFORM.                    " SUB_OUTPUTHEAD
*&---------------------------------------------------------------------
*&      单据表尾显示
*&---------------------------------------------------------------------
FORM. SUB_BOTTOM.
*取制单人
 CLEAR NAME_LAST.
 CLEAR NAME_FIRST.
 CLEAR NAME.
 SELECT NAME_LAST NAME_FIRST
      FROM USER_ADDR
   INTO (NAME_LAST, NAME_FIRST)
   WHERE BNAME = SY-UNAME .   "取logon 帐号
 ENDSELECT.
 CONCATENATE NAME_LAST(4) NAME_FIRST(8) INTO NAME.

 WRITE: AT 70  '操作员',NAME+0(10) LEFT-JUSTIFIED .
 WRITE: AT 90 '打印时间:',SY-DATUM,SY-UZEIT.
ENDFORM.                    "SUB_BOTTOM

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/765243/viewspace-253302/,如需转载,请注明出处,否则将追究法律责任。

上一篇: ZR_FI_020
下一篇: ZR_FI_019
请登录后发表评论 登录
全部评论

注册时间:2006-03-01

  • 博文量
    43
  • 访问量
    33242