粘贴过来个表学习下

类别:软件工程 点击:0 评论:0 推荐:

***************************************
*  定义一个报表,非标准报表,
*  定义长度为70行,宽度为200.
***************************************

REPORT ZMMSPT NO STANDARD PAGE HEADING LINE-COUNT 70 LINE-SIZE 200.
*&--------------------------------------------------------*
*& 海烟物流运营部备件及价格明细表
*& Created by Hand
*&--------------------------------------------------------*
TABLES: MKPF,
        MSEG,
        MAKT,
        MBEW,
        MARD.

******************************
* 数据定义
******************************
DATA: BEGIN OF ITAB_SPT OCCURS 0,
        MATNR LIKE MSEG-MATNR,"物料号
        MAKTX LIKE MAKT-MAKTX, "物料描述
        LABST LIKE MARD-LABST, "库存数量
        SUM_PUR LIKE MSEG-ERFMG,"累计购货数量
        SUM_RET LIKE MSEG-ERFMG,"累计退货数量
        SUM_GR LIKE MSEG-ERFMG,"累计收货数量
        SUM_GI LIKE MSEG-ERFMG,"累计发货数量
        VERPR LIKE MBEW-VERPR, "单价
        VERPRTTL LIKE MBEW-VERPR,   "总价
      END OF ITAB_SPT.

***************************************
* 定义一个内部表的副本.包含ITAB_SPT的机构.
*
***************************************
DATA BEGIN OF ITAB_SPT_TMP OCCURS 0.
        INCLUDE STRUCTURE ITAB_SPT.
DATA END OF ITAB_SPT_TMP.

***************************************
* 定义一个SQL字符内表.
*
***************************************
DATA: BEGIN OF ITAB_SQL OCCURS 0,
        SQL_TXT(72),
      END OF ITAB_SQL.

***************************************
* 定义一个总类的统计内表,用来存放
*  计算后的数据的结果.
***************************************
DATA: BEGIN OF ITAB_SUM_NUM OCCURS 0,
        MATNR LIKE MSEG-MATNR,
        MBLNR LIKE MSEG-MBLNR,
        BWART LIKE MSEG-BWART,
        SMBLN LIKE MSEG-SMBLN,
        ERFMG LIKE MSEG-ERFMG,
      END OF ITAB_SUM_NUM.
***************************************
* 定义一些长量.
*
***************************************
CONSTANTS: CNS_PLANT       LIKE MARD-WERKS VALUE '1000', "工厂
           CNS_STG_LOC     LIKE MARD-LGORT VALUE '0071',"存储地点
           CNS_PAGE_LINES  TYPE I VALUE 30,         "每页显示行数+1
           CNS_MATERIAL_TYPE LIKE MARA-MTART VALUE 'FERT'."物料类型

***************************************
* LAYOUT.定义画面查询输入条件.
*
***************************************
SELECTION-SCREEN BEGIN OF BLOCK  RAD1 WITH FRAME
                                      TITLE TEXT-000.
"记帐日期
SELECT-OPTIONS: BUDAT FOR MKPF-BUDAT OBLIGATORY,
                MATNR FOR MSEG-MATNR."物料号
PARAMETERS MAKTX LIKE MAKT-MAKTX.      "物料描述
SELECT-OPTIONS: LABST1 FOR MARD-LABST,  "库存数量
                GRNUM FOR MSEG-ERFMG,   "累计收货数量
                GINUM FOR MSEG-ERFMG,   "累计发货数量
                VERPR1 FOR MBEW-VERPR,  "物料单价
                VERPRTTL FOR MBEW-VERPR."物料总价
SELECTION-SCREEN END OF BLOCK RAD1.

******************************
* AT SELECTION-SCREEN检查输入.
*
******************************
AT SELECTION-SCREEN.
  "取明细数据
  CLEAR ITAB_SPT.
  CLEAR ITAB_SPT[].
  PERFORM FRM_GET_DATA TABLES ITAB_SPT.

******************************
*START-OF-SELECTION.
******************************
START-OF-SELECTION.
  SET PF-STATUS 'TEST'.
* 数据输出
  PERFORM FRM_DATA_OUTPUT.

******************************
* AT LINE-SELECTION.
* 设置一些事件.让用户选择物料号码,就显示详细信息.
******************************
*AT LINE-SELECTION.
* 弹出窗口方式
*   WINDOW STARTING AT 40 10 ENDING AT 70 20.
*        WRITE : / ITAB_SPT-MATNR.
* 新开REPORT方式
* WRITE: /XXXXXX.

******************************
* AT USER-COMMAND.
* 用户自己定义了PF-STATUS 'TEST'里面
* 定义了F2的FUNCTION CODE为USER_F2
* 所以在这里处理F2的事件.
******************************
AT USER-COMMAND.
  CASE SY-UCOMM.
    WHEN 'USER_F2'.
      WRITE:/ ITAB_SPT-MATNR.
* 以下类型不匹配,所以注释.用户单点一个数据.
* CALL 下一个事物码,把必要参数传入,然后跳入下一屏幕
* RUN MBO3 ,F1,浪头,然后看参数ID.里面是需要的接口.
* SET PARAMETER ID 'MBN' FIELD ITAB_SPT-MATNR.
* call transACtion 'MB03' AND SKIP FIRST SCREEN.
    WHEN 'SAVE'.
      WRITE:/ 'YOU CLICK SAVE'.
  ENDCASE.

*&---------------------------------------------------------------------*
*&      Form  FRM_GET_DATA
*&---------------------------------------------------------------------*
*       取明细数据
*----------------------------------------------------------------------*
*      -->P_ITAB_SPT  text
*----------------------------------------------------------------------*
FORM FRM_GET_DATA TABLES   P_ITAB_SPT STRUCTURE ITAB_SPT.

* 取物料号
  PERFORM FRM_GET_MATNR TABLES ITAB_SPT.

* 检查取出到ITAB_SPT的物料数据.是否为空.
* 如果为空就输出错误信息.
  PERFORM FRM_CHK_COUNT TABLES ITAB_SPT.

* 删除物料类型不符的数据
  PERFORM FRM_CHK_MTYPE TABLES ITAB_SPT.

* 检查取出到ITAB_SPT的物料数据.是否为空.
* 如果为空就输出错误信息.
  PERFORM FRM_CHK_COUNT TABLES ITAB_SPT.


* 取物料描述和库存数量
  PERFORM FRM_GET_MTX_LST TABLES ITAB_SPT.

* 检查取出到ITAB_SPT的物料数据.是否为空.
* 如果为空就输出错误信息.
  PERFORM FRM_CHK_COUNT TABLES ITAB_SPT.

* 取物料单价和总价
*  PERFORM FRM_GET_VERPR TABLES ITAB_SPT.
*  PERFORM FRM_CHK_COUNT TABLES ITAB_SPT.
* 累计数量
  CLEAR ITAB_SUM_NUM.
  CLEAR ITAB_SUM_NUM[].
  PERFORM FRM_SUM_NUM TABLES ITAB_SUM_NUM ITAB_SPT.
  PERFORM FRM_CHK_COUNT TABLES ITAB_SPT.
ENDFORM.                    " FRM_GET_DATA

*&---------------------------------------------------------------------*
*&      Form  FRM_GET_MATNR
*&---------------------------------------------------------------------*
*       取物料号
*----------------------------------------------------------------------*
*      -->P_ITAB_SPT  text
*----------------------------------------------------------------------*
FORM FRM_GET_MATNR TABLES P_ITAB_SPT STRUCTURE ITAB_SPT.

  SELECT DISTINCT G~MATNR
    INTO CORRESPONDING FIELDS OF TABLE P_ITAB_SPT
    FROM MKPF AS F INNER JOIN MSEG AS G
      ON F~MBLNR = G~MBLNR "物料凭证编号
     AND F~MJAHR = G~MJAHR "物料凭证的年份
   WHERE F~BUDAT IN BUDAT
     AND G~MATNR IN MATNR.
ENDFORM.                    " FRM_GET_MATNR

*&---------------------------------------------------------------------*
*&      Form  FRM_GET_MTX_LST
*&---------------------------------------------------------------------*
*       取物料描述和库存数量
*----------------------------------------------------------------------*
*      -->P_ITAB_SPT  text
*----------------------------------------------------------------------*
FORM FRM_GET_MTX_LST TABLES   P_ITAB_SPT STRUCTURE ITAB_SPT.
* 动态SQL生成
  CLEAR ITAB_SQL.
  CLEAR ITAB_SQL[].
  "物料描述

* 把用户输入的物料描述,组织成查询语言.
* 在下面调用.因为传入的只是内表字段
* 所以在字段内容改变后,要添加到内表中.
  PERFORM FRM_DY_SQL_MAKTX CHANGING ITAB_SQL-SQL_TXT.
  APPEND ITAB_SQL.

  SELECT T~MATNR T~MAKTX D~LABST
    INTO CORRESPONDING FIELDS OF TABLE ITAB_SPT_TMP
    FROM MAKT AS T INNER JOIN MARD AS D
      ON T~MATNR = D~MATNR
     FOR ALL ENTRIES IN P_ITAB_SPT
   WHERE T~MATNR = P_ITAB_SPT-MATNR
     AND T~SPRAS = SY-LANGU
     AND D~WERKS = CNS_PLANT
     AND D~LGORT = CNS_STG_LOC
     AND D~LABST IN LABST1
* ()来引用上面的内表做查询条件.
     AND (ITAB_SQL).

* 把查询出来的结构放入临时表,
* 然后再放入P_ITAB_SPT(他改变会改变ITAB_SPT)
  MOVE ITAB_SPT_TMP[] TO P_ITAB_SPT[].

ENDFORM.                    " FRM_GET_MTX_LST

*&---------------------------------------------------------------------*
*&      Form  FRM_DY_SQL_MAKTX
*&---------------------------------------------------------------------*
*       物料描述
*----------------------------------------------------------------------*
*      <--P_SQL_TXT  text
*----------------------------------------------------------------------*
FORM FRM_DY_SQL_MAKTX CHANGING P_SQL_TXT.

* 定义一个临时的变量.用来存放中转.
  DATA L_MAKTX LIKE MAKT-MAKTX.

  L_MAKTX = MAKTX.
  CONDENSE L_MAKTX.

  CONCATENATE 'T~MAKTX LIKE ''%' L_MAKTX '%''' INTO P_SQL_TXT.

* MAKTX(物料描述),去数据库中查询,只要物料描述中包含用户输入的.
* 取出输入框中的自符. 匹配成
* T~MAKTX LIKE '%L_MAKTX%' INTO P_SQL_TXT.


ENDFORM.                    " FRM_DY_SQL_MAKTX

*&---------------------------------------------------------------------*
*&      Form  FRM_GET_VERPR
*&---------------------------------------------------------------------*
*       取物料单价和总价
*----------------------------------------------------------------------*
*      -->P_ITAB_SPT  text
*----------------------------------------------------------------------*
FORM FRM_GET_VERPR TABLES P_ITAB_SPT STRUCTURE ITAB_SPT.

  SELECT MATNR VERPR
    INTO CORRESPONDING FIELDS OF TABLE ITAB_SPT_TMP
    FROM MBEW
     FOR ALL ENTRIES IN P_ITAB_SPT
   WHERE MATNR = P_ITAB_SPT-MATNR
     AND VERPR IN VERPR1.

  LOOP AT ITAB_SPT_TMP.
    READ TABLE P_ITAB_SPT WITH KEY MATNR = ITAB_SPT_TMP-MATNR.
    ITAB_SPT_TMP-MAKTX = P_ITAB_SPT-MAKTX.
    ITAB_SPT_TMP-LABST = P_ITAB_SPT-LABST.
    ITAB_SPT_TMP-VERPRTTL = ITAB_SPT_TMP-VERPR * ITAB_SPT_TMP-LABST.
    MODIFY ITAB_SPT_TMP.
  ENDLOOP.

  MOVE ITAB_SPT_TMP[] TO P_ITAB_SPT[].

  "剔除不符合用户输入的总价
  DELETE P_ITAB_SPT WHERE NOT VERPRTTL IN VERPRTTL.
ENDFORM.                    " FRM_GET_VERPR

 

*&---------------------------------------------------------------------*
*&      Form  FRM_CHK_COUNT
*&---------------------------------------------------------------------*
*       检查数据条数
*----------------------------------------------------------------------*
*      -->P_ITAB_SPT  text
*----------------------------------------------------------------------*
FORM FRM_CHK_COUNT TABLES   P_ITAB_SPT STRUCTURE ITAB_SPT.
  DATA L_COUNT TYPE I.

* 取出传入的内表的总数据跳数.如果为0
* 则报一个错误.
  DESCRIBE TABLE P_ITAB_SPT LINES L_COUNT.
  IF L_COUNT = 0.
    MESSAGE E429(MO).
  ENDIF.
ENDFORM.                    " FRM_CHK_COUNT

*&---------------------------------------------------------------------*
*&      Form  FRM_SUM_NUM
*&---------------------------------------------------------------------*
*       累计数量
*----------------------------------------------------------------------*
*      -->P_ITAB_SUM_NUM  text
*----------------------------------------------------------------------*
FORM FRM_SUM_NUM TABLES P_ITAB_SUM_NUM STRUCTURE ITAB_SUM_NUM
                        P_ITAB_SPT STRUCTURE ITAB_SPT.
  DATA L_ITAB_TMP LIKE ITAB_SUM_NUM OCCURS 0 WITH HEADER LINE.
  DATA: BEGIN OF L_ITAB_COLLECT OCCURS 0,
          MATNR LIKE MSEG-MATNR,
          TTL_GI TYPE I,
          TTL_PUR TYPE I,
          TTL_RET TYPE I,
        END OF L_ITAB_COLLECT.

* 取出符合移动类型的数据
  SELECT G~MBLNR G~BWART G~SMBLN G~ERFMG G~MATNR
    INTO CORRESPONDING FIELDS OF TABLE P_ITAB_SUM_NUM
    FROM MKPF AS F INNER JOIN MSEG AS G
      ON F~MBLNR = G~MBLNR "物料凭证编号
     AND F~MJAHR = G~MJAHR "物料凭证的年份
   WHERE G~BWART IN ('201','X01','261','101','262','X02','202','102')
     AND F~BUDAT IN BUDAT
     AND G~MATNR IN MATNR
     AND G~INSMK = ''.

  MOVE P_ITAB_SUM_NUM[] TO L_ITAB_TMP[].

* 删除冲销记录
  LOOP AT L_ITAB_TMP WHERE BWART <> '101' AND SMBLN <> ''.
    DELETE P_ITAB_SUM_NUM WHERE MBLNR = L_ITAB_TMP-SMBLN.
    DELETE P_ITAB_SUM_NUM WHERE MBLNR = L_ITAB_TMP-MBLNR.
  ENDLOOP.
  DELETE P_ITAB_SUM_NUM WHERE BWART = '102'.

* 汇总不同类型的累计数据
  CLEAR L_ITAB_COLLECT[].
  LOOP AT P_ITAB_SUM_NUM.
    CLEAR L_ITAB_COLLECT.
    L_ITAB_COLLECT-MATNR = P_ITAB_SUM_NUM-MATNR.

    "累计发货数量
    IF P_ITAB_SUM_NUM-BWART = '201' OR P_ITAB_SUM_NUM-BWART = 'X01'
     OR P_ITAB_SUM_NUM-BWART = '261'.
      L_ITAB_COLLECT-TTL_GI = P_ITAB_SUM_NUM-ERFMG.
    ENDIF.
    "累计购货数量
    IF P_ITAB_SUM_NUM-BWART = '101'.
      L_ITAB_COLLECT-TTL_PUR = P_ITAB_SUM_NUM-ERFMG.
    ENDIF.
    "累计退货数量
    IF P_ITAB_SUM_NUM-BWART = '202' OR P_ITAB_SUM_NUM-BWART = 'X02'
     OR P_ITAB_SUM_NUM-BWART = '262'.
      L_ITAB_COLLECT-TTL_RET = P_ITAB_SUM_NUM-ERFMG.
    ENDIF.

    COLLECT L_ITAB_COLLECT.
  ENDLOOP.

* 更新主表数据
  LOOP AT P_ITAB_SPT.
    READ TABLE L_ITAB_COLLECT WITH KEY MATNR = P_ITAB_SPT-MATNR.
    IF SY-SUBRC = 0.
      P_ITAB_SPT-SUM_PUR = L_ITAB_COLLECT-TTL_PUR.
      P_ITAB_SPT-SUM_RET = L_ITAB_COLLECT-TTL_RET.
      P_ITAB_SPT-SUM_GR = L_ITAB_COLLECT-TTL_RET +
                          L_ITAB_COLLECT-TTL_PUR.
      P_ITAB_SPT-SUM_GI = L_ITAB_COLLECT-TTL_GI.
      MODIFY P_ITAB_SPT.
    ELSE.
      DELETE P_ITAB_SPT.
    ENDIF.
  ENDLOOP.

* 剔除不符合用户输入的累计收货数量
  DELETE P_ITAB_SPT WHERE NOT SUM_GR IN GRNUM.
* 剔除不符合用户输入的累计发货数量
  DELETE P_ITAB_SPT WHERE NOT SUM_GI IN GINUM.
ENDFORM.                    " FRM_SUM_NUM

*&---------------------------------------------------------------------*
*&      Form  FRM_WRT_HEAD
*&---------------------------------------------------------------------*
*       表头
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_WRT_HEAD.
  DATA L_BUDAT_HIGH LIKE MKPF-BUDAT.

  L_BUDAT_HIGH = BUDAT-HIGH.
  CONDENSE L_BUDAT_HIGH.

  WRITE 60 '海烟物流运营部备件及价格明细表'.
  WRITE:/ '时间范围: ' NO-GAP, BUDAT-LOW NO-GAP.

  IF L_BUDAT_HIGH <> '00000000'.
    WRITE: '至' NO-GAP, L_BUDAT_HIGH.
  ENDIF.
ENDFORM.                    " FRM_WRT_HEAD

*&---------------------------------------------------------------------*
*&      Form  FRM_WRT_TIT
*&---------------------------------------------------------------------*
*       数据标题
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_WRT_TIT.
*  FORMAT COLOR COL_HEADING.
  WRITE /(165) SY-ULINE.
  WRITE:/(1) SY-VLINE, (4) '序号',
         (1) SY-VLINE, (10) '物料号',
         (1) SY-VLINE, (40) '物料描述',
         (1) SY-VLINE, (10) '库存数量' CENTERED,
         (1) SY-VLINE, (10) '累计购货' CENTERED,
         (1) SY-VLINE, (10) '累计退货' CENTERED,
         (1) SY-VLINE, (10) '累计收货' CENTERED,
         (1) SY-VLINE, (10) '累计发货' CENTERED,
         (1) SY-VLINE, (15) '单价(RMB)' CENTERED,
         (1) SY-VLINE, (15) '总金额(RMB)' CENTERED,
         (1) SY-VLINE.
  WRITE:/(1) SY-VLINE,
         (6) SY-VLINE RIGHT-JUSTIFIED,
         (12) SY-VLINE RIGHT-JUSTIFIED,
         (42) SY-VLINE RIGHT-JUSTIFIED,
         (12) SY-VLINE RIGHT-JUSTIFIED,
         (10) '数量' CENTERED, (1) SY-VLINE,
         (10) '数量' CENTERED, (1) SY-VLINE,
         (10) '数量' CENTERED, (1) SY-VLINE,
         (10) '数量' CENTERED, (1) SY-VLINE,
         (15) ' '    CENTERED, (1) SY-VLINE,
         (15) ' '    CENTERED, (1) SY-VLINE.
  WRITE /(165) SY-ULINE.

ENDFORM.                    " FRM_WRT_TIT

*&---------------------------------------------------------------------*
*&      Form  FRM_WRT_FOOT
*&---------------------------------------------------------------------*
*       数据尾
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_WRT_FOOT.
  DATA: L_LINE TYPE I,
        L_COUNT TYPE I,
        L_MOD TYPE I.

  DESCRIBE TABLE ITAB_SPT LINES L_LINE.
  L_COUNT = L_LINE DIV ( CNS_PAGE_LINES - 1 ).
  L_MOD = L_LINE MOD ( CNS_PAGE_LINES - 1 ).
  IF L_MOD > 0.
    L_COUNT = L_COUNT + 1.
  ENDIF.

  FORMAT COLOR COL_BACKGROUND.

  WRITE:/ '备件及价格明细表', 75 '报表生成日期:', SY-DATUM,
          140 '页码:', SY-PAGNO LEFT-JUSTIFIED NO-GAP,
          '/' NO-GAP, L_COUNT LEFT-JUSTIFIED NO-GAP.

ENDFORM.                    " FRM_WRT_FOOT

*&---------------------------------------------------------------------*
*&      Form  FRM_WRT_DATA
*&---------------------------------------------------------------------*
*       主数据
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_WRT_DATA.
  DATA: L_LABST(15),
        L_SUM_PUR(15),
        L_SUM_RET(15),
        L_SUM_GR(15),
        L_SUM_GI(15).

  L_LABST = ITAB_SPT-LABST.
  L_LABST = L_LABST+0(10).
  L_SUM_PUR = ITAB_SPT-SUM_PUR.
  L_SUM_PUR = L_SUM_PUR+0(10).
  L_SUM_RET = ITAB_SPT-SUM_RET.
  L_SUM_RET = L_SUM_RET+0(10).
  L_SUM_GR = ITAB_SPT-SUM_GR.
  L_SUM_GR = L_SUM_GR+0(10).
  L_SUM_GI = ITAB_SPT-SUM_GI.
  L_SUM_GI = L_SUM_GI+0(10).

  WRITE:/(1) SY-VLINE, (4) SY-TABIX LEFT-JUSTIFIED,
         (1) SY-VLINE, (10) ITAB_SPT-MATNR,
         (1) SY-VLINE, (40) ITAB_SPT-MAKTX,
         (1) SY-VLINE, (10) L_LABST,
         (1) SY-VLINE, (10) L_SUM_PUR,
         (1) SY-VLINE, (10) L_SUM_RET,
         (1) SY-VLINE, (10) L_SUM_GR,
         (1) SY-VLINE, (10) L_SUM_GI,
         (1) SY-VLINE, ITAB_SPT-VERPR,
         (1) SY-VLINE, ITAB_SPT-VERPRTTL,
         (1) SY-VLINE.
  hide ITAB_SPT-MATNR.
  WRITE /(165) SY-ULINE.
ENDFORM.                    " FRM_WRT_DATA


*&---------------------------------------------------------------------*
*&      Form  FRM_DATA_OUTPUT
*&---------------------------------------------------------------------*
*       数据输出
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_DATA_OUTPUT.
  DATA L_COUNT LIKE SY-TABIX.
  DATA: L_COUNT2 TYPE I.
*      L_COUNT3 TYPE I.

* 表头
  PERFORM FRM_WRT_HEAD.
* 数据标题
  PERFORM FRM_WRT_TIT.

  L_COUNT = 0.
*  L_COUNT2 = 1.
*  L_COUNT3 = 1.
  SORT ITAB_SPT BY MATNR.
  LOOP AT ITAB_SPT.
    L_COUNT = L_COUNT + 1.
    IF L_COUNT = CNS_PAGE_LINES.
      NEW-PAGE.
      L_COUNT = 1.
      "数据标题
      PERFORM FRM_WRT_TIT.
    ENDIF.

*    "确定文本颜色
*    IF L_COUNT2 = L_COUNT3.
*      FORMAT COLOR COL_NORMAL.
*      L_COUNT2 = L_COUNT2 + 1.
*    ELSE.
*      FORMAT COLOR COL_KEY.
*      L_COUNT3 = L_COUNT2.
*    ENDIF.

    "主数据
    PERFORM FRM_WRT_DATA.

    L_COUNT = L_COUNT + 1.
    IF L_COUNT = CNS_PAGE_LINES.
      "数据尾
      PERFORM FRM_WRT_FOOT.
    ENDIF.
    L_COUNT = L_COUNT - 1.

    AT LAST.
      "空数据
      L_COUNT2 = CNS_PAGE_LINES - L_COUNT - 1.
      DO L_COUNT2 TIMES.
        PERFORM FRM_WRT_NULL.
      ENDDO.
    ENDAT.
  ENDLOOP.

  "数据尾
  L_COUNT = L_COUNT + 1.
  IF L_COUNT <> CNS_PAGE_LINES.
    PERFORM FRM_WRT_FOOT.
  ENDIF.
ENDFORM.                    " FRM_DATA_OUTPUT


*&---------------------------------------------------------------------*
*&      Form  FRM_CHK_MTYPE
*&---------------------------------------------------------------------*
*       删除物料类型不符的数据
*----------------------------------------------------------------------*
*      -->P_ITAB_SPT  text
*----------------------------------------------------------------------*
FORM FRM_CHK_MTYPE TABLES   P_ITAB_SPT STRUCTURE ITAB_SPT.

* 去掉重复的数据条目.然后把数据插入一个前面定义的
* 临时的ITAB_SPT_TMP(和ITAB_SPT的结构类型一样的.)

  SELECT DISTINCT MATNR
    INTO CORRESPONDING FIELDS OF TABLE ITAB_SPT_TMP
    FROM MARA
     FOR ALL ENTRIES IN P_ITAB_SPT
   WHERE MATNR = P_ITAB_SPT-MATNR
     AND MTART = CNS_MATERIAL_TYPE.

* 然后把数据从临时表插入到P_ITAB_SPT
  MOVE ITAB_SPT_TMP[] TO P_ITAB_SPT[].

* 系统返回的时候,会自己把P_ITAB_SPT的数据放入
* ITAB_SPT.
* 属于引用参数.会改变ITAB-SPT的直.

ENDFORM.                    " FRM_CHK_MTYPE

*&---------------------------------------------------------------------*
*&      Form  FRM_WRT_NULL
*&---------------------------------------------------------------------*
*       空数据
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_WRT_NULL.
  WRITE:/(1) SY-VLINE, (4) ' ',
         (1) SY-VLINE, (10) ' ',
         (1) SY-VLINE, (40) ' ',
         (1) SY-VLINE, (10) ' ',
         (1) SY-VLINE, (10) ' ',
         (1) SY-VLINE, (10) ' ',
         (1) SY-VLINE, (10) ' ',
         (1) SY-VLINE, (10) ' ',
         (1) SY-VLINE, (15) ' ',
         (1) SY-VLINE, (15) ' ',
         (1) SY-VLINE.
  WRITE /(165) SY-ULINE.

ENDFORM.                    " FRM_WRT_NULL

本文地址:http://com.8s8s.com/it/it35384.htm