ABAP 恍忽昨天的代码,今天看不懂了;大叔


曲不离口,艺不离手,常看常新,有感而发

查询界面:

 

*&---------------------------------------------------------------------*
*& Report ZSDR0030
*& 交货单查询
*&---------------------------------------------------------------------*
*&zh
*&---------------------------------------------------------------------*
REPORT zsdr0030.
TABLES :likp,lips,zsact0003,kna1,vbap,vbak,vbrp,marm,mvke,vbfa,vbkd,vbpa,zmmt0037,but000.

**定义结构
DATA:
  gt_data TYPE TABLE OF zsact0003.

TYPES: BEGIN OF gty_out,
         werks         LIKE lips-werks,                               "工厂
         erdat         LIKE likp-erdat,                            "创建日期
         aedat         LIKE lips-aedat,                            "发货日期
         wadat_ist     LIKE likp-wadat_ist,                            "过帐日期
         vkorg         LIKE likp-vkorg,                                "销售组织代码
         vtweg         LIKE lips-vtweg,                                "渠道编码
         vtweg_mc(10)  TYPE c,                              "渠道名称
         vkbur         LIKE lips-vkbur,                                "销售办公室编码
         vkbur_mc(20)  TYPE c,                                     "销售办公室名称
         vkgrp         LIKE vbak-vkgrp,                              "销售组编码
         vkgrp_mc(20)  TYPE c,                                     "销售组名称
         bzirk         LIKE vbkd-bzirk,                                "销售地区
         bzirk_mc(20)  TYPE c,                                "销售地区名称
         kdgrp         LIKE vbkd-kdgrp,                                "客户组
         kdgrp_mc(20)  TYPE c ,                                      "客户组名称
         kunnr         LIKE likp-kunag,                                "客户代码
         name1         LIKE kna1-name1,                                 "客户名称
         matnr         LIKE lips-matnr,                                "物料号
         maktx         LIKE zmmt0037-maktx,                            "物料描述
         charg         LIKE lips-charg,                                 "批号
         lfart         LIKE likp-lfart,                                "交货单类型
         lfimg         LIKE lips-lfimg,                                "交货数量
         hsdj          LIKE vbap-kwmeng,                               "含税价
         hsje          LIKE vbap-kwmeng,                               "含税价
         vrkme         LIKE lips-vrkme,                                "销售单位
         netwr         LIKE vbap-kzwi1,                                "销售订单行金额
         kwmeng        LIKE vbap-kwmeng,                               "销售订单数量
         vrkme_so      LIKE vbap-vrkme,                      "销售单位
         vbeln         LIKE likp-vbeln,                     "交货单号
         posnr         LIKE lips-posnr,                       "行项目号
         vbtyp_v       LIKE vbfa-vbtyp_v,                     "
         ddbh          LIKE vbak-vbeln ,                         "订单编号
         rybh          LIKE vbpa-kunnr,                           "业务员号
         ryxm          LIKE but000-name_last ,                    "业务员姓名
         zzbusin       LIKE zmmt0037-zzbusin,                  "事业部
         zzproducst    LIKE zmmt0037-zzproducst,                "生产企业
         zzabccat      LIKE zmmt0037-zzabccat,                 "ABC类别
         umvkz         LIKE lips-umvkz,                  "每件数量
         umrez         LIKE zmmt0037-umrez,               "标准件数量
         wgbez         LIKE zmmt0037-wgbez,                  "物料组
         zzdosage_desc LIKE zmmt0037-zzdosage_desc,       "剂型描述
         ewbez         LIKE zmmt0037-ewbez,                  "治疗领域
         vtext         LIKE zmmt0037-vtext,                 "产品类别
         zsl           LIKE lips-lfimg,                    "主数量
         fzsl          LIKE lips-lfimg,                    "辅助数量
         vsart         LIKE vbkd-vsart,                          "运输方式
         vsart_mc(20)  TYPE c,                          "运输方式名称
       END OF gty_out.

DATA:
  lv_kwmeng_su TYPE vbap-kwmeng,     "销售单位数量
  lv_kwmeng_bu TYPE vbap-kwmeng,     "基本单位数量
  lv_netwr     TYPE vbap-netwr,      "金额
  lwa_data     TYPE zsact0003,
  lt_marm      TYPE TABLE OF marm,   "单位转化系数
  lwa_marm     TYPE marm,
  lt_mvke      TYPE TABLE OF mvke,   "销售单位
  lwa_mvke     TYPE mvke,
  lv_price     TYPE p LENGTH 11 DECIMALS 5,      "销售单价
  lv_lfimg     TYPE lips-lfimg,      "发货数量
  lv_lfimg_ba  TYPE lips-lfimg,      "发货数量(基本单位)
  lv_fkimg     TYPE vbrp-fkimg,      "开票数量
  lv_fkimg_ba  TYPE vbrp-fkimg.      "开票数量(基本单位)

*标准的ALV输出
* slis 类型池 全局变量 定义,多数没用,
DATA: g_repid             TYPE sy-repid,
      g_line              TYPE slis_fieldcat_alv,
      gt_fieldcat         TYPE slis_t_fieldcat_alv,
      gt_layout           TYPE slis_layout_alv,
      gt_sortinfo         TYPE slis_sortinfo_alv,
      gt_lvc_title        TYPE lvc_title,
      gt_list_top_of_page TYPE slis_t_listheader,
      gt_events           TYPE slis_t_event,
      gt_fcat             TYPE lvc_t_fcat,
      gt_table            TYPE REF TO data,
      gs_settings         TYPE lvc_s_glay,
      f2code              LIKE sy-ucomm VALUE '&TEA'.


* 定义用于输出的内表
DATA: gt_tab TYPE STANDARD TABLE OF gty_out  WITH HEADER LINE.
DATA: gt_tab2 TYPE STANDARD TABLE OF gty_out.

**定义双击执行事务代码 用,  猜的
DATA ok_code LIKE sy-ucomm.

DATA: g_ucomm LIKE sy-ucomm.

DATA:   bdcdata LIKE bdcdata    OCCURS 0 WITH HEADER LINE."用来存储屏幕字段参数值,传递录屏参数
*       messages of call transaction
DATA:   messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE."记录执行BDC过程中产生的消息
DATA: ls_mss LIKE bdcmsgcoll.

*选择屏幕
SELECT-OPTIONS:
  s_vbeln FOR likp-vbeln,"交货单号
  s_kunnr FOR likp-kunag,"客户号
  s_ywy   FOR vbpa-kunnr,"业务员
  s_vkorg FOR likp-vkorg,"销售组织
  s_vtweg FOR lips-vtweg,"渠道
  s_matnr FOR lips-matnr,"物料号
  s_werks FOR lips-werks,"工厂
  s_bzirk FOR vbkd-bzirk,"地区
  s_fhrq FOR likp-wadat_ist , "实际发货日期
  s_cjrq FOR likp-wadat_ist , "创建日期
  s_pjrq FOR likp-wadat_ist . "票据日期


AT SELECTION-SCREEN.
  IF s_fhrq IS INITIAL AND
     s_cjrq IS INITIAL AND
     s_pjrq IS INITIAL .
    MESSAGE '发货日期、创建日期、票据日期 至少填一个'  TYPE 'E'.
  ENDIF.

  DATA: lv_message        TYPE string.
  SELECT tvko~vkorg
  INTO  TABLE @DATA(gt_tvko)
  FROM tvko
  WHERE tvko~vkorg IN @s_vkorg
    AND tvko~vkorg <> '0001'
    AND tvko~vkorg <> '0003'
    .
  LOOP AT gt_tvko INTO DATA(wa_tvko).
    AUTHORITY-CHECK OBJECT 'V_VBAK_VKO'
     ID 'VKORG' FIELD wa_tvko-vkorg
     ID 'VTWEG' DUMMY
     ID 'SPART' DUMMY
*     ID 'ACTVT' FIELD '03'
     .
    IF sy-subrc <> 0.
      lv_message = '公司代码:' && wa_tvko-vkorg .
      MESSAGE e053(zmm) WITH   lv_message.
    ENDIF.
    CLEAR: wa_tvko.
  ENDLOOP.


***************************************************************
**2 功能 程序
**************************************************************
** 1 统计发货情况,含正向发货和退货
START-OF-SELECTION.

  "发货
  SELECT
    b~werks,                  "工厂
    a~erdat,                  "   创建日期
    a~wadat_ist,              "发货日期
    a~vkorg,                  "销售组织代码
    b~vtweg,                  "渠道编码
  "  b~vtweg AS vtweg_mc,     "渠道名称
    b~vkbur,                  "销售办公室编码
 "   b~vkbur AS vkbur_mc,     "销售办公室编码
    g~vkgrp,                  "销售组编码
"    g~vkgrp AS vkgrp_mc,     "销售组名称
    e~bzirk,                  "销售地区
  "  e~bzirk AS bzirk_mc,     "销售地区名称
    e~kdgrp,                  "客户组
*    e~kdgrp AS kdgrp_mc,
    a~kunag AS kunnr,         "客户代码
    h~name1 ,                 "客户名称
    b~matnr,                  "物料号
    i~maktx,                  "物料描述
    b~charg,                  "批号
    a~lfart,                  "交货单类型
    b~lfimg,                  "交货数量
*    f~kzwi1  AS hsdj,        "含税价
*    f~kzwi1  AS hsje,        "含税价
    b~vrkme,                  "销售单位
    f~kzwi1 AS netwr,         "销售订单行金额
    f~kwmeng,                 "销售订单数量
    f~vrkme AS vrkme_so,      "销售单位
    a~vbeln,
    b~posnr,
    d~vbtyp_v,
    g~vbeln AS ddbh ,         "订单号
    j~kunnr AS rybh,          "业务员号
    k~name_last AS ryxm,      "姓名
    i~zzbusin,                "事业部
    i~zzproducst,             "生产企业
    i~zzabccat,               "ABC分类
    b~umvkz,                  "每件数量
    i~umrez,                  "标准件数量
    i~wgbez,                  "物料组
    i~zzdosage_desc,          "剂型描述
    i~ewbez,                  "治疗领域
    i~vtext,                  "产品类别
    b~lfimg AS zsl,           "主数量
    b~lfimg AS fzsl,          "辅助主数量
    e~vsart

     INTO  CORRESPONDING FIELDS OF TABLE @gt_tab
  FROM likp AS a
  INNER JOIN lips AS b
    ON a~vbeln = b~vbeln
  LEFT JOIN vbfa AS d
    ON b~vbeln = d~vbeln
   AND b~posnr = d~posnn
   AND d~vbtyp_v = 'C'                   "只获取销售订单和交货单的关联数据
  LEFT JOIN vbkd AS e
    ON d~vbelv = e~vbeln AND e~posnr = '000000'
  LEFT JOIN vbap AS f
    ON d~vbelv = f~vbeln
   AND d~posnv = f~posnr
  LEFT JOIN vbak AS g
    ON d~vbelv = g~vbeln
   LEFT JOIN kna1 AS h
    ON a~kunag = h~kunnr
   LEFT JOIN zmmt0037 AS i
    ON b~matnr = i~matnr
   LEFT JOIN vbpa AS j
    ON a~vbeln = j~vbeln AND j~parvw = 'Z1'
   LEFT JOIN but000 AS k
    ON j~kunnr = k~partner


  WHERE a~erdat  IN @s_cjrq
    AND a~kunag IN @s_kunnr
**************************************************
*&  Modified by  shuaige
*&  Date:   23.02.2022 08:59:43
*&  Description: 修改了发货日期取值逻辑后 这里的查询条件不在生效 将在处理数据时处理这个日期
*    AND b~aedat IN @s_fhrq
*&
**************************************************

    AND a~wadat_ist IN @s_pjrq

    AND b~matnr IN @s_matnr
    AND a~vkorg IN @s_vkorg
    AND b~vtweg IN @s_vtweg
    AND a~vbeln IN @s_vbeln
    AND b~werks IN @s_werks
    AND j~kunnr IN @s_ywy
    AND e~bzirk IN @s_bzirk
    AND a~wbstk = 'C'
    AND a~lfart = 'LF'.

  "退货
  SELECT
    b~werks,                  "工厂
    a~erdat,                  "   创建日期
    a~wadat_ist,              "发货日期
    a~vkorg,                  "销售组织代码
    b~vtweg,                  "渠道编码
  "  b~vtweg AS vtweg_mc,     "渠道名称
    b~vkbur,                  "销售办公室编码
 "   b~vkbur AS vkbur_mc,     "销售办公室编码
    g~vkgrp,                  "销售组编码
"    g~vkgrp AS vkgrp_mc,     "销售组名称
    e~bzirk,                  "销售地区
  "  e~bzirk AS bzirk_mc,     "销售地区名称
    e~kdgrp,                  "客户组
*    e~kdgrp AS kdgrp_mc,
    a~kunag AS kunnr,         "客户代码
    h~name1 ,                 "客户名称
    b~matnr,                  "物料号
    i~maktx,                  "物料描述
    b~charg,                  "批号
    a~lfart,                  "交货单类型
    b~lfimg,                  "交货数量
*    f~kzwi1  AS hsdj,        "含税价
*    f~kzwi1  AS hsje,        "含税价
    b~vrkme,                  "销售单位
    f~kzwi1 AS netwr,         "销售订单行金额
    f~kwmeng,                 "销售订单数量
    f~vrkme AS vrkme_so,      "销售单位
    a~vbeln,
    b~posnr,
    d~vbtyp_v,
    g~vbeln AS ddbh ,         "订单号
    j~kunnr AS rybh,          "业务员号
    k~name_last AS ryxm,      "姓名
    i~zzbusin,                "事业部
    i~zzproducst,             "生产企业
    i~zzabccat,               "ABC分类
    b~umvkz,                  "每件数量
    i~umrez,                  "标准件数量
    i~wgbez,                  "物料组
    i~zzdosage_desc,          "剂型描述
    i~ewbez,                  "治疗领域
    i~vtext,                  "产品类别
    b~lfimg AS zsl,           "主数量
    b~lfimg AS fzsl,          "辅助主数量
    e~vsart

    APPENDING CORRESPONDING FIELDS OF  TABLE @gt_tab
  FROM likp AS a
  INNER JOIN lips AS b
    ON a~vbeln = b~vbeln
  LEFT JOIN vbfa AS d
    ON b~vbeln = d~vbeln
   AND b~posnr = d~posnn
   AND d~vbtyp_v = 'H'                  "只获取销售订单和交货单的关联数据
  LEFT JOIN vbkd AS e
    ON d~vbelv = e~vbeln AND e~posnr = '000000'
  LEFT JOIN vbap AS f
    ON d~vbelv = f~vbeln
   AND d~posnv = f~posnr
  LEFT JOIN vbak AS g
    ON d~vbelv = g~vbeln
   LEFT JOIN kna1 AS h
    ON a~kunag = h~kunnr
   LEFT JOIN zmmt0037 AS i
      ON b~matnr = i~matnr
   LEFT JOIN vbpa AS j
    ON a~vbeln = j~vbeln AND j~parvw = 'Z1'
   LEFT JOIN but000 AS k
    ON j~kunnr = k~partner

  WHERE a~erdat  IN @s_cjrq
  AND a~kunag IN @s_kunnr
***************************************************
*&  Modified by  shuaige
*&  Date:   23.02.2022 08:59:43
*&  Description: 修改了发货日期取值逻辑后 这里的查询条件不在生效 将在处理数据时处理这个日期
*    AND b~aedat IN @s_fhrq
*&
***************************************************
    AND a~wadat_ist IN @s_pjrq
    AND b~matnr IN @s_matnr
    AND a~vkorg IN @s_vkorg
    AND b~vtweg IN @s_vtweg
    AND a~vbeln IN @s_vbeln
    AND b~werks IN @s_werks
    AND j~kunnr IN @s_ywy
    AND e~bzirk IN @s_bzirk
    AND a~lfart = 'LR'.
**************************************************
*&  Modified by  shuaige
*&  Date:   22.02.2022 14:54:04
*&  Description: 从物料凭证mseg表中 按照物料编号 批次 交货单号 查询出库日期
  SELECT vbeln_im AS vbeln,matnr,charg,cpudt_mkpf AS ckrq FROM mseg
    FOR ALL ENTRIES IN @gt_tab
    WHERE vbeln_im = @gt_tab-vbeln
    AND charg = @gt_tab-charg
    AND matnr = @gt_tab-matnr
    AND bwart = 'Z01'
    AND cpudt_mkpf IN @s_fhrq
    AND lgort = '9999' INTO TABLE @DATA(ckrq).
  SORT ckrq BY matnr charg vbeln.
*&
**************************************************



**2 将相关列取值由代码变为中文描述

**取订单类型字典
  SELECT auart,bezei AS ddlx  INTO TABLE @DATA(ddlx) FROM tvakt WHERE auart LIKE 'Z%' AND spras = '1'  .

**取运输方式字典
*  SELECT bezei, vsart INTO TABLE @DATA(ysfs) FROM t173t  WHERE  spras = '1'  .
*  LOOP AT ysfs  ASSIGNING FIELD-SYMBOL().
*    CLEAR gt_tab.
*    gt_tab-vsart_mc = -bezei.
*    "MODIFI 内表名 FROM 结构(如果同名,可以不要 FROM GT_TAB) TRANSPORTING 要修改的字段名 WHERE 字段名= 新值。
*    MODIFY gt_tab FROM gt_tab  TRANSPORTING vsart_mc WHERE vsart = -vsart.
*  ENDLOOP.
**取销售渠道字典
**SELECT  vtweg,  vtext INTO TABLE @DATA(xsqd)  FROM tvtwt   WHERE  spras = '1'.
*  查询渠道
  SELECT  vtweg,  vtext  INTO TABLE @DATA(vtweg1)  FROM tvtwt  WHERE  spras = '1'  .
  LOOP AT vtweg1  ASSIGNING FIELD-SYMBOL().
    CLEAR gt_tab.
    gt_tab-vtweg_mc = -vtext.
    "MODIFI 内表名 FROM 结构(如果同名,可以不要 FROM GT_TAB) TRANSPORTING 要修改的字段名 WHERE 字段名= 新值。
    MODIFY gt_tab FROM gt_tab  TRANSPORTING vtweg_mc WHERE vtweg = -vtweg.
  ENDLOOP.


**取销售组织
  SELECT  vkorg, vtext INTO TABLE @DATA(xszz)  FROM tvkot WHERE  spras = '1'    .
  LOOP AT xszz  ASSIGNING FIELD-SYMBOL().
    CLEAR gt_tab.
    gt_tab-vkorg = -vtext.
    MODIFY gt_tab FROM gt_tab  TRANSPORTING vkorg WHERE vkorg = -vkorg.
  ENDLOOP.

*  查询销售办公室
  SELECT  vkbur,  bezei  INTO TABLE @DATA(vkbur)   FROM tvkbt  WHERE  spras = '1'  .
  LOOP AT vkbur  ASSIGNING FIELD-SYMBOL().
    CLEAR gt_tab.
    gt_tab-vkbur_mc = -bezei.
    MODIFY gt_tab FROM gt_tab  TRANSPORTING vkbur_mc WHERE vkbur = -vkbur.
  ENDLOOP.

**  查询销售组
  SELECT  vkgrp,  bezei  INTO TABLE @DATA(vkgrp)  FROM tvgrt   WHERE  spras = '1'  .
  LOOP AT vkgrp  ASSIGNING FIELD-SYMBOL().
    CLEAR gt_tab.
    gt_tab-vkgrp_mc = -bezei.
    MODIFY gt_tab FROM gt_tab  TRANSPORTING vkgrp_mc WHERE vkgrp = -vkgrp.
  ENDLOOP.

**  查询销售地区
  SELECT   bzirk,  bztxt  INTO TABLE @DATA(bzirk)  FROM t171t  WHERE  spras = '1'  .
  LOOP AT bzirk  ASSIGNING FIELD-SYMBOL().
    CLEAR gt_tab.
    gt_tab-bzirk_mc = -bztxt.
    MODIFY gt_tab FROM gt_tab  TRANSPORTING bzirk_mc WHERE bzirk = -bzirk.
  ENDLOOP.
** 查询客户组(客?类型描述)
  SELECT kdgrp,ktext INTO TABLE @DATA(khlx) FROM t151t WHERE spras = '1'.
  LOOP AT khlx ASSIGNING FIELD-SYMBOL().
    CLEAR gt_tab.
    gt_tab-kdgrp_mc = -ktext.
    MODIFY gt_tab FROM gt_tab  TRANSPORTING kdgrp_mc WHERE kdgrp = -kdgrp.
  ENDLOOP.

**2 处理单价、主数量等其它辅助信息
  SORT gt_tab BY vbeln ASCENDING.
  DELETE  gt_tab  WHERE lfimg = 0 .
  DATA index LIKE sy-tabix.
  LOOP AT gt_tab .
    index = sy-tabix.
**************************************************
*&  Modified by  shuaige
*&  Date:   22.02.2022 15:01:30
*&  Description:添加出库日期
    READ TABLE ckrq INTO DATA(wa_ckrq) WITH  KEY matnr = gt_tab-matnr charg = gt_tab-charg vbeln = gt_tab-vbeln BINARY SEARCH.
    IF sy-subrc = 0.
      gt_tab-aedat = wa_ckrq-ckrq.
*     发货日期不在查询条件范围内 直接删除即可  注意这里如果没有按照出库日期筛选 就不能从表里删除数据
      IF s_fhrq IS NOT  INITIAL AND gt_tab-aedat NOT IN s_fhrq.
        DELETE gt_tab[].
        CONTINUE.
      ENDIF.
    ELSE.
*  注意这里如果没有按照出库日期筛选 就不能从表里删除数据
      IF s_fhrq IS NOT  INITIAL.
        DELETE gt_tab[].
        CONTINUE.
      ENDIF.

    ENDIF.
*&
**************************************************

    gt_tab-hsdj = gt_tab-netwr / gt_tab-kwmeng.   "用销售金额 除以 订单数量,得到 含税单价
    IF gt_tab-lfart = 'LR'.
      gt_tab-lfimg =  gt_tab-lfimg * -1.
      gt_tab-netwr =  gt_tab-netwr * -1.
    ENDIF.

    gt_tab-hsje = gt_tab-lfimg * gt_tab-hsdj.  "用交货数量* 订单的含税单价
    IF gt_tab-umvkz > 1.
      gt_tab-zsl = gt_tab-lfimg * gt_tab-umrez."转换为最小包装数
    ENDIF.
    IF gt_tab-umrez <> 0 .
      gt_tab-fzsl = gt_tab-zsl / gt_tab-umrez."转换为标准件包装数
    ENDIF .


    "去掉前导000
    SHIFT gt_tab-kunnr LEFT DELETING LEADING '0'.
    SHIFT gt_tab-vbeln LEFT DELETING LEADING '0'.
    SHIFT gt_tab-matnr LEFT DELETING LEADING '0'.
    SHIFT gt_tab-ddbh LEFT DELETING LEADING '0'.
    SHIFT gt_tab-rybh LEFT DELETING LEADING '0'.
    MODIFY gt_tab INDEX index.
  ENDLOOP.


**删除重复行项目
  SORT gt_tab ASCENDING BY vbeln posnr.
  DELETE  gt_tab  WHERE lfimg = 0 .

END-OF-SELECTION.

**执行函数
  PERFORM frm_show_alv.


* 输出 alv 报表
FORM frm_show_alv .

  DEFINE append_alv_field.
    CLEAR g_line.
    g_line-fieldname    = &1.
    g_line-tabname      = 'GT_ALV'.
    g_line-reptext_ddic = &2.
    g_line-seltext_l    = &2.
    g_line-seltext_m    = &2.
    g_line-seltext_s    = &2.
    g_line-cfieldname   = &3.
    g_line-ctabname     = &4.
    g_line-no_out       = &5.
    g_line-no_zero      = &6.
    g_line-outputlen    = &7.
    g_line-qfieldname   = &8.
    g_line-just         = &9.
    g_line-ddictxt      = 'L'.
    g_line-do_sum       = 'X'.
    IF  g_line-fieldname = 'LFIMG'. "如果字段名为LFIMG,则将小数位设置为0,其它的设置为2位
      g_line-decimals_out       = '0'. "去掉小数点后的0
     ELSE.
       g_line-decimals_out       = '2'. "去掉小数点后的0
    ENDIF.

    APPEND g_line TO gt_fieldcat.
  END-OF-DEFINITION.


**ALV 显示字段
  REFRESH:gt_fieldcat.
  gt_layout-colwidth_optimize = 'X'. " 自适应宽度
  append_alv_field 'WERKS' '工厂' '' '' '' '' '' '' ''.
  append_alv_field 'VKORG' '销售组织' '' '' '' '' '' '' ''.
  append_alv_field 'VTWEG' '渠道' '' '' '' '' '' '' ''.
  append_alv_field 'VTWEG_MC' '渠道名称' '' '' '' '' '' '' ''.
  append_alv_field 'ERDAT' '创建日期' '' '' '' '' '' '' ''.
  append_alv_field 'AEDAT' '发货日期' '' '' '' '' '' '' ''.
  append_alv_field 'WADAT_IST' '票据日期' '' '' '' '' '' '' ''.
  append_alv_field 'VBELN' '交货单号' '' '' '' '' '' '' ''.
  append_alv_field 'RYBH' '业务员号' '' '' '' '' '' '' ''.
  append_alv_field 'RYXM' '业务员姓名' '' '' '' '' '' '' ''.
  append_alv_field 'KUNNR' '客户号' '' '' '' '' '' '' ''.
  append_alv_field 'NAME1' '客户名称' '' '' '' '' '' '' ''.
  append_alv_field 'MATNR' '物料号' '' '' '' '' '' '' ''.
  append_alv_field 'MAKTX' '物料描述' '' '' '' '' '' '' ''.
  append_alv_field 'CHARG' '批号' '' '' '' '' '' '' ''.
  append_alv_field 'LFART' '类型' '' '' '' '' '' '' ''.
  append_alv_field 'LFIMG' '交货数量' '' '' '' '' '' '' ''.
  append_alv_field 'ZSL' '主数量' '' '' '' '' '' '' ''.
  append_alv_field 'FZSL' '辅助数量' '' '' '' '' '' '' ''.

  append_alv_field 'HSDJ' '单价' '' '' '' '' '' '' ''.
  append_alv_field 'HSJE' '金额' '' '' '' '' '' '' ''.
  append_alv_field 'NETWR' '订单金额' '' '' '' '' '' '' ''.
  append_alv_field 'KWMENG' '订单数量' '' '' '' '' '' '' ''.
  append_alv_field 'VTWEG' '行项目' '' '' '' '' '' '' ''.
  append_alv_field 'DDBH' '订单号' '' '' '' '' '' '' ''.
  append_alv_field 'KDGRP' '客户类型' '' '' '' '' '' '' ''.
  append_alv_field 'KDGRP_MC' '客户类型名称' '' '' '' '' '' '' ''.
  append_alv_field 'VKBUR' '销售办公室' '' '' '' '' '' '' ''.
  append_alv_field 'VKBUR_MC' '销售办名称' '' '' '' '' '' '' ''.
  append_alv_field 'VKGRP' '销售组' '' '' '' '' '' '' ''.
  append_alv_field 'VKGRP_MC' '销售组名称' '' '' '' '' '' '' ''.
  append_alv_field 'BZIRK' '销售地区号' '' '' '' '' '' '' ''.
  append_alv_field 'BZIRK_MC' '销售地区' '' '' '' '' '' '' ''.
  append_alv_field 'ZZBUSIN' '事业部' '' '' '' '' '' '' ''.
  append_alv_field 'ZZPRODUCST' '生产企业' '' '' '' '' '' '' ''.
  append_alv_field 'ZZABCCAT' 'ABC分类' '' '' '' '' '' '' ''.
  append_alv_field 'VSART' '运输方式1' '' '' '' '' '' '' ''.
  append_alv_field 'VSART_MC' '运输方式' '' '' '' '' '' '' ''.
  append_alv_field 'UMREZ' '件数量' '' '' '' '' '' '' ''.
  append_alv_field 'WGBEZ' '物料组' '' '' '' '' '' '' ''.
  append_alv_field 'ZZDOSAGE_DESC' '剂型' '' '' '' '' '' '' ''.
  append_alv_field 'EWBEZ' '治疗领域' '' '' '' '' '' '' ''.
  append_alv_field 'VTEXT' '产品类别' '' '' '' '' '' '' ''.


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program = sy-repid
*     i_callback_pf_status_set = 'FRM_STATUS'   "GUI指定子程序
*     i_callback_user_command  = 'FRM_USER_COMM' "客户命令指定子程序
      is_layout          = gt_layout
      it_fieldcat        = gt_fieldcat[]
*     it_events          = events[]
    TABLES
      t_outtab           = gt_tab[] "指定要显示的内表名称
    EXCEPTIONS
      program_error      = 1
      OTHERS             = 2.


ENDFORM.
SAP