精华内容
下载资源
问答
  • YHLMR009 交货单查询
    2019-09-22 09:51:18
    ***********************************************************************
    * Title           : YHLMR009                                          *
    * Application     : LM                                               *
    * Subject         : 交货清单查询                                      *
    * Requested by    : Yang_Teng Fei (YH_LM)                             *
    * Execution       : Online when required                              *
    * Ref no:         : ERPS0115                                          *
    * Author          : AD_CAIXIANG                                       *
    * Req Date        : 20120722                                          *
    ***********************************************************************
    *              交货清单查询程序                                   *
    ***********************************************************************
    *              设计主要逻辑与原理说明                             *
    ***********************************************************************
    *1.取数:根据用户的输入单据编号、交货单类型、计划发货日期、实际发货日期*
    * 配入机构、商品编码等输入条件单一或者组合进行交货订单的查询。        *
    * 涉及到的表  LIKP T001W KNA1 LIPS MARA MAKT MBEW MEAN LIPSD ZMADQ    *
    *2.输出: 进行alv输出交货清单信息                                      *
    ***********************************************************************
    * MODIFICATIONS (latest entry at the top)                             *
    * ------------------------------------------------------------------- *
    * REL  DATE    NAME (COMPANY)   DESCRIPTION               TASK-NO     *
    * ---  ----    ---- ---------     -----------             -------     *
    * 01 20121206   LM  交货清单查询修改  by  AD_CAIXIANG      ECDK906448 *
    * 02 20121210   LM  交货清单查询修改  by  AD_CAIXIANG      ECDK906618 *
    * 03 20121210   LN  程序规范化        by  AD_CAIXIANG      ECDK906622 *
    * 04 20130111   LM  加直接显示明细按钮 BY AD_CAIXIANG      ECDK907564 *
    * 05 20130126   LM  交货单类型增添    BY AD_CAIXIANG       ECDK907564 *
    * 06 20130222   LM  价格取数修改    移动类型671,673       ECDK908753.*
    *                                  价格取数改为 EKPO-KZWI1/EKPO-MENGE *
    * 07 20130402   LM  程序优化          BY AD_CAIXIANG       ECDK910228 *
    * 08 20130516   LM  移出库位作为查询条件出现问题的修改                *
    *                                     BY AD_CAIXIANG       ECDK911439 *
    * 09 20130603   LM  价格取数问题调整  BY AD_CAIXIANG       ECDK912048 *
    * 10 20130703   LM  取税率优化        BY AD_CAIXIANG       ECDK912680 *
    * 11 20130726   LM  取数部分优化,                                    *
    *                   当S_WBSTK 为空的时候,把VBUK的取数单独出来,      *
    *                   对于EKPO和EKBE进行分批取数             ECDK913630 *
    ***********************************************************************
    REPORT  YHLMR009 NO STANDARD PAGE HEADING
                          LINE-SIZE 132
                          LINE-COUNT 65(1)
                          MESSAGE-ID YH_LM1.
    
    *----------------------------------------------------------------------
    *                          PUB-INCLDUE
    *----------------------------------------------------------------------
    INCLUDE  <ICON>.
    *INCLUDE YHLM009_TOP.
    
    *----------------------------------------------------------------------
    *                          TYPE-POOLS
    *----------------------------------------------------------------------
    TYPE-POOLS: SLIS.
    
    
    
    *--------------------------------------------------------------------*
    *  宏的调用方式:
    *--------------------------------------------------------------------*
    
    *----------------------------------------------------------------------
    *                          TABLES/Structure
    *----------------------------------------------------------------------
    TABLES: LIKP, "SD凭证:交货抬头数据
            LIPS, "SD凭证 :交货:项目数据
            KNA1, "客户主文件的一般数据
            MBEW, "商品评估
            MEAN, "商品的条码
            LIPSD,"交货项目的动态部分
            VBUK, "销售凭证:抬头状态和管理数据
            VBFA, "销售凭证流
            ADRP, "个人(办公地址管理)
            EKPO. "采购凭证项目
    TABLES: MARA, MARC, MAKT, T001W.
    
    *----------------------------------------------------------------------
    *                          Internal table
    *----------------------------------------------------------------------
    DATA: BEGIN OF GT_ITAB OCCURS 0,
           VBELN LIKE LIKP-VBELN,
           POSNR LIKE LIPS-POSNR,
           LFART LIKE LIKP-LFART,
           WERKS LIKE LIPS-WERKS,
           NAME1 LIKE T001W-NAME1,"配出机构名称
           KUNNR LIKE LIKP-KUNNR,
           NAME2 LIKE KNA1-NAME1,
         YYCARNO LIKE LIKP-YYCARNO,
           TDDAT LIKE LIKP-TDDAT,
           BLDAT LIKE LIKP-BLDAT,
           ANZPK LIKE LIKP-ANZPK,
           RESLO LIKE EKPO-RESLO,
          LGOBE1 LIKE T001L-LGOBE,"移出
           LGORT LIKE LIPS-LGORT,
          LGOBE2 LIKE T001L-LGOBE,"移入
           MENGE TYPE EKPO-MENGE, "订货数量
           LFIMG TYPE LIPS-LFIMG, "实发数量
            SHFA TYPE  P DECIMALS 1, "实发件数
           VGBEL LIKE LIPS-VGBEL,
           VGPOS LIKE LIPS-VGPOS,
           VGTYP LIKE LIPS-VGTYP,
           MATNR LIKE LIPS-MATNR,
           EAN11 LIKE MEAN-EAN11,
       WADAT_IST LIKE LIKP-WADAT_IST,
           MAKTX LIKE MAKT-MAKTX,
           MEINS LIKE LIPS-MEINS,
           VRKME LIKE LIPS-VRKME,
           GROES LIKE MARA-GROES,
         YUMREZ1 LIKE YTMADQ-YUMREZ1,
           BRGEW TYPE LIPS-BRGEW,  "毛重
           NTGEW TYPE LIPS-NTGEW,  "净重
           JINZH TYPE LIPS-NTGEW,  "皮重
           KOSTK TYPE VBUK-KOSTK,  "交货状态
           ERNAM LIKE LIKP-ERNAM,
           VTEXT TYPE TVLKT-VTEXT,
            DINH TYPE P DECIMALS 1,"订货件数
           WBSTK TYPE VBUK-WBSTK,   "状态
      NAME_TEXT  LIKE ADRP-NAME_FIRST,
           LIFEX TYPE LIKP-LIFEX,
           LIFNR TYPE EORD-LIFNR,
           NAME3 TYPE LFA1-NAME1,
    
           JIAGE TYPE EKPO-KZWI5,
           JINE  TYPE EKPO-KZWI5,
    
           KZWI5 TYPE EKPO-KZWI5,
           DMBTR TYPE MSEG-DMBTR,
           ERZET TYPE LIKP-ERZET,
           BWART LIKE LIPS-BWART,
           KBETR TYPE KBETR,
    *&->START ADD BY AD_CAIXIANG ON 20130514.
          YLBID1 LIKE YTLBDY-YLBID2,
          YDLNAM LIKE YTLBCJ-YLBNAME,
    *&-END ADD
           TIMMM(14) TYPE C,
           FLAG(1)  TYPE C,
    
        END OF GT_ITAB.
    
    
    DATA: BEGIN OF GT_DATA OCCURS 0,
          VBELN LIKE LIKP-VBELN,
          LFART LIKE LIKP-LFART,
          VTEXT TYPE TVLKT-VTEXT,
          WERKS LIKE LIPS-WERKS,
          NAME1 LIKE T001W-NAME1,
          KUNNR LIKE LIKP-KUNNR,
          NAME2 LIKE KNA1-NAME1,
          RESLO LIKE EKPO-RESLO,  "移出
         LGOBE1 LIKE T001L-LGOBE,
          LGORT LIKE EKPO-LGORT, "移入
         LGOBE2 LIKE T001L-LGOBE,
        YYCARNO LIKE LIKP-YYCARNO,
          TDDAT LIKE LIKP-TDDAT,
          BLDAT LIKE LIKP-BLDAT,
      WADAT_IST LIKE LIKP-WADAT_IST,
          MENGE TYPE EKPO-MENGE,   "订货数量
          LFIMG TYPE LIPS-LFIMG,   "实发数量
          JINZH TYPE LIPS-NTGEW,   "皮重
          ERNAM LIKE LIKP-ERNAM,
     NAME_TEXT  LIKE ADRP-NAME_FIRST,
          KOSTK TYPE VBUK-KOSTK,    "交货状态
          WBSTK TYPE VBUK-WBSTK,     "状态
          LIFEX TYPE LIKP-LIFEX,
    *&START CHANGED BY AD_CAIXIANG ON 20121210 ECDK906622
    *      LIFNR TYPE EORD-LIFNR,
    *      NAME3 TYPE LFA1-NAME1,
    *&END CHANGED BY AD_CAIXIANG ON 20121210.
          ERZET TYPE LIPS-ERZET,
          JINE  TYPE EKPO-KZWI5,
    *      LNN   TYPE SY-TABIX,
    
         END OF GT_DATA.
    *----------------------------------------------------------------------
    *                          Variants
    *----------------------------------------------------------------------
    DATA: G_LEN   TYPE I.
    DATA: WA LIKE GT_ITAB.
    DATA: G_LIN TYPE I.
    DATA: G_TABIX LIKE SY-TABIX.
    RANGES:R_LFART FOR LIKP-LFART.
    
    *---------------------------------------------------------------------*
    *  Data parameters for alv report use
    *---------------------------------------------------------------------*
    DATA: G_PROGRAM    TYPE SY-REPID,
          GS_LAYOUT    TYPE SLIS_LAYOUT_ALV,
          GT_FIELDCAT  TYPE SLIS_T_FIELDCAT_ALV,
          GS_FIELDCAT  LIKE LINE OF GT_FIELDCAT,
          GT_FIELDCAT2 TYPE SLIS_T_FIELDCAT_ALV,
          GS_FIELDCAT2 LIKE LINE OF GT_FIELDCAT,
          WA_FIELDCAT  TYPE SLIS_FIELDCAT_ALV,
          IT_EVENTS    TYPE SLIS_T_EVENT WITH HEADER LINE,
          GT_EVENT     TYPE SLIS_T_EVENT,
          WA_EVENT     TYPE SLIS_ALV_EVENT.
    DATA: GT_LIST_TOP_OF_PAGE     TYPE SLIS_T_LISTHEADER.
    DATA: GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME
                                  VALUE 'ALV_TOP_OF_PAGE'.
    DATA: G_GRID       TYPE REF TO CL_GUI_ALV_GRID.
    
    *--------------------------------------------------------------------*
    *  D宏的定义
    *--------------------------------------------------------------------*
    DEFINE MAR_ADD_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-FIELDNAME    =  &1.
      WA_FIELDCAT-SELTEXT_L    =  &2.
      WA_FIELDCAT-COL_POS      =  &3.
      WA_FIELDCAT-JUST         =  &4.
      WA_FIELDCAT-OUTPUTLEN    =  &5.
      WA_FIELDCAT-FIX_COLUMN   =  &6.
      WA_FIELDCAT-EDIT         =  &7.
      WA_FIELDCAT-NO_ZERO      =  &8.
      APPEND WA_FIELDCAT TO GT_FIELDCAT.
    END-OF-DEFINITION.
    
    
    *--------------------------------------------------------------------*
    *  D宏的定义2
    *--------------------------------------------------------------------*
    DEFINE MAR_ADD_FIELDCAT2.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-FIELDNAME    =  &1.
      WA_FIELDCAT-SELTEXT_L    =  &2.
      WA_FIELDCAT-COL_POS      =  &3.
      WA_FIELDCAT-JUST         =  &4.
      WA_FIELDCAT-OUTPUTLEN    =  &5.
      WA_FIELDCAT-FIX_COLUMN   =  &6.
      WA_FIELDCAT-EDIT         =  &7.
      WA_FIELDCAT-NO_ZERO      =  &8.
      APPEND WA_FIELDCAT TO GT_FIELDCAT2.
    END-OF-DEFINITION.
    
    
    
    
    *======================================================================
    *                          SELECTION-SCREEN
    *======================================================================
    SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
    
    PARAMETERS:     P_WERKS LIKE MARC-WERKS MEMORY ID WRK OBLIGATORY.
    SELECT-OPTIONS: S_VBELN FOR LIKP-VBELN,
                    S_LFART FOR LIKP-LFART.           "交货类型
    
    "S_TDDAT FOR LIKP-TDDAT OBLIGATORY, "运输计划日期
    "s_ERZET FOR LIKP-ERZET default '000000' to sy-uzeit no-extension OBLIGATORY,
    
    PARAMETERS:     P_BLDATL LIKE LIKP-BLDAT DEFAULT SY-DATUM  OBLIGATORY,
                    P_ERZETL LIKE LIKP-ERZET DEFAULT '000000',
                    P_BLDATH LIKE LIKP-BLDAT DEFAULT SY-DATUM  OBLIGATORY,
                    P_ERZETH LIKE LIKP-ERZET DEFAULT SY-UZEIT.
    
    SELECT-OPTIONS: "S_BLDAT FOR LIKP-BLDAT OBLIGATORY,"凭证日期
                    S_WADAT FOR LIKP-WADAT_IST,        "实际发货日期
                    S_WBSTK FOR VBUK-WBSTK,
                    S_KUNNR FOR LIKP-KUNNR,
                    S_MATNR FOR LIPS-MATNR ,
                    S_VGBEL FOR LIPS-VGBEL,
                    S_YYCAR FOR LIKP-YYCARNO MATCHCODE OBJECT YH_YTCARNUM,
                    S_RESLO FOR EKPO-RESLO,   "移出库位
                    S_LGORT FOR EKPO-LGORT,   "移入库位
                    S_ERNAM FOR LIKP-ERNAM MATCHCODE OBJECT USER_COMP.
    
    SELECTION-SCREEN SKIP.
    
    PARAMETERS: P_DETAIL TYPE C AS CHECKBOX DEFAULT ''.
    
    SELECTION-SCREEN END OF BLOCK BLK1.
    
    *----------------------------------------------------------------------
    *  INITIALIZATION
    *----------------------------------------------------------------------
    INITIALIZATION.
    
    * 初始化数据
      PERFORM FRM_INITIAL.
    
    *----------------------------------------------------------------------
    *  AT SELECTION-SCREEN
    *----------------------------------------------------------------------
    AT SELECTION-SCREEN.
    * 权限检查部分
      PERFORM FRM_CHECK_AUTHOR.
    
    *======================================================================
    *                          MAIN PROGRAM
    *======================================================================
    *  START-OF-SELECTION
    *----------------------------------------------------------------------
    START-OF-SELECTION.
    
    *&S1: 取得数据:
      PERFORM FRM_GET_DATA.
    
    *BREAK AD_CAIXIANG.
    *&--->START ADD BY AD_CAIXIANG ON 20130111 ECDK907564.
      IF P_DETAIL IS NOT INITIAL.
    
        PERFORM FRM_DETAIL_DISP .
    
      ELSE.
    *----------------------------------------------------------------------
    *  END-OF-SELECTION
    *----------------------------------------------------------------------
    *&S3:  输出数据:
        PERFORM FRM_ALV_OUTPUT.
    
      ENDIF.
    
    *&---<END ADD BY AD_CAIXIANG ON 20130111.
    
    *&---------------------------------------------------------------------*
    *&      Form  FRM_INITIAL
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_INITIAL.
    
    *&设定日期默认:
    *  IF S_TDDAT[] IS INITIAL.
    *    S_TDDAT-LOW  = SY-DATUM.
    *    S_TDDAT-HIGH = SY-DATUM + 5.
    *    APPEND S_TDDAT.
    *  ENDIF.
    *  IF S_BLDAT[] IS INITIAL.
    *    S_BLDAT-LOW  = SY-DATUM - 5.
    *    S_BLDAT-HIGH = SY-DATUM.
    *    APPEND S_BLDAT.
    *  ENDIF.
    
    ENDFORM.                    " FRM_INITIAL
    
    *&---------------------------------------------------------------------*
    *&      Form  FRM_CHECK_AUTHOR
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_CHECK_AUTHOR.
    
    *  IF S_BLDAT-LOW IS INITIAL OR S_BLDAT-HIGH IS INITIAL.
    *    MESSAGE I011 WITH '凭证日期应上限都输入!'.
    *    STOP.
    *  ENDIF.
    * IF s_ERZET-LOW IS NOT INITIAL AND S_ERZET-HIGH IS INITIAL.
    *   MESSAGE I011 WITH '时间应上下限都输入!'.
    *   STOP.
    *  ELSE.
    * IF s_ERZET-LOW IS INITIAL AND s_ERZET-HIGH IS NOT INITIAL.
    *   MESSAGE I011 WITH '时间应上下限都输入!'.
    *   STOP.
    * endif.
    * ENDIF.
    * IF s_ERZET-LOW IS INITIAL OR S_ERZET-HIGH IS INITIAL.
    *   MESSAGE I011 WITH '时间应上下限都输入!'.
    *   STOP.
    * ENDIF.
    
    *&权限检查:
      AUTHORITY-CHECK OBJECT  'V_LIKP_VST'
        ID  'VSTEL' FIELD P_WERKS
        ID  'ACTVT' FIELD '03'.
      IF SY-SUBRC NE 0.
        MESSAGE I002 WITH  P_WERKS .
        STOP.
      ENDIF.
    
    ENDFORM.                    " FRM_CHECK_AUTHOR
    
    
    *&---------------------------------------------------------------------*
    *&      Form  frm_get_data
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_GET_DATA .
      DATA: L_BZIRK LIKE T001W-BZIRK,
            L_NAME_FIRST LIKE ADRP-NAME_FIRST,
            L_WERKS LIKE T001W-WERKS,
            L_NAME_LAST  LIKE ADRP-NAME_LAST,
            L_NAME_TEXT  LIKE ADRP-NAME_FIRST.
      DATA: LT_ITAB LIKE GT_ITAB OCCURS 0 WITH HEADER LINE,
            LT_WTAB LIKE GT_ITAB OCCURS 0 WITH HEADER LINE.
    
      DATA: BEGIN OF LT_MADQ OCCURS 0,
            MATNR LIKE MARA-MATNR,
            WERKS LIKE MARC-WERKS,
            YUMREZ1 LIKE YTMADQ-YUMREZ1,
            END OF LT_MADQ.
      DATA: BEGIN OF LT_MEAN OCCURS 0,
             MATNR LIKE MARA-MATNR,
             EAN11 LIKE MEAN-EAN11,
            END OF LT_MEAN.
    *  DATA: BEGIN OF LT_MARA OCCURS 0,
    *        MATNR LIKE MARA-MATNR,
    *        GROES LIKE MARA-GROES,
    *        MATKL LIKE MARA-MATKL,
    *       END OF LT_MARA.
      DATA: BEGIN OF LT_T001W OCCURS 0,
             WERKS LIKE T001W-WERKS,
             NAME1 LIKE T001W-NAME1,
             KUNNR LIKE T001W-KUNNR,
            END OF LT_T001W.
    
      DATA: BEGIN OF  LT_T001L OCCURS 0,
             WERKS LIKE MARD-WERKS,
             LGORT LIKE MARD-LGORT,
             LGOBE LIKE T001L-LGOBE,
           END OF LT_T001L.
      DATA: BEGIN OF LT_TVLKT OCCURS 0,
            LFART LIKE TVLKT-LFART,
            VTEXT LIKE TVLKT-VTEXT,
           END OF LT_TVLKT .
    
      DATA: BEGIN OF LT_TAB OCCURS 0,
            VBELN LIKE LIKP-VBELN,
            LFART LIKE LIKP-LFART,
            VTEXT TYPE TVLKT-VTEXT,
            WERKS LIKE LIPS-WERKS,
            JINE  TYPE EKPO-KZWI5,
           END OF LT_TAB.
    
      DATA: G_TEXT TYPE KBETR,
            C_TEXT(8) TYPE N.
      DATA: G_MWSKZ LIKE EKPO-MWSKZ,
            G_KZWI5 LIKE EKPO-KZWI5,
            G_KZWI1 LIKE VBRP-KZWI1,
            G_MENGE LIKE EKPO-MENGE,
            G_DMBTR LIKE MSEG-DMBTR,
            G_FKIMG LIKE VBRP-FKIMG.
      DATA: L_MENGE TYPE EKPO-MENGE,   "订货数量
            L_LFIMG TYPE LIPS-LFIMG,   "实发数量
            L_JINZH TYPE LIPS-NTGEW.   "皮重
      DATA: L_TIMEL(14) TYPE C,
            L_TIMEH(14) TYPE C.
    
      DATA:BEGIN OF LT_EORD OCCURS 0,
            WERKS LIKE EORD-WERKS,
            MATNR LIKE EORD-MATNR,
            LIFNR LIKE EORD-LIFNR,
           END OF LT_EORD.
    
    *  DATA: BEGIN OF LT_MARA2 OCCURS 0,
    *        MATNR LIKE MARA-MATNR,
    *        SATNR LIKE MARA-MATNR,
    *      END OF LT_MARA2.
      DATA:BEGIN OF LT_LFA1 OCCURS 0,
             LIFNR LIKE LFA1-LIFNR,
             NAME1 LIKE LFA1-NAME1,
            END OF LT_LFA1.
      DATA: BEGIN OF LT_KNA1 OCCURS 0,
             KUNNR LIKE KNA1-KUNNR,
             NAME1 LIKE KNA1-NAME1,
            END OF LT_KNA1.
      DATA: BEGIN OF LT_NAME OCCURS 0,
          BNAME     LIKE V_USR_NAME-BNAME,
          NAME_TEXT LIKE V_USR_NAME-NAME_TEXT,
            END OF LT_NAME .
    
      DATA:BEGIN OF LT_EKPO OCCURS 0,
             EBELN LIKE EKPO-EBELN,
             EBELP LIKE EKPO-EBELP,
             TXZ01 LIKE EKPO-TXZ01,
             LGORT LIKE EKPO-LGORT,
             RESLO LIKE EKPO-RESLO,
             MWSKZ LIKE EKPO-MWSKZ,
             MENGE LIKE EKPO-MENGE,
             KZWI1 LIKE EKPO-KZWI1,
             KZWI5 LIKE EKPO-KZWI5,
        END OF LT_EKPO.
      DATA:BEGIN OF LT_EKKO OCCURS 0 ,
              EBELN LIKE EKPO-EBELN,
              EBELP LIKE EKPO-EBELP,
              VBELN LIKE LIPS-VBELN,
         END OF LT_EKKO.
      DATA: LT_WEKO LIKE TABLE OF LT_EKKO WITH HEADER LINE.
    
      DATA:BEGIN OF LT_EKBE OCCURS 0,
            EBELN LIKE EKBE-EBELN,
            EBELP LIKE EKBE-EBELP,
            VBELN LIKE LIKP-VBELN,
            DMBTR LIKE EKBE-DMBTR,
          END OF LT_EKBE.
      DATA: BEGIN OF LT_VBFA OCCURS 0,
             VBELV LIKE VBFA-VBELV,
             POSNV LIKE VBFA-POSNV,
             VBELN LIKE VBFA-VBELN,
             POSNN LIKE VBFA-POSNN,
            END OF LT_VBFA.
      DATA: LT_TAB1 LIKE TABLE OF LT_VBFA WITH HEADER LINE.
    
      DATA: BEGIN OF LT_VBRP OCCURS 0,
             VBELN LIKE VBRP-VBELN,
             POSNR LIKE VBRP-POSNR,
             KZWI1 LIKE VBRP-KZWI1,
             FKIMG LIKE VBRP-FKIMG,
            END OF LT_VBRP.
      DATA: BEGIN OF LT_VBAP OCCURS 0,
             VBELN LIKE VBAP-VBELN,
             POSNR LIKE VBAP-POSNR,
            KWMENG LIKE VBAP-KWMENG,
             ARKTX LIKE VBAP-ARKTX,
            END OF LT_VBAP.
      DATA: LT_WVBAP LIKE TABLE OF LT_VBAP WITH HEADER LINE.
    
      DATA: BEGIN OF LT_VBUK OCCURS 0,
             VBELN LIKE VBUK-VBELN,
             KOSTK LIKE VBUK-KOSTK,
             WBSTK LIKE VBUK-WBSTK,
            END OF LT_VBUK.
      DATA: BEGIN OF LT_YTLBCJ OCCURS 0,
             YLBID LIKE YTLBCJ-YLBID,
           YLBNAME LIKE YTLBCJ-YLBNAME,
            END OF LT_YTLBCJ.
      DATA: BEGIN OF LT_MARA3 OCCURS 0,
             MATNR LIKE MARA-MATNR,
             ATTYP LIKE MARA-ATTYP,
             SATNR LIKE MARA-SATNR,
             GROES LIKE MARA-GROES,
             MATKL LIKE MARA-MATKL,
             LVORM LIKE MARA-LVORM,
            END OF LT_MARA3.
      DATA: BEGIN OF LT_A003 OCCURS 0,
               MWSKZ LIKE A003-MWSKZ,
               KBETR LIKE KONP-KBETR,
             END OF LT_A003.
      DATA: LT_MARA LIKE TABLE OF LT_MARA3 WITH HEADER LINE,
            LT_MARA2 LIKE TABLE OF LT_MARA3 WITH HEADER LINE.
      RANGES:R_LFARTN FOR LIKP-LFART.
      DATA: L_TIAN(5) TYPE N.
      DATA: L_COUNT TYPE I.
      DATA: L_LAST TYPE C.
      DATA: L_NMAX TYPE I.
    
      SELECT SINGLE TBMAXSEL INTO L_NMAX FROM YTMMREPNUM
        WHERE PROGNAME = SY-REPID AND ACTIVE = 'X'.
      IF SY-SUBRC NE 0.
        L_NMAX = 150000.
      ENDIF.
    
    *&->START CHANGE BY AD_CX ON 20130708 ECDK912680
      L_TIAN = P_BLDATH - P_BLDATL.
      IF L_TIAN GT 37.
        MESSAGE S011 WITH '时间范围查询条件输入过大!请将时间段分开查询,谢谢!' DISPLAY LIKE 'E'.
        STOP.
      ENDIF.
    *&->END CHANGE.
    
    *&S1.默认交货单移动类型:
      PERFORM FRM_LFART.
    
    *&->START CHANGE BY AD_CX ON 20130725 ECDK913587.
    *&S1.1先取出单据类型:
      SELECT LFART VTEXT
        INTO TABLE LT_TVLKT
        FROM TVLKT
       WHERE SPRAS EQ SY-LANGU
         AND LFART IN S_LFART
         AND LFART IN R_LFART.
      SORT LT_TVLKT BY LFART.
    
    *&S1.2形成单据最终RANGE.
      LOOP AT LT_TVLKT.
        R_LFARTN(3) = 'IEQ'.
        R_LFARTN-LOW = LT_TVLKT-LFART.
        APPEND R_LFARTN.
      ENDLOOP.
    
      IF S_WBSTK[] IS NOT INITIAL .
    
    *&S2.1:数据表LIPS LIKP VBUK关联取数
        SELECT A~VBELN
               A~ANZPK
               A~ERNAM    "创建对象人员的名称
               A~KUNNR    "配入机构
               A~LFART    "交货单类型(加描述)
               A~TDDAT    "计划发货日期
               A~BLDAT    "凭证日期
               A~WADAT_IST"实际发货日期
               A~YYCARNO
               A~LIFEX    "融通单号
               A~ERZET
    
               B~BWART
               B~POSNR   "序号
               B~WERKS   "配出机构
               B~VGBEL   "参考凭证号
               B~VGPOS   "参考凭证项目
               B~VGTYP
               B~MATNR   "商品编码
               B~MEINS   "单位
               B~VRKME
               B~LFIMG   "实发数量
               B~BRGEW   "毛重
               B~NTGEW   "净重
               B~LGORT
    
               C~KOSTK
               C~WBSTK
          INTO CORRESPONDING FIELDS OF TABLE  GT_ITAB
          FROM LIKP AS A
          JOIN VBUK AS C
            ON ( A~VBELN EQ C~VBELN )
          JOIN LIPS AS B
            ON ( A~VBELN EQ B~VBELN )
          UP TO L_NMAX ROWS
    *&start changed by robin 20130514  ECDK910228
    *&性能优化:
         WHERE A~BLDAT >= P_BLDATL
           AND A~BLDAT <= P_BLDATH
           AND A~LFART IN R_LFARTN
           AND B~WERKS EQ P_WERKS
           AND C~WBSTK IN S_WBSTK
           AND A~VBELN IN S_VBELN
           AND A~KUNNR IN S_KUNNR
           AND A~YYCARNO IN S_YYCAR
           AND A~WADAT_IST IN S_WADAT
           AND A~ERNAM IN S_ERNAM
         "AND B~WERKS EQ P_WERKS
           AND B~MATNR IN S_MATNR
           AND B~VGBEL IN S_VGBEL
    *&->START ADD
           AND B~LGORT IN S_LGORT.
    *&->END ADD.
    
    
    **&end changed by robin 20130514.
    
      ELSE.
    
    *&S2.2:数据表LIPS LIKP 关联取数,将VBUK取数移出
    *&->START CHANGE BY AD_CX ON 20130725 ECDK913587.
        SELECT A~VBELN
               A~ANZPK
               A~ERNAM    "创建对象人员的名称
               A~KUNNR    "配入机构
               A~LFART    "交货单类型(加描述)
               A~TDDAT    "计划发货日期
               A~BLDAT    "凭证日期
               A~WADAT_IST"实际发货日期
               A~YYCARNO
               A~LIFEX    "融通单号
               A~ERZET
    
               B~BWART
               B~POSNR   "序号
               B~WERKS   "配出机构
               B~VGBEL   "参考凭证号
               B~VGPOS   "参考凭证项目
               B~VGTYP
               B~MATNR   "商品编码
               B~MEINS   "单位
               B~VRKME
               B~LFIMG   "实发数量
               B~BRGEW   "毛重
               B~NTGEW   "净重
               B~LGORT
    *         C~KOSTK
    *         C~WBSTK
          INTO CORRESPONDING FIELDS OF TABLE  GT_ITAB
          FROM LIKP AS A
    *  JOIN VBUK AS C
    *    ON ( A~VBELN EQ C~VBELN )
          JOIN LIPS AS B
            ON ( A~VBELN EQ B~VBELN )
          UP TO L_NMAX ROWS
    *&start changed by robin 20130514  ECDK910228
    *&性能优化:
         WHERE A~BLDAT >= P_BLDATL
           AND A~BLDAT <= P_BLDATH
           AND A~LFART IN R_LFARTN
           AND B~WERKS EQ P_WERKS
           AND A~VBELN IN S_VBELN
           AND A~KUNNR IN S_KUNNR
           AND A~YYCARNO IN S_YYCAR
           AND A~WADAT_IST IN S_WADAT
           AND A~ERNAM IN S_ERNAM
           AND B~MATNR IN S_MATNR
           AND B~VGBEL IN S_VGBEL
    *&->START ADD
           AND B~LGORT IN S_LGORT.
    *&->END ADD.
    
    *   AND C~WBSTK IN S_WBSTK.
    *&->END CHANGE BY AD_CX.
    
      ENDIF.
    
    *&S2.3.内表排序
      SORT GT_ITAB BY VBELN POSNR.
    
    
    *&S4.1当数量极大时提示:
    *  IF G_LEN GT 80000.
    *    MESSAGE E011 WITH '你查询的数据太多,请重新选择条件!'.
    *    STOP.
    *  ENDIF.
    
    *&S3.日期加时间点作为时间段查询数据
    *&->START ADD BY AD_CAIXIANG ON 20121128.  增加按详细时间筛选数据逻辑:
    *&判断时间范围内的数据
      LOOP AT GT_ITAB .
        CONCATENATE GT_ITAB-BLDAT GT_ITAB-ERZET INTO GT_ITAB-TIMMM.
    
        CONCATENATE P_BLDATL P_ERZETL INTO L_TIMEL.
        CONCATENATE P_BLDATH P_ERZETH INTO L_TIMEH.
    
        IF GT_ITAB-TIMMM > L_TIMEH OR GT_ITAB-TIMMM < L_TIMEL.
          GT_ITAB-FLAG = 'X'.
          DELETE GT_ITAB.
          CONTINUE.
        ENDIF.
    
        CHECK GT_ITAB-VGBEL IS NOT INITIAL.
        IF GT_ITAB-VGTYP = 'V'.
    *&S3.1 形成采购订单数据中间表
          LT_EKKO-EBELN = GT_ITAB-VGBEL.
          LT_EKKO-EBELP = GT_ITAB-VGPOS.
          LT_EKKO-VBELN = GT_ITAB-VBELN.
          COLLECT LT_EKKO.
          CLEAR LT_EKKO.
        ELSE."销售凭证
          LT_WVBAP-VBELN = GT_ITAB-VGBEL.
          LT_WVBAP-POSNR = GT_ITAB-VGPOS.
          COLLECT LT_WVBAP.
        ENDIF.
    
    *    MODIFY GT_ITAB TRANSPORTING FLAG.
      ENDLOOP.
    
    *&S3.2 删除不满足条件的数据
      DELETE GT_ITAB WHERE FLAG EQ 'X'.
    *& END ADD BY AD_CAIXIANG ON 20121128.
    
    *&->START ADD BY AD_CX ON 20130727.
      IF LINES( GT_ITAB ) = L_NMAX.
        MESSAGE I014(YH_FI1) WITH '条目的最大数值限制为' L_NMAX ',' '请分批查询!'.
        STOP.
      ENDIF.
    *&->END ADD.
    
    *&S4.检查是否取到数据:
      DESCRIBE TABLE GT_ITAB LINES G_LEN.
      IF G_LEN EQ 0.
        MESSAGE I011 WITH '没有查询到符合条件的数据!'.
        STOP.
      ENDIF.
    
    *&S5.VBUK表取数:
    *& 考虑用中间表:
      LT_WTAB[] = GT_ITAB[].
    * SORT LT_WTAB BY VBELN.
      DELETE ADJACENT DUPLICATES FROM LT_WTAB  COMPARING VBELN.
    
      IF S_WBSTK[] IS INITIAL .
        LOOP AT LT_WTAB.
          CLEAR L_LAST.
          AT LAST.
            L_LAST = 'X'.
          ENDAT.
    
          APPEND LT_WTAB TO LT_ITAB.
          ADD 1 TO L_COUNT.
    
          IF L_COUNT = 5000 OR L_LAST = 'X'.
            SELECT VBELN KOSTK WBSTK
            APPENDING TABLE LT_VBUK
              FROM VBUK
               FOR ALL ENTRIES IN LT_ITAB
             WHERE VBELN EQ LT_ITAB-VBELN.
    
            REFRESH LT_ITAB.
            CLEAR L_COUNT.
          ENDIF.
        ENDLOOP.
        SORT LT_VBUK BY VBELN.
      ENDIF.
      FREE LT_WTAB.
    
    *&S6.EKPO取数:
      IF LT_EKKO[] IS NOT INITIAL.
        LOOP AT LT_EKKO.
          CLEAR L_LAST.
          AT LAST.
            L_LAST = 'X'.
          ENDAT.
    
          APPEND LT_EKKO TO LT_WEKO.
    
          ADD 1 TO L_COUNT.
          IF L_COUNT = 5000 OR L_LAST = 'X'.
    *&S6.1.通过凭证号关联到EKPO取数
            SELECT EBELN EBELP
                   TXZ01 LGORT
                   RESLO MWSKZ
                   MENGE KZWI1
                   KZWI5
            APPENDING TABLE LT_EKPO
              FROM EKPO
               FOR ALL ENTRIES IN LT_WEKO
             WHERE EBELN = LT_WEKO-EBELN
               AND EBELP = LT_WEKO-EBELP
               AND LOEKZ EQ SPACE.
    
    *&S7.采购凭证历史表取数:
            SELECT EBELN EBELP
                   VBELN_ST AS VBELN
                   DMBTR
              APPENDING TABLE LT_EKBE
              FROM EKBE
               FOR ALL ENTRIES IN LT_WEKO
             WHERE EBELN EQ LT_WEKO-EBELN
               AND EBELP EQ LT_WEKO-EBELP
               AND VGABE EQ '6'
               AND VBELN_ST EQ LT_WEKO-VBELN.
    
            REFRESH LT_WEKO.
            CLEAR L_COUNT.
          ENDIF.
        ENDLOOP.
        SORT LT_EKPO BY EBELN EBELP.
        SORT LT_EKBE BY EBELN EBELP VBELN.
      ENDIF.
      FREE: LT_WEKO,LT_EKKO.
    
    *&—>START 以下备注:
    **&S6.1.通过凭证号关联到EKPO取数
    *    SELECT EBELN EBELP
    *           TXZ01 LGORT
    *           RESLO MWSKZ
    *           MENGE KZWI1
    *           KZWI5
    *
    *      INTO TABLE LT_EKPO
    *      FROM EKPO
    *       FOR ALL ENTRIES IN LT_EKKO
    *     WHERE EBELN = LT_EKKO-EBELN
    *       AND EBELP = LT_EKKO-EBELP
    *       AND LOEKZ EQ SPACE.
    **&->START ADD BY AD_CAIXIANG ON 20130516 ECDK911439
    **    AND RESLO IN S_RESLO
    **    AND LGORT IN S_LGORT.
    **&->EDN ADD 20130516.
    *    SORT LT_EKPO BY EBELN EBELP.
    
    *&S6.2.关联到EKBE取数
    *  *    BREAK AD_CAIXIANG.
    * SELECT SINGLE DMBTR
    *   FROM EKBE
    *   INTO G_DMBTR
    *  WHERE EBELN EQ WA-VGBEL
    *    AND EBELP EQ WA-VGPOS+1(5)
    *    AND BWART EQ WA-BWART.
    * SELECT EBELN EBELP
    *        DMBTR
    *   INTO TABLE LT_EKBE
    *   FROM EKBE
    *    FOR ALL ENTRIES IN LT_EKKO
    *  WHERE EBELN = LT_EKKO-EBELN
    *    AND EBELP = LT_EKKO-EBELP
    *    AND VGABE = '6'.
    *&->START CHANGE BY AD_CAIXIANG ON 20130603
    *    LT_ITAB[] = GT_ITAB[].
    *    SORT LT_ITAB BY VGBEL VGPOS VBELN.
    *    DELETE ADJACENT DUPLICATES FROM LT_ITAB COMPARING VGBEL VGPOS VBELN.
    *&->END 备注
    
    *  IF LT_EKKO[] IS NOT INITIAL.
    **&S7.采购凭证历史表取数:
    *    SELECT EBELN EBELP
    *           VBELN_ST AS VBELN
    *           DMBTR
    *      INTO TABLE LT_EKBE
    *      FROM EKBE
    *       FOR ALL ENTRIES IN LT_EKKO
    *     WHERE EBELN EQ LT_EKKO-EBELN
    *       AND EBELP EQ LT_EKKO-EBELP
    *       AND VGABE EQ '6'
    *       AND VBELN_ST EQ LT_EKKO-VBELN.
    *    SORT LT_EKBE BY EBELN EBELP VBELN.
    ** REFRESH LT_ITAB.
    **&->END CHANGE .
    *  ENDIF.
    
    *&S8通过地点商品编码找对应大区件装数:
      LT_ITAB[] = GT_ITAB[].
      SORT LT_ITAB BY MATNR WERKS.
      DELETE ADJACENT DUPLICATES FROM LT_ITAB COMPARING MATNR WERKS.
    
      SELECT A~MATNR B~WERKS A~YUMREZ1
        INTO TABLE LT_MADQ
        FROM YTMADQ AS A
        JOIN T001W AS B
          ON ( A~BZIRK EQ B~BZIRK )
         FOR ALL ENTRIES IN LT_ITAB
       WHERE A~MATNR EQ LT_ITAB-MATNR
         AND B~WERKS EQ LT_ITAB-WERKS.
      SORT LT_MADQ BY MATNR WERKS.
    
    *&S9通过货源找供应商:
      SELECT WERKS MATNR LIFNR
        INTO TABLE LT_EORD
        FROM YTMEORD
         FOR ALL ENTRIES IN LT_ITAB
       WHERE MATNR EQ  LT_ITAB-MATNR
         AND WERKS EQ  LT_ITAB-WERKS .
      SORT LT_EORD BY MATNR WERKS.
    *  REFRESH LT_ITAB.
    
    *&S10:商品编码找条码:
    *  LT_ITAB[] = GT_ITAB[].
    *  SORT LT_ITAB BY MATNR.
    
      DELETE ADJACENT DUPLICATES FROM LT_ITAB COMPARING MATNR.
      SELECT MATNR EAN11
        INTO TABLE LT_MEAN
        FROM MEAN
         FOR ALL ENTRIES IN LT_ITAB
       WHERE MATNR EQ LT_ITAB-MATNR
         AND HPEAN EQ 'X'.
      SORT LT_MEAN BY MATNR.
    
    *S6.6:商品编码取规格:
    *  SORT LT_ITAB BY MATNR.
    *  DELETE ADJACENT DUPLICATES FROM LT_ITAB COMPARING MATNR.
    *  SELECT MATNR GROES
    **&->START ADD BY AD_CAIXIANG ON 20130514  ECDK911331
    *         MATKL
    **&->END ADD BY AD_CAIXIANG.
    *    INTO TABLE LT_MARA
    *    FROM MARA
    *     FOR ALL ENTRIES IN LT_ITAB
    *   WHERE MATNR EQ LT_ITAB-MATNR
    *     AND LVORM EQ SPACE.
    **&6.7分子母码找对应的商品编码:
    *  SELECT MATNR SATNR
    *    INTO TABLE LT_MARA2
    *    FROM MARA
    *     FOR ALL ENTRIES IN LT_ITAB
    *   WHERE MATNR EQ LT_ITAB-MATNR
    *     AND ATTYP EQ '02'
    *     AND SATNR NE ''.
    
    
    *&S11.MARA表取数
      SELECT MATNR ATTYP SATNR GROES MATKL LVORM
        INTO TABLE LT_MARA3
        FROM MARA
         FOR ALL ENTRIES IN LT_ITAB
       WHERE MATNR EQ LT_ITAB-MATNR.
    
      LT_MARA[] = LT_MARA3[].
      DELETE LT_MARA WHERE LVORM NE SPACE.
      LT_MARA2[] = LT_MARA3[].
      DELETE LT_MARA2 WHERE ATTYP NE '02' OR SATNR EQ ''.
    
      SORT LT_MARA BY MATNR.
      SORT LT_MARA2 BY MATNR.
    
      FREE LT_MARA3.
    *&->START ADD BY AD_CAIXIANG ON 20130514  ECDK911331
    *&S12.取大类名称
      SELECT YLBID YLBNAME
        INTO TABLE LT_YTLBCJ
        FROM YTLBCJ.
    *     FOR ALL ENTRIES IN LT_MARA
    *   WHERE YLBID EQ LT_MARA-MATKL+0(2).
      SORT LT_YTLBCJ BY YLBID.
    
    *&->END ADD BY AD_CAIXIANG.
    
    *&---?
    
      REFRESH LT_ITAB.
    
    *&S13:取机构名称:
    *  LT_ITAB[] = GT_ITAB[].
    *  SORT LT_ITAB BY WERKS.
    *  DELETE ADJACENT DUPLICATES FROM LT_ITAB COMPARING WERKS.
      SELECT WERKS NAME1 KUNNR
        INTO TABLE LT_T001W
        FROM T001W.
    *     FOR ALL ENTRIES IN LT_ITAB
    *   WHERE WERKS EQ LT_ITAB-WERKS.
      SORT LT_T001W BY WERKS.
    
    *&S14.找出库位描述:
      SELECT WERKS LGORT LGOBE
        INTO TABLE LT_T001L
        FROM T001L.
    *     FOR ALL ENTRIES IN LT_ITAB
    *   WHERE WERKS EQ  LT_ITAB-WERKS.
      SORT LT_T001L BY WERKS LGORT.
      REFRESH LT_ITAB.
    
    *&->START CHANGE BY AD_CX ON 20130725 ECDK913587.
    *&S6.10取凭证类型描述:
    *  SELECT LFART VTEXT
    *    INTO TABLE LT_TVLKT
    *    FROM TVLKT
    *   WHERE SPRAS EQ SY-LANGU
    *     AND LFART IN S_LFART
    *     AND LFART IN R_LFART.
    *  SORT LT_TVLKT BY LFART.
    *&->END CHANGE.
    
    *&S15.取供应商名称
    *  LT_ITAB[] = GT_ITAB[].
    *  SORT LT_ITAB BY LIFNR.
    *  DELETE ADJACENT DUPLICATES FROM LT_LFA1 COMPARING LIFNR.
    
      SELECT LIFNR NAME1
        INTO TABLE LT_LFA1
        FROM LFA1
         FOR ALL ENTRIES IN LT_EORD
       WHERE LIFNR EQ LT_EORD-LIFNR.
      SORT LT_LFA1 BY LIFNR.
      REFRESH LT_ITAB.
    
    
    *&S16.取客户名称:
      LT_ITAB[] = GT_ITAB[].
      SORT LT_ITAB BY KUNNR.
      DELETE ADJACENT DUPLICATES FROM LT_ITAB COMPARING KUNNR.
      SELECT KUNNR NAME1
        INTO TABLE LT_KNA1
        FROM KNA1
         FOR ALL ENTRIES IN LT_ITAB
       WHERE KUNNR EQ LT_ITAB-KUNNR.
      SORT LT_KNA1 BY KUNNR.
      REFRESH LT_ITAB.
    
    *&S17.取制单人名称
      LT_ITAB[] = GT_ITAB[].
      SORT LT_ITAB BY ERNAM.
      DELETE ADJACENT DUPLICATES FROM LT_ITAB COMPARING ERNAM.
      SELECT BNAME NAME_TEXT
        INTO TABLE LT_NAME
        FROM V_USR_NAME
         FOR ALL ENTRIES IN LT_ITAB
       WHERE BNAME EQ LT_ITAB-ERNAM.
      SORT LT_NAME BY BNAME.
      REFRESH LT_ITAB.
    
    *& 销售凭证
      IF LT_WVBAP[] IS NOT INITIAL.
        LOOP AT LT_WVBAP.
          CLEAR L_LAST.
          AT LAST.
            L_LAST = 'X'.
          ENDAT.
    
          LT_TAB1-VBELV = LT_WVBAP-VBELN.
          LT_TAB1-POSNV = LT_WVBAP-POSNR.
          APPEND LT_TAB1.
    
          ADD 1 TO L_COUNT.
          IF L_COUNT = 5000 OR L_LAST = 'X'.
    
    *&S19.取销售凭证对应数量
            SELECT VBELN  POSNR
                   KWMENG ARKTX
              APPENDING TABLE LT_VBAP
              FROM VBAP
               FOR ALL ENTRIES IN LT_TAB1
             WHERE VBELN EQ LT_TAB1-VBELV
               AND POSNR EQ LT_TAB1-POSNV.
    
    *&S18.取销售凭证发票
            SELECT VBELV POSNV
                   VBELN POSNN
              APPENDING TABLE LT_VBFA
              FROM VBFA
               FOR ALL ENTRIES IN LT_TAB1
             WHERE VBELV EQ LT_TAB1-VBELV
               AND POSNV EQ LT_TAB1-POSNV
               AND VBTYP_N EQ 'M'.
            IF SY-SUBRC = 0.
              SELECT VBELN POSNR
                     KZWI1 FKIMG
                APPENDING TABLE LT_VBRP
                FROM VBRP
                 FOR ALL ENTRIES IN LT_VBFA
               WHERE VBELN = LT_VBFA-VBELN
                 AND POSNR = LT_VBFA-POSNN.
            ENDIF.
    
            REFRESH LT_TAB1.
            CLEAR L_COUNT.
          ENDIF.
    
        ENDLOOP.
    
        SORT LT_VBFA BY VBELV POSNV.
        SORT LT_VBAP BY VBELN POSNR.
        SORT LT_VBRP BY VBELN POSNR.
      ENDIF.
      FREE: LT_TAB1,LT_WVBAP.
    
    *  LT_ITAB[] = GT_ITAB[].
    *  SORT LT_ITAB BY VGBEL VGPOS.
    *  DELETE ADJACENT DUPLICATES FROM LT_ITAB COMPARING VGBEL VGPOS.
    *  SELECT VBELV POSNV
    *         VBELN POSNN
    *    INTO TABLE LT_VBFA
    *    FROM VBFA
    *     FOR ALL ENTRIES IN LT_ITAB
    *   WHERE VBELV EQ LT_ITAB-VGBEL
    *     AND POSNV EQ LT_ITAB-VGPOS
    *     AND VBTYP_N EQ 'M'.
    *  SORT LT_VBFA BY VBELV POSNV.
    *
    *
    *
    **&S19.取销售凭证对应数量
    *  SELECT VBELN  POSNR
    *         KWMENG ARKTX
    *    INTO TABLE LT_VBAP
    *    FROM VBAP
    *     FOR ALL ENTRIES IN LT_ITAB
    *   WHERE VBELN EQ LT_ITAB-VGBEL
    *     AND POSNR EQ LT_ITAB-VGPOS.
    *  SORT LT_VBAP BY VBELN POSNR.
    *
    *  REFRESH LT_ITAB.
    *
    **&S20.取发票数量与金额
    *  LT_TAB1[] = LT_VBFA[].
    *  SORT LT_TAB1 BY VBELN POSNN.
    *  DELETE ADJACENT DUPLICATES FROM LT_TAB1 COMPARING VBELN POSNN.
    *  IF LT_TAB1[] IS NOT INITIAL.
    *    SELECT VBELN POSNR
    *           KZWI1 FKIMG
    *      INTO TABLE LT_VBRP
    *      FROM VBRP
    *       FOR ALL ENTRIES IN LT_TAB1
    *     WHERE VBELN = LT_TAB1-VBELN
    *       AND POSNR = LT_TAB1-POSNN.
    *    SORT LT_VBRP BY VBELN POSNR.
    *  ENDIF.
    
    
    
    *&S21获取税率
      SELECT A~MWSKZ
             B~KBETR
        INTO TABLE LT_A003
        FROM A003 AS A
        JOIN KONP AS B
          ON A~KNUMH = B~KNUMH AND B~KOPOS = '01'
       WHERE A~KAPPL = 'TX'
         AND A~KSCHL = 'MWVS'
         AND A~ALAND = 'CN'
         AND B~LOEVM_KO = SPACE.
      SORT LT_A003 BY MWSKZ.
    
    *&S22,环取得其他表中取其它值
      LOOP AT GT_ITAB. " INTO WA.
        G_TABIX = SY-TABIX.
    
        MOVE GT_ITAB TO WA.
    
    *&S检查ekpo中的库位:
    *&读取EKPO中金额,税码等数据
        IF  WA-VGBEL NE SPACE AND WA-VGTYP = 'V'.
          READ TABLE LT_EKPO WITH KEY EBELN = WA-VGBEL
                                      EBELP = WA-VGPOS+1(5) BINARY SEARCH.
          IF SY-SUBRC EQ 0.
    *& 取小计金额 和 数量
            G_MWSKZ = LT_EKPO-MWSKZ.
            G_KZWI5 = LT_EKPO-KZWI5.
            G_KZWI1 = LT_EKPO-KZWI1.
            G_MENGE = LT_EKPO-MENGE.
    *&->ADD BY AD_CAIXIANG.
            WA-MENGE = LT_EKPO-MENGE.
    *&->END ADD.
            " WA-LGORT = LT_EKPO-LGORT.
    *      WA-RESLO = LT_EKPO-RESLO.
            WA-RESLO = LT_EKPO-LGORT.
    *&->START CHANGE BY AD_CAIXIANG ON 20130516.
            WA-MAKTX = LT_EKPO-TXZ01.
    *&->END CHANGE BY AD_CAIXIANG.
    *&判断库位:
    *&IF WA-LGORT IN S_LGORT AND
            IF WA-RESLO IN S_RESLO.
    *          WA-MAKTX = LT_EKPO-TXZ01.
    *          WA-LGORT = LT_EKPO-LGORT.
    *          WA-RESLO = LT_EKPO-RESLO.
            ELSE.
              CLEAR WA.
              DELETE GT_ITAB INDEX G_TABIX.
              CONTINUE.
            ENDIF.
    
    *     ENDIF.
    **&->START CHANGE BY AD_CAIXIANG ON 20130513  ECDK911294.
    *      ELSE.
    *        CLEAR WA.
    *        DELETE GT_ITAB INDEX G_TABIX.
    *        CONTINUE.
    
          ENDIF.
    *&->END CHANGE BY AD_CAIXIANG ON 20130513.
    
        ENDIF.
    
    *&--->START CHANGE BY AD_CAIXIANG ON 20130406 ECDK910228
    
        IF S_WBSTK[] IS INITIAL .
          READ TABLE LT_VBUK WITH KEY VBELN = GT_ITAB-VBELN BINARY SEARCH.
          IF SY-SUBRC = 0.
            GT_ITAB-KOSTK = LT_VBUK-KOSTK.
            GT_ITAB-WBSTK = LT_VBUK-WBSTK.
            WA-KOSTK = LT_VBUK-KOSTK.
            WA-WBSTK = LT_VBUK-WBSTK.
          ENDIF.
        ENDIF.
    
    *& 分子母码找对应的商品编码:
    *    SELECT SINGLE SATNR
    *             INTO WA-MATNR
    *             FROM MARA
    *            WHERE ATTYP = '02'
    *              AND SATNR <> ''
    *              AND MATNR = WA-MATNR.
        READ TABLE LT_MARA2 WITH KEY MATNR = WA-MATNR BINARY SEARCH.
        IF SY-SUBRC EQ 0.
          WA-MATNR = LT_MARA2-SATNR.
        ENDIF.
    
    *&读取供应商
        READ TABLE LT_EORD WITH KEY MATNR = WA-MATNR
                                    WERKS = WA-WERKS BINARY SEARCH.
        IF SY-SUBRC EQ 0.
          WA-LIFNR = LT_EORD-LIFNR.
        ENDIF.
    
    *& 取供应商名称:
        READ TABLE LT_LFA1 WITH KEY LIFNR = WA-LIFNR BINARY SEARCH.
        IF SY-SUBRC = 0.
          WA-NAME3 = LT_LFA1-NAME1.
        ENDIF.
    
    
        AT NEW VBELN .
          CLEAR:L_NAME_TEXT.
    *&S1.5.1:获取制单人信息:
          READ TABLE LT_NAME WITH KEY BNAME = WA-ERNAM BINARY SEARCH.
          IF SY-SUBRC EQ 0.
            L_NAME_TEXT = LT_NAME-NAME_TEXT.
          ENDIF.
    
    *&S1.5.2:取客户描述:
          CLEAR KNA1-NAME1.
          READ TABLE LT_KNA1 WITH KEY KUNNR = WA-KUNNR BINARY SEARCH.
          IF SY-SUBRC = 0.
            KNA1-NAME1 = LT_KNA1-NAME1.
          ENDIF.
    
    *&S1.5.3:取出客户对应的工厂:
          CLEAR L_WERKS.
          READ TABLE LT_T001W WITH KEY KUNNR = WA-KUNNR. " BINARY SEARCH.
          IF SY-SUBRC = 0.
            L_WERKS = LT_T001W-WERKS.
          ENDIF.
    
        ENDAT.
    
    
    *&--->END CHANGE BY AD_CAIXIANG ON 20130406.
    
    
    *& 金额:
        WA-JINE = WA-JIAGE *  GT_ITAB-LFIMG.
    
    *&---> START CHANGE BY AD_CAIXIANG ON 20130222  ECDK908753
        IF WA-BWART EQ '641' OR WA-BWART EQ '643'.
    *&当交货单的凭证类型为‘641’ ‘643’时,取交货单凭证里的KZWI5
    *& 当小计5不为0:价格=  小计5/数量
    *&  当小计5为0: 通过交货单凭证中的税码EKPO-MWSKZ,计算税率,然后通
    *&   ( DMBTR * ( 1 + 税率 / 100 ) ) / 数量.计算价格。
    *&---> END CHANGE BY AD_CAIXIANG.
          READ TABLE LT_EKBE WITH KEY EBELN = WA-VGBEL
                                      EBELP = WA-VGPOS+1(5)
                                      VBELN = WA-VBELN BINARY SEARCH.
          IF SY-SUBRC = 0.
            G_DMBTR = LT_EKBE-DMBTR.
    
    *& 当KZWI5不为0:
            IF G_KZWI5 NE 0.
              IF G_MENGE NE 0.
                WA-JIAGE = G_KZWI5 / G_MENGE.
              ELSE.
                WA-JIAGE = 0.
              ENDIF.
    *& 金额:
              WA-JINE = WA-JIAGE *  GT_ITAB-LFIMG.
            ELSE.
    
    *&获取税率
    *&->START CHANGE BY AD_CX ON 20130703 ECDK912680
    
              READ TABLE LT_A003 WITH KEY MWSKZ = G_MWSKZ BINARY SEARCH.
              IF SY-SUBRC = 0.
                G_TEXT = LT_A003-KBETR / 10.
    *&剔除税率小数点后的零
                C_TEXT = TRUNC( G_TEXT ).
                CONCATENATE C_TEXT '%' INTO C_TEXT.
              ENDIF.
    *&->START CHANGE BY AD_CAIXIANG ON 20130603 ECDK912048.
              WA-JINE  = ( G_DMBTR * ( 1 + C_TEXT / 100 ) ) .
              IF G_MENGE NE 0.
    *&->START CHANGE BY AD_CAIXIANG ON 20130604.
                WA-JIAGE = WA-JINE / GT_ITAB-LFIMG.
              ELSE.
                WA-JIAGE = 0.
              ENDIF.
    
    
    *&函数注释
    *    CALL FUNCTION 'YH_PUB_TAX_VALUE_GET'
    *       EXPORTING
    *           I_KSCHL = 'MWVS'
    *              I_MWSKZ = G_MWSKZ
    *            IMPORTING
    *              O_KBETR = G_TEXT.
    **&->START CHANGE BY AD_CAIXIANG ON 20130603 ECDK912048.
    *          WA-JINE  = ( G_DMBTR * ( 1 + G_TEXT / 100 ) ) .
    *          IF G_MENGE NE 0.
    **&->START CHANGE BY AD_CAIXIANG ON 20130604.
    *            WA-JIAGE = WA-JINE / GT_ITAB-LFIMG.
    **  WA-JIAGE = WA-JINE / G_MENGE.
    *&->END CHANGE BY AD_CX.
    
    **&->END CHANGE.
    *          ELSE.
    *            WA-JIAGE = 0.
    *          ENDIF.
    *     IF G_MENGE NE 0.
    *       WA-JIAGE = ( G_DMBTR * ( 1 + G_TEXT / 100 ) ) / G_MENGE.
    *     ELSE.
    *       WA-JIAGE = 0.
    *     ENDIF.
    *&->END CHANGE .
    
            ENDIF.
    
          ENDIF.
    
        ENDIF.
    
    *&---> START ADD BY AD_CAIXIANG ON 20130222 ECDK908753.
    *&当交货单移动类型为 ‘671’ ‘673’时, 小计1/数量 计算价格,
        IF WA-BWART EQ '671' OR WA-BWART EQ '673'.
          WA-JIAGE = G_KZWI1 / G_MENGE.
    *& 金额:
          WA-JINE = WA-JIAGE *  GT_ITAB-LFIMG.
        ENDIF.
    *&---> END ADD BY AD_CAIXIANG ON 20130222.
    
    *&当移动类型为‘653’ ‘601’,通过交货凭证找到对应的开票凭证数据计算价格
        IF WA-BWART EQ '653' OR WA-BWART EQ '601' .
    
    *&读取开票凭证
          READ TABLE LT_VBFA WITH KEY VBELV = WA-VGBEL
                                      POSNV = WA-VGPOS
                                      BINARY SEARCH.
          IF SY-SUBRC EQ 0.
            VBFA-VBELN = LT_VBFA-VBELN.
            VBFA-POSNN = LT_VBFA-POSNN.
          ENDIF.
    
    
          READ TABLE LT_VBRP WITH KEY VBELN = VBFA-VBELN
                                      POSNR = VBFA-POSNN
                                      BINARY SEARCH.
          IF SY-SUBRC EQ 0.
            G_KZWI1 = LT_VBRP-KZWI1.
            G_FKIMG = LT_VBRP-FKIMG.
          ENDIF.
    *&计算价格
          IF G_FKIMG NE SPACE.
            WA-JIAGE = G_KZWI1 / G_FKIMG.
    
          ELSE.
            WA-JIAGE = 0.
          ENDIF.
    *& 金额:
          WA-JINE = WA-JIAGE *  GT_ITAB-LFIMG.
    
        ENDIF.
    
    **& 金额:
    *    WA-JINE = WA-JIAGE *  GT_ITAB-LFIMG.
    *& END ADD ON 20121128
    
    *&S1.6.1: 读取条码:
        READ TABLE LT_MEAN WITH KEY MATNR = WA-MATNR
    *                                MEINH = WA-MEINS
                              BINARY SEARCH.
        IF SY-SUBRC EQ 0.
          WA-EAN11 = LT_MEAN-EAN11.
        ENDIF.
    
    *S1.6.2:取规格:
        READ TABLE LT_MARA WITH KEY MATNR = WA-MATNR
                               BINARY SEARCH.
        IF SY-SUBRC EQ 0.
          WA-GROES = LT_MARA-GROES.
    *&->ADD BY AD_CAIXIANG
          WA-YLBID1 = LT_MARA-MATKL+0(4).
    *&->END ADD.
        ENDIF.
    
    *&->ADD BY AD_CAIXIANG
    *&S1.6.2.1读取大类名称
        READ TABLE LT_YTLBCJ WITH KEY YLBID = WA-YLBID1 BINARY SEARCH.
        IF SY-SUBRC EQ 0.
          WA-YDLNAM = LT_YTLBCJ-YLBNAME.
        ENDIF.
    *&->END ADD.
    
    *S1.6.3:取工厂描述:
        READ TABLE LT_T001W WITH KEY WERKS = WA-WERKS BINARY SEARCH.
        IF SY-SUBRC EQ 0.
          WA-NAME1 = LT_T001W-NAME1.
        ENDIF.
    
    *S1.6.5: 取件数:
        READ TABLE LT_MADQ WITH KEY MATNR = WA-MATNR
                                    WERKS = WA-WERKS
                                   BINARY SEARCH.
        IF SY-SUBRC EQ 0.
          WA-YUMREZ1 = LT_MADQ-YUMREZ1.
        ENDIF.
    
    *&S1.6.6:取数量:
        IF  WA-LFART = 'ZLF' OR WA-LFART = 'ZLR' OR WA-LFART = 'ZLF2' OR WA-LFART = 'ZLR2'.
    
          READ TABLE LT_VBAP WITH KEY VBELN = WA-VGBEL
                                      POSNR = WA-VGPOS
                                      BINARY SEARCH.
          IF SY-SUBRC EQ 0.
            WA-MENGE = LT_VBAP-KWMENG.
            WA-MAKTX = LT_VBAP-ARKTX.
          ENDIF.
    *    ELSE.
    **      WA-MENGE = EKPO-MENGE.
        ENDIF.
    
    *&皮重:
        WA-JINZH  = WA-BRGEW  - WA-NTGEW.
    
    *&订货件数
        IF WA-YUMREZ1 NE 0.
          WA-DINH = WA-MENGE / WA-YUMREZ1.
        ENDIF.
    
    *&实发件数
        IF WA-YUMREZ1 NE 0.
          WA-SHFA = WA-LFIMG / WA-YUMREZ1.
        ENDIF.
    
    *&找移入库位描述:
        IF WA-RESLO NE SPACE.
          READ TABLE LT_T001L WITH KEY WERKS = L_WERKS
                                       LGORT = WA-RESLO
                                       BINARY SEARCH.
          IF SY-SUBRC EQ 0.
            WA-LGOBE1 = LT_T001L-LGOBE.
          ENDIF.
        ENDIF.
    
    **S1.5.12:找移出库位描述:
        IF WA-LGORT NE SPACE.
          READ TABLE LT_T001L WITH KEY WERKS = WA-WERKS
                                       LGORT = WA-LGORT
                                       BINARY SEARCH.
          IF SY-SUBRC EQ 0.
            WA-LGOBE2 = LT_T001L-LGOBE.
          ENDIF.
    
        ENDIF.
    
    
    *& 找类型描述:
        READ TABLE LT_TVLKT WITH KEY LFART = WA-LFART BINARY SEARCH.
        IF SY-SUBRC EQ 0.
          WA-VTEXT = LT_TVLKT-VTEXT.
        ENDIF.
    
    *&S1.5.11:汇总数量:
        L_MENGE  = L_MENGE + WA-MENGE.
        L_LFIMG  = L_LFIMG + WA-LFIMG.
        L_JINZH  = L_JINZH + WA-JINZH.
        WA-NAME2 =  KNA1-NAME1.
        WA-NAME_TEXT = L_NAME_TEXT.
    
    *& 单位转换:
        CALL FUNCTION 'CONVERSION_EXIT_CUNIT_OUTPUT'
          EXPORTING
            INPUT          = WA-MEINS
            LANGUAGE       = SY-LANGU
          IMPORTING
            OUTPUT         = WA-MEINS
          EXCEPTIONS
            UNIT_NOT_FOUND = 1
            OTHERS         = 2.
    
    
    *&START ADD BY AD_CAIXIANG ON 201211206
        MOVE-CORRESPONDING WA TO GT_DATA.
        GT_DATA-MENGE = L_MENGE.
        GT_DATA-LFIMG = L_LFIMG.
        GT_DATA-JINZH = L_JINZH.
    
    
        COLLECT GT_DATA.
        CLEAR   GT_DATA.
    
        MODIFY GT_ITAB FROM WA.
        CLEAR: WA.
        CLEAR : L_MENGE, L_LFIMG, L_JINZH.
    
      ENDLOOP.
    *&END ADD BY AD_CAIXIANG ON ...
    
    *&筛选条件]
    *&->START ADD BY AD_CAIXIANG ON 20130513 ECDK911373
      IF S_RESLO[] IS NOT INITIAL.
        DELETE GT_ITAB WHERE RESLO NOT IN S_RESLO.
        DELETE GT_DATA WHERE RESLO NOT IN S_RESLO.
      ENDIF.
    *&->EDN ADD BY AD_CX.
    
    *&S1.7: 检查是否取到数据:
      DESCRIBE TABLE GT_DATA LINES G_LEN.
      IF G_LEN EQ 0.
        MESSAGE I011 WITH '没有查询到符合条件的数据!'.
        STOP.
      ENDIF.
    
    ENDFORM.                    " frm_get_data
    
    
    *&---------------------------------------------------------------------*
    *&      Form  FRM_LFART
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_LFART .
    
      CLEAR:R_LFART[],R_LFART.
      R_LFART-SIGN = 'I'. R_LFART-OPTION = 'EQ'.
      R_LFART-LOW = 'NLR'.  APPEND R_LFART.
      R_LFART-LOW = 'NL'.   APPEND R_LFART.
      R_LFART-LOW = 'NLCC'. APPEND R_LFART.
      R_LFART-LOW = 'NCR'.  APPEND R_LFART.
      R_LFART-LOW = 'ZLF'.  APPEND R_LFART.
      R_LFART-LOW = 'ZLR'.  APPEND R_LFART.
    *&->START ADD BY AD_CAIXIANG ON 20120126 ECDK907564
      R_LFART-LOW = 'ZLF2'. APPEND R_LFART.
      R_LFART-LOW = 'ZLR2'. APPEND R_LFART.
    *&->END ADD BY AD_CAIXIANG
    
    ENDFORM.                    " FRM_LFART
    
    
    *&---------------------------------------------------------------------*
    *&      Form  frm_output_data
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_ALV_OUTPUT.
    
      CHECK G_LEN NE 0.
    
    *&S4.1: 设定输出字段:
      PERFORM FRM_FIELDCAT_GET.
      PERFORM FRM_EVENTS_SET.
    
    *&S4.2:设定输出格式:
      PERFORM FRM_LAYOUT_SET.
    
      G_LEN = LINES( GT_DATA[] ).
      MESSAGE S013 WITH '找到数据:' G_LEN ''.
    
    *&调用ALV函数输出:
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM       = SY-REPID
    *     I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
          I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
          IS_LAYOUT                = GS_LAYOUT
          IT_FIELDCAT              = GT_FIELDCAT
          I_SAVE                   = 'A'
    *     it_events                = gt_event
        TABLES
          T_OUTTAB                 = GT_DATA
        EXCEPTIONS
          PROGRAM_ERROR            = 1
          OTHERS                   = 2.
    
    
    ENDFORM.                    " FRM_ALV_OUTPUT.
    
    *&---------------------------------------------------------------------*
    *&      Form  USER_COMMAND
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
                            RS_SELFIELD TYPE SLIS_SELFIELD.
      DATA: LR_GRID TYPE REF TO CL_GUI_ALV_GRID.
    
    *&将变更的数据刷新
      CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
        IMPORTING
          E_GRID = LR_GRID.
      CALL METHOD LR_GRID->CHECK_CHANGED_DATA.
      RS_SELFIELD-REFRESH = 'X'.
    
    *  break ad_taoxb.
    
      CLEAR WA.
      CASE R_UCOMM.
        WHEN '&IC1'.
    *&Double deal with:
          CLEAR GT_DATA.
          READ TABLE  GT_DATA INDEX RS_SELFIELD-TABINDEX.
          IF SY-SUBRC EQ 0.
            PERFORM FRM_DETAIL_DISP.
          ENDIF.
    *      CALL METHOD lr_grid->refresh_table_display.
        WHEN OTHERS.
      ENDCASE.
    ENDFORM.                    "USER_COMMAND
    
    
    *&---------------------------------------------------------------------*
    *&      ALV EVENT Form  f_pf_status_set
    *&---------------------------------------------------------------------*
    FORM F_PF_STATUS_SET  USING EXTAB TYPE SLIS_T_EXTAB.
    
      SET PF-STATUS 'STANDARD' EXCLUDING EXTAB.
    
    ENDFORM.                    " f_pf_status_set
    *&---------------------------------------------------------------------*
    *&      Form  FRM_FIELDCAT_GET
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_FIELDCAT_GET .
    
      CLEAR GT_FIELDCAT.
      REFRESH GT_FIELDCAT.
    *&设定输出的相关字段结构:
      MAR_ADD_FIELDCAT 'VBELN'     '交货单'       '1'  '' '10' 'X' '' ''.
      MAR_ADD_FIELDCAT 'WERKS'     '配出机构'     '2'  '' '6'  ' ' '' ''.
      MAR_ADD_FIELDCAT 'NAME1'     '配出机构名称' '3'  '' '15' ' ' '' ''.
      MAR_ADD_FIELDCAT 'KUNNR'     '配入机构'     '5'  '' '6'  ' ' '' 'X'.
      MAR_ADD_FIELDCAT 'NAME2'     '配入机构名称' '6'  '' '20' ' ' '' ''.
    
      MAR_ADD_FIELDCAT 'LGORT'     '移出库位'     '7' '' '6'    ' ' '' ''.
      MAR_ADD_FIELDCAT 'LGOBE2'    '移出库位描述' '8' '' '15'   ' ' '' ''.
      MAR_ADD_FIELDCAT 'RESLO'     '移入库位'     '9'  '' '6'   ' ' '' ''.
      MAR_ADD_FIELDCAT 'LGOBE1'    '移入库位描述' '10'  '' '15' ' ' '' ''.
      MAR_ADD_FIELDCAT 'LIFEX'     '融通单号'     '12' '' '20' ' ' '' ''.
      MAR_ADD_FIELDCAT 'LFART'     '类型'         '13' '' '5'  ' ' '' ''.
      MAR_ADD_FIELDCAT 'VTEXT'     '交货类型描述' '14' '' '15' ' ' '' ''.
      MAR_ADD_FIELDCAT 'YYCARNO'   '车辆号'       '15' '' '10' ' ' '' ''.
      MAR_ADD_FIELDCAT 'BLDAT'     '凭证日期'     '17' '' '10' ' ' '' ''.
      MAR_ADD_FIELDCAT 'ERZET'     '时间'         '17' '' '10' ' ' '' ''.
      MAR_ADD_FIELDCAT 'WADAT_IST' '实际发货日期' '18' '' '10' ' ' '' ''.
      MAR_ADD_FIELDCAT 'MENGE'     '订货数量'     '20' '' '10' ' ' '' ''.
      MAR_ADD_FIELDCAT 'LFIMG'     '实发数量'     '21' '' '10' ' ' '' ''.
      MAR_ADD_FIELDCAT 'JINZH'     '皮重'         '22' '' '10' ' ' '' ''.
      MAR_ADD_FIELDCAT 'JINE'      '金额'         '22' '' '10' ' ' '' ''.
      MAR_ADD_FIELDCAT 'KOSTK'     '总拣配状态'   '23' '' '6'  ' ' '' ''.
      MAR_ADD_FIELDCAT 'WBSTK'     '移动总状态'   '25' '' '8'  ' ' '' ''.
      MAR_ADD_FIELDCAT 'NAME_TEXT' '制单人'       '26' '' '10' ' ' '' ''.
      "MAR_ADD_FIELDCAT 'TDDAT' '计划日期' '16' '' '10' ' ' ' '.
    
    ENDFORM.                    " FRM_FIELDCAT_GET
    *&---------------------------------------------------------------------*
    *&      Form  FRM_EVENTS_SET
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_EVENTS_SET .
    
    ENDFORM.                    " FRM_EVENTS_SET
    *&---------------------------------------------------------------------*
    *&      Form  FRM_LAYOUT_SET
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_LAYOUT_SET .
    
      CLEAR GS_LAYOUT.
      MOVE:  'X'  TO  GS_LAYOUT-ZEBRA,
             'X'  TO  GS_LAYOUT-COLWIDTH_OPTIMIZE,
             'X'  TO  GS_LAYOUT-DETAIL_POPUP.
    
    ENDFORM.                    " FRM_LAYOUT_SET
    *&---------------------------------------------------------------------*
    *&      Form  FRM_DETAIL_DISP
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_DETAIL_DISP .
      DATA: LT_ITAB LIKE GT_ITAB OCCURS 0 WITH HEADER LINE.
      DATA: G_LEN2 TYPE SY-TABIX.
    
    *&T1.找到需显示的数据:
      LT_ITAB[] = GT_ITAB[].
      IF P_DETAIL IS INITIAL.
        DELETE LT_ITAB WHERE VBELN NE GT_DATA-VBELN.
        SORT  LT_ITAB BY MATNR.
      ENDIF.
    
    *&T2:获取结构:
      PERFORM FRM_FIELDCAT_GET2.
    
      G_LEN2 = LINES( LT_ITAB[] ).
      MESSAGE S013 WITH '找到数据:' G_LEN2 ''.
    
    *&T3: 显示:
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM       = SY-CPROG
    *     I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
    *     I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
          IS_LAYOUT                = GS_LAYOUT
          IT_FIELDCAT              = GT_FIELDCAT2
          I_SAVE                   = 'A'
    *     it_events                = gt_event
        TABLES
          T_OUTTAB                 = LT_ITAB
        EXCEPTIONS
          PROGRAM_ERROR            = 1
          OTHERS                   = 2.
    
    ENDFORM.                    " FRM_DETAIL_DISP
    *&---------------------------------------------------------------------*
    *&      Form  FRM_FIELDCAT_GET2
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_FIELDCAT_GET2 .
    
      CLEAR GT_FIELDCAT2.
      REFRESH GT_FIELDCAT2.
    *&设定输出的相关字段结构:
      MAR_ADD_FIELDCAT2 'VBELN'     '交货单'       '1'  '' '10'  'X' ''   ''.
      MAR_ADD_FIELDCAT2 'POSNR'     '项次'         '2'  '' '5'   'X' ' '  ''.
      MAR_ADD_FIELDCAT2 'WERKS'     '配出机构'     '3'  '' '6'   ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'NAME1'     '配出机构名称' '4'  '' '15'  ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'KUNNR'     '配入机构'     '5'  '' '6'   ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'NAME2'     '配入机构名称' '6'  '' '20'  ' ' ' '  ''.
    
      MAR_ADD_FIELDCAT2 'LGORT'     '移出库位'     '7' '' '6'    ' ' '' ''.
      MAR_ADD_FIELDCAT2 'LGOBE2'    '移出库位描述' '8' '' '15'   ' ' '' ''.
      MAR_ADD_FIELDCAT2 'RESLO'     '移入库位'     '9'  '' '6'   ' ' '' ''.
      MAR_ADD_FIELDCAT2 'LGOBE1'    '移入库位描述' '10'  '' '15' ' ' '' ''.
    
    *  MAR_ADD_FIELDCAT2 'RESLO'     '移出库位'     '8'  '' '6'   ' ' ' '  ''.
    *  MAR_ADD_FIELDCAT2 'LGOBE1'    '移出库位描述' '9'  '' '15'  ' ' ' '  ''.
    *  MAR_ADD_FIELDCAT2 'LGORT'     '移入库位'     '10' '' '6'   ' ' ' '  ''.
    *  MAR_ADD_FIELDCAT2 'LGOBE2'    '移入库位描述' '11' '' '15'  ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'LFART'     '类型'         '13' '' '5'   ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'VTEXT'     '交货类型描述' '14' '' '15'  ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'VGBEL'     '参考凭证'     '14' '' '10'  ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'VGPOS'     '参考项次'     '14' '' '5'   ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'MATNR'     '商品编码'     '15' '' '18'  ' ' ' '  'X'.
      MAR_ADD_FIELDCAT2 'EAN11'     '条码'         '16' '' '15'  ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'MAKTX'     '商品名称'     '17' '' '30'  ' ' ' '  ''.
    *&->START ADD BY AD_CAIXIANG ON 20130514 ECDK911331
      MAR_ADD_FIELDCAT2 'YLBID1'    '大类编码'     '18' '' '15'  ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'YDLNAM'    '大类名称'     '18' '' '30'  ' ' ' '  ''.
    *&->END ADD.
    
      MAR_ADD_FIELDCAT2 'MEINS'     '单位'         '19' '' '5'   ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'YYCARNO'   '车辆号'       '20' '' '10'  ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'BLDAT'     '凭证日期'     '23' '' '10'  ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'ERZET'     '时间'         '23' '' '10'  ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'WADAT_IST' '实际发货日期' '24' '' '10'  ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'ANZPK'     '包数'         '25' '' '10'  ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'GROES'     '规格'         '26' '' '10'  ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'YUMREZ1'   '件装数'       '28' '' '10'  ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'DINH'      '订货件数'     '29' '' '10'  ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'MENGE'     '订货数量'     '30' '' '10'  ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'SHFA'      '实发件数'     '31' '' '10'  ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'LFIMG'     '实发数量'     '32' '' '10'  ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'JINZH'     '皮重'         '33' '' '10'  ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'NAME_TEXT' '制单人'       '36' '' '10'  ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'LIFNR'     '供应商编码'   '37' '' '10'  ' ' ' '  'X'.
      MAR_ADD_FIELDCAT2 'NAME3'     '供应商名称'   '38' '' '10'  ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'JIAGE'     '价格'         '38' '' '10'  ' ' ' '  ''.
      MAR_ADD_FIELDCAT2 'JINE'      '金额'         '38' '' '10'  ' ' ' '  ''.
      "MAR_ADD_FIELDCAT2 'TDDAT' '计划日期' '21' '' '10' ' ' ' ' ''.
    
    ENDFORM.                    " FRM_FIELDCAT_GET2

     

    转载于:https://www.cnblogs.com/rainysblog/p/6093990.html

    更多相关内容
  • 交货通知单格式.DOC

    2021-12-18 21:43:15
    交货通知单格式.DOC
  • 交货通知(DOC模板格式).doc
  • 交货期变更通知单格式.doc
  • 交货期变更通知(表格模板、DOC格式).doc
  • 交货期变更通知(DOC格式).doc
  • 交货单(内向和外向)因实际业务需求append一个或多个附加字段,在使用BAPI维护交货单时,需要对附加字段进行修改。标准参数字段较少,无法满足更改需求,需要通过其他方式实现 实现思路 在使用交货单的修改BAPI...

    创建增强

    创建BAPI:BAPI_OUTB_DELIVERY_CREATE_SLS

    增强BADI:LE_SHP_DELIVERY_PROC

    增强字段

     

     

     

     

     

    修改增强

    交货单(内向和外向)因实际业务需求append一个或多个附加字段,在使用BAPI维护交货单时,需要对附加字段进行修改。标准参数字段较少,无法满足更改需求,需要通过其他方式实现

     

    实现思路

    在使用交货单的修改BAPI(BAPI_*_DELIVERY_CHANGE)时,发现自带的Extension参数,但不知具体用法。经查阅SAP官方社区的帖子,发现两个增强的位置, BADI->SMOD_V50B0001,可以将extension读取到标准程序的全局变量中;在BADI->LE_SHP_DELIVERY_UPDATE中,通过全局变量更新标准结构CS_LIKP、CS_LIPS;

     

    以下就具体实施方法进行简要说明(以内向交货单抬头和行项目为例,外向类似)。

     

    具体步骤

    Append字段至标准结构

    抬头结构:VBKOK

     

    行项目结构

     

     

      参考下图,无特定规则,根据实际需求填充参数,

     

    更新标准字段

    复制extension字段至全局变量

    实现BADI->SMOD_V50B0001,在方法exit_saplv50i_010(外向交货单更改出口)中:

     

    CS_VBKOK为抬头

    CT_VBPOK为行项目

     

     

    从全局变量获取更新参数

    实现BADI->LE_SHP_DELIVERY_UPDATE,在对应方法中进行字段更新

     

     

     

    展开全文
  • 交货期变更通知(DOC模板格式).doc
  • 原文链接:【MM系列】SAP 交货单屏幕增强 前言部分 大家可以关注我的公众号,公众号里的排版更好,阅读更舒适。 正文部分 BADI:LE_SHP_TAB_CUST_ITEM 增强屏幕 LE_SHP_DELIVERY_PR...
    公众号: SAP Technical
    本文作者: matinal
     

     

    前言部分

    大家可以关注我的公众号,公众号里的排版更好,阅读更舒适。

    正文部分

    BADI:LE_SHP_TAB_CUST_ITEM  增强屏幕

    LE_SHP_DELIVERY_PROC   逻辑编写

    转载于:https://www.cnblogs.com/SAPmatinal/p/11174531.html

    展开全文
  • 本专利申请属于企业管理系统技术领域,更具体地说,是涉及一种基于SAP系统数据智能导入批量创建销售订单及交货单过账的方法。背景技术:SAP ( system application and products in data processing ) 是一款用于企业...

    本专利申请属于企业管理系统技术领域,更具体地说,是涉及一种基于SAP系统数据智能导入批量创建销售订单及交货单过账的方法。

    背景技术:

    SAP ( system application and products in data processing ) 是一款用于企业资源计划ERP(enterprise resource planning)的管理软件,具有集成管理、共享数据、最优化资源利用等特性。

    BAPI(business application programming interface)是面向对象程序设计方法中的一组程序接口,有属性、有方法、有事件,可以反映SAP的业务应用。作为功能函数,BAPI 中自带有自动检查逻辑的功能。

    在此之前业务人员制单需要在SAP系统中通过VA01、VL01N的方式进行单张录入,过程繁锁,效率低,工作量大。此种方法,在现有技术中,首先被排除。另一张方法,通过BDC录屏的方式,记录人的第一次操作,然后重复模拟这个动作来完成批量工作,灵活度不高,只适合单一操作,并且此操作的专业性要求较高。BAPI与BDC相比,执行速度会更快,效率更高,灵活性更强,因此需要进行基于SAP系统批量创建销售订单及交货单过账的方法的研发。

    技术实现要素:

    本发明需要解决的技术问题是提供一种基于SAP系统批量创建销售订单及交货单过账的方法,旨在解决批量创建销售订单及交货单及批量过账的问题。

    为了解决上述问题,本发明所采用的技术方案是:

    一种基于SAP系统批量创建销售订单及交货单过账的方法,运用ABAP开发语言,在SAP系统中导入创建销售订单所需要的数据,在程序中通过调用BAPI函数,自动批量创建销售订单,销售订单创建成功后,再根据所对应的销售订单号创建交货单及发货过账。

    本发明技术方案的进一步改进在于:包括如下步骤:

    步骤一、先将创建销售订单和交货单的模板上传到SAP的服务器中,业务人员通过自开发的报表,下载模板,按照模板填入创建销售订单所需数据,必填数据不能为空;

    步骤二、把收集好的数据用TXT的格式导入自开发的报表中,并进行数据验证(用报表自带的逻辑检查必填数据是否为空),若数据导入失败,则返回报错信息;

    步骤三、数据导入成功后运行程序,并创建销售订单,若创建失败,在显示界面中会返回报错原因;若创建成功,在显示界面中会返回创建的订单号和订单行项目;

    步骤四、把新生成的订单号和订单行项目号导出,并进行格式转换,转换成TXT的格式,然后再次导入创建交货单及过账的报表中,并进行数据验证,交货量为必填项,报表自带逻辑检查必填数据是否为空,没有返回报错信息,则说明数据导入成功;

    步骤五、数据导入成功后,运行交货单创建及过账的报表,若创建失败,在显示界面中会返回报错原因;若创建成功,在显示界面中会返回创建的交货单号。

    本发明技术方案的进一步改进在于:步骤二中,把收集好的数据用TXT的格式导入自开发的报表中;步骤四中,把新生成的订单号和订单行项目号导出,转换成TXT的格式,

    本发明技术方案的进一步改进在于:步骤三和步骤五中的显示界面为ALV显示。

    由于采用了上述技术方案,本发明取得的有益效果是:本发明摒弃了传统手工单张录入的方式,采用自动批量创建的方法,减少人员干预,提高工作效率,降低用工成本,增加了操作准确性,同时选择采用自开发程序和调用BAPI的方法,而不是使用简单的BDC录屏,灵活性高,适合定制化制单,更符合现在的业务需求,因此本发明具有设计合理、结构简单,使用方便等特点,具有很好的推广使用价值。

    附图说明

    图1是本发明的流程图。

    具体实施方式

    下面结合实施例对本发明做进一步详细说明。

    本发明公开了一种基于SAP系统批量创建销售订单及交货单过账的方法,参见图1,运用ABAP开发语言,在SAP系统中导入创建销售订单所需要的数据,在程序中通过调用BAPI函数,自动批量创建销售订单,销售订单创建成功后,再根据所对应的销售订单号创建交货单及发货过账。

    包括如下步骤:

    步骤一、先将创建销售订单和交货单的模板上传到SAP的服务器中,业务人员通过自开发的报表,下载模板,按照模板填入创建销售订单所需数据,必填数据不能为空;

    步骤二、把收集好的数据用TXT的格式导入自开发的报表中(图中为zsd115报表),并进行数据验证(报表自带逻辑检查必填数据是否为空),若数据导入失败,则返回报错信息;

    步骤三、数据导入成功后运行程序,并创建销售订单,若创建失败,在ALV显示中会返回报错原因;若创建成功,在ALV显示中会返回创建的订单号和订单行项目;

    步骤四、把新生成的订单号和订单行项目号导出,并进行格式转换,转换成TXT的格式,然后再次导入创建交货单及过账的报表中(图中为zsd116报表),并进行数据验证,交货量为必填项,报表自带逻辑检查必填数据是否为空,没有返回报错信息,则说明数据导入成功;

    步骤五、数据导入成功后,运行交货单创建及过账的报表,若创建失败,在ALV显示中会返回报错原因;若创建成功,在ALV显示中会返回创建的交货单号。

    步骤二中,把收集好的数据用TXT的格式导入自开发的报表中;步骤四中,把新生成的订单号和订单行项目号导出,转换成TXT的格式。也可以两者都采用word形式,只要双方相互对应即可。

    步骤三和步骤五中的显示界面为ALV显示,面向对象化的方式来进行列表显示。

    展开全文
  • SAP中交货计划导出需求处理实例

    千次阅读 2020-05-25 16:23:55
    有时SAP前台事务无法完美的满足业务部门的工作需求报表需求。...只是针对一些简单的中间需求(即标准功能无法实现,BW又没有预先设计)采用后台表或多表组合的方式来处理相关需求的一种方法。通过笔者所
  • 送货管理软件下载

    2021-04-29 01:41:35
    思达送货管理系统是一款简单易用、功能强大的送货管理软件,软件界面简明,操作按钮一目了然,只需花几分钟就可以对整个系统完全上手,致力于为用户带来更加轻松的送货管理体验。功能介绍√ 权限操作,可以设置...
  • 批量修改工日期: STATUS_READ获取订单状态 通过订单的对象号(OR+4位前导0+订单号)到表JEST中取出字段STAT INACT,再去表TJ02T查看STAT对应的描述 Direction ...
  •  8、送货可引入报价或销售订单,无需重复输入,引入后自动显示交货数量;  9、销售时可以设置产品最低价,最高低,低于最低价时禁止开单;  10、销售时可以适时掌握商品的当前库存数、销售成本等信息;  11...
  • 问题场景:需要将下列的交期一列的数据格式更改成2019/05/10存货编码 尺寸 数量 交期0 K10Y0190000X B140 200 2019-05-10 00:00:001 K10Y0190000X B150 200 2019-05-10 00:00:002 K10Y0190000X B165 100 2019-05-10 ...
  • 原文地址:DN打印设置VL71作者:乡巴佬 双击打开,修改存取顺序类型 程序修改 VV21 设置输出条件
  • 标签:php因此,我在数据库中有一个字段用于交付时间,它具有某些格式(肯定不是我的设计!):以下是几个示例:M,T,W,TH; 9:4关闭12:1关闭T,W,TH,F;...分号之后是天数,没有分开,然后是交货时间,包括...
  • 外贸报价完整格式

    2013-08-13 14:05:00
    一、报价的头部 01,卖家基本资料(举例) 工厂标志(Factory Logo) 公司名称(Company) 详细地址(Detailed Address) 邮政编码(Post Code) 联系人名(Contact) 职位名称(Job title) 电话号码...
  •  8、送货可引入报价或销售订单,无需重复输入,引入后自动显示交货数量;  9、销售时可以设置产品最低价,最高低,低于最低价时禁止开单;  10、销售时可以适时掌握商品的当前库存数、销售成本等信息;  11、...
  • “销售退货资料汇总”、“销售收款资料查询”、“销售收款明细查询”、“销售订单交货情况查询”、“应收帐款资料查询”、“应收帐 款资料汇总”等等。 7、库存管理 在库存管理模块,睿智进销存提供了其它...
  • 外贸跟员详细工作流程外贸跟员定义: 外贸跟员是指在进出口业务中,在贸易合同签订后,依据合同和相关单证对货物加工、装运、保险、报检、报关、结汇等部分或全部环节进行跟踪或操作,协助履行贸易合同的外贸...
  • 本篇文章小编给大家分享一下利用python对excel中一列的时间数据更改格式代码示例,文章代码介绍的很详细,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看。问题场景:需要将下列的交期一...
  • 文档介绍:投标书格式(范本)一、 投标书封面格式投 标 书建 设 项 目 名 称:投 标 位:投标单位全权代表:投标单位: (公章)年 月 日二、 投标书格式投 标 书致:________________________________依据贵...
  • 该清单采购交货计划,需要包含采购协议号,供应商代码,物料号,交货计划(日期及数量)。但在SAP标准功能中,笔者没有找到有事务能够完整的满足需求。SAP确实也提供了大量标准的报表输出事务,但仍不能满复杂的业务...
  • 用python对excel中一列的时间数据更改格式 问题场景:需要将下列的交期一列的数据格式更改成2019/05/10 存货编码 尺寸 数量 交期 0 K10Y0190000X B140 200 2019-05-10 00:00:00 1 K10Y0190000X B150 200 2019-05-...
  • 问题场景:需要将下列的交期一列的数据格式更改成2019/05/10存货编码 尺寸 数量 交期0 K10Y0190000X B140 200 2019-05-10 00:00:001 K10Y0190000X B150 200 2019-05-10 00:00:002 K10Y0190000X B165 100 2019-05-10 ...
  • 软件主要针对的是企业店铺的订单管理和打印,可以实现订单的妥善管理和精美的送货单格式送货单格式。软件界面美观简洁、简单全面、实用方便,无需培训,即可快速上手,轻轻松松完成日常订单管理功能,真正做到简单...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 2,251
精华内容 900
关键字:

交货单格式