*&---------------------------------------------------------------------
*& Program name:
*& T-Code:
*& Porgram Type: Report
*& Description: 订单状
*&----------------------------------------------------------------------
*& Modification Log:
*& Version Date Author DESCRIPTION CHANGE REQUEST
* 2016/3/31
REPORT zsdr017 NO STANDARD PAGE HEADING MESSAGE-ID oo.
*----------------------------------------------------------------------*
* INCLUDE *
*----------------------------------------------------------------------*
"TYPES:vbfa.
TYPE-POOLS: slis.
*----------------------------------------------------------------------*
* CONSTANTS *
*----------------------------------------------------------------------*
"CONSTANTS: c_s TYPE bapi_mtype VALUE 'S'.
*----------------------------------------------------------------------*
* TYPES *
*----------------------------------------------------------------------*
TYPES: BEGIN OF typ_vbap ,
erdat TYPE vbak-erdat,
vdatu TYPE vbak-vdatu , "交货日期
vbeln TYPE vbak-vbeln,
kunnr TYPE vbak-kunnr,
vkorg TYPE vbak-vkorg,
vtweg TYPE vbak-vtweg,
spart TYPE vbak-spart,
spart2 TYPE vbap-spart,
bzirk TYPE vbkd-bzirk, "销售部
"route LIKE vttk-route, "路线
vkgrp TYPE vbak-vkgrp,
vkbur TYPE vbak-vkbur,
bstnk TYPE vbak-bstnk,
erzet TYPE vbak-erzet,
posnr TYPE vbap-posnr,
pstyv TYPE vbap-pstyv, "
matnr TYPE vbap-matnr,
arktx TYPE vbap-arktx,
werks TYPE vbap-werks,
* lgort type vbap-lgort ,
kwmeng TYPE vbap-kwmeng,
vrkme TYPE vbap-vrkme,
netwr TYPE vbap-netwr,
mwsbp TYPE vbap-mwsbp,
umvkz TYPE vbap-umvkz,
umvkn TYPE vbap-umvkn,
meins TYPE vbap-meins,
klmeng TYPE vbap-klmeng,
kdmat TYPE vbap-kdmat, "客户物料编码
kdmat_quan TYPE vbap-kwmeng,
auart TYPE vbak-auart, "订单类型
matkl TYPE vbap-matkl, "物料组
ztext TYPE string, "行项目长文本
* ------20120312修改------
vstel TYPE vbap-vstel, "装运点
* 20120406修改
rise_text TYPE tdline, "抬头文本
so_text TYPE tdline, "抬头文本
eannr LIKE vbap-eannr,
knumv LIKE vbak-knumv,
END OF typ_vbap .
TYPES: BEGIN OF typ_output.
INCLUDE TYPE typ_vbap.
TYPES: zsel TYPE c, "选择标识
name1_kna1 TYPE kna1-name1, "客户名称
bzirk_txt TYPE tvkbt-bezei, "销售部描述
route_txt LIKE tvkbt-bezei,
pstyv_txt LIKE tvapt-vtext, "行项目类型描述
bezei_tvkbt TYPE tvkbt-bezei, "销售大区描述
bezei_tvgrt TYPE tvgrt-bezei, "销售办事处描述
kunnr_we TYPE vbpa-kunnr, " 送达方代码
name1_we TYPE adrc-name1, " 送达方名称
name1_t001w TYPE t001w-name1, "工厂名称
lgobe TYPE t001l-lgobe, "库存名称
zdj TYPE vbap-netwr, "含税单价--销售单位
zsl_base TYPE vbap-kwmeng, "基本单位数量
zdj_base TYPE vbap-netwr, "含税单价--基本单位
absta TYPE vbup-absta, "so项目状态
zabsta_des TYPE char10, "拒绝状态描述
kdgrp TYPE knvv-kdgrp, "客户组
ktext TYPE t151t-ktext, "客户组描述
dmbtr LIKE bseg-dmbtr, "新增金额字段
"PO采购订单信息
ebeln_po TYPE ekko-ebeln,
aedat_po TYPE ekko-aedat,
ebelp_po TYPE ekpo-ebelp,
menge_po TYPE ekpo-menge, "数量
netpr_po TYPE ekpo-netpr, "净价
meins_po TYPE ekpo-meins, "单位
"PO对应的收货单GR
mblnr_po_gr TYPE mseg-mblnr,
zeile_po_gr TYPE mseg-zeile,
menge_po_gr TYPE mseg-menge,
meins_po_gr TYPE mseg-meins,
"PO对应的发票校验单
belnr_po_ir TYPE rseg-belnr,
buzei_po_ir TYPE rseg-buzei,
menge_po_ir TYPE rseg-menge,
meins_po_ir TYPE rseg-meins,
"DN交货单信息
vbeln_dn TYPE lips-vbeln,
route LIKE vttk-route, "路线描述
posnr_dn TYPE lips-posnr,
charg_dn TYPE lips-charg,
lgmng_dn TYPE lips-lgmng,
meins_dn TYPE lips-meins,
bolnr TYPE likp-bolnr, "车牌号
bezei TYPE tvakt-bezei, "订单类型
wgbez TYPE t023t-wgbez, "物料组
devlv TYPE lips-lgmng, "交货率
* werks type lips-werks,
lgort TYPE lips-lgort,
posnr_dn_chai TYPE lips-posnr, "交货单拆分
charg_dn_chai TYPE lips-charg,
lgmng_dn_chai TYPE lips-lgmng,
meins_dn_chai TYPE lips-meins,
"DN对应的收货单GR
mblnr_dn_gr TYPE mseg-mblnr,
zeile_dn_gr TYPE mseg-zeile,
menge_dn_gr TYPE mseg-menge,
meins_dn_gr TYPE mseg-meins,
"DN对应的开票凭证
vbeln_dn_bl TYPE vbrp-vbeln,
posnr_dn_bl TYPE vbrp-posnr,
fkimg_dn_bl TYPE vbrp-fkimg,
vrkme_dn_bl TYPE vbrp-vrkme,
erdat_likp LIKE likp-erdat, "新加四个字段,用于过滤屏幕
erzet_likp LIKE likp-erzet,
cpudt LIKE mkpf-cpudt,
cputm LIKE mkpf-cputm,
ddlx TYPE string,
erzet_fp LIKE vbrk-erzet,
erdat_fp LIKE vbrk-erdat,
zh_kwert LIKE konv-kwert,
zj_kwert LIKE konv-kwert,
fy_kwert LIKE konv-kwert.
TYPES: END OF typ_output.
TYPES: BEGIN OF typ_m_mbmps ,
smbln TYPE m_mbmps-smbln,
sjahr TYPE m_mbmps-sjahr,
smblp TYPE m_mbmps-smblp,
mjahr TYPE m_mbmps-mjahr,
zeile TYPE m_mbmps-zeile,
mblnr TYPE m_mbmps-mblnr,
END OF typ_m_mbmps .
TYPES: BEGIN OF typ_kna1 ,
kunnr TYPE kna1-kunnr,
name1 TYPE kna1-name1,
END OF typ_kna1 .
TYPES: BEGIN OF typ_tvkbt ,
vkbur TYPE tvkbt-vkbur,
bezei TYPE tvkbt-bezei,
END OF typ_tvkbt .
TYPES: BEGIN OF typ_tvgrt ,
vkgrp TYPE tvgrt-vkgrp,
bezei TYPE tvgrt-bezei,
END OF typ_tvgrt .
TYPES: BEGIN OF typ_t001w ,
werks TYPE t001w-werks,
name1 TYPE t001w-name1,
END OF typ_t001w .
TYPES: BEGIN OF typ_t001l ,
werks TYPE t001l-werks,
lgort TYPE t001l-lgort,
lgobe TYPE t001l-lgobe,
END OF typ_t001l .
TYPES: BEGIN OF typ_vbup ,
vbeln TYPE vbup-vbeln,
posnr TYPE vbup-posnr,
absta
TYPE vbup-absta,
END OF typ_vbup .
TYPES: BEGIN OF typ_vbfa_so ,
vbelv
TYPE vbfa-vbelv,
posnv
TYPE vbfa-posnv,
vbeln
TYPE vbfa-vbeln,
posnn
TYPE vbfa-posnn,
posnn_5
TYPE ekpo-ebelp,
vbtyp_n
TYPE vbfa-vbtyp_n,
erdat
TYPE vbfa-erdat,
erzet
TYPE vbfa-erzet,
rfmng
TYPE vbfa-rfmng,
rfwrt
TYPE vbfa-rfwrt,
meins
TYPE vbfa-meins,
END OF typ_vbfa_so .
TYPES: BEGIN OF typ_ekbe ,
ebeln
TYPE ekbe-ebeln,
ebelp
TYPE ekbe-ebelp,
zekkn
TYPE ekbe-zekkn,
vgabe
TYPE ekbe-vgabe,
gjahr
TYPE ekbe-gjahr,
belnr
TYPE ekbe-belnr,
buzei
TYPE ekbe-buzei,
buzei_6
TYPE rseg-buzei,
END OF typ_ekbe .
TYPES: BEGIN OF typ_mseg_po ,
mblnr
TYPE mseg-mblnr,
mjahr
TYPE mseg-mjahr,
zeile
TYPE mseg-zeile,
menge
TYPE mseg-menge,
meins
TYPE mseg-meins,
END OF typ_mseg_po .
TYPES: BEGIN OF typ_rseg ,
belnr
TYPE rbkp-belnr,
gjahr
TYPE rbkp-gjahr,
buzei
TYPE rseg-buzei,
menge
TYPE rseg-menge,
meins
TYPE rseg-meins,
END OF typ_rseg .
TYPES: BEGIN OF typ_lips ,
vbeln
TYPE lips-vbeln,
posnr
TYPE lips-posnr,
charg
TYPE lips-charg,
lgmng
TYPE lips-lgmng,
meins
TYPE lips-meins,
uecha
TYPE lips-uecha,
* werks type lips-werks,
lgort
TYPE lips-lgort,
* 车牌号
bolnr
TYPE likp-bolnr,
erdat_likp
LIKE likp-erdat, "新加四个字段,用于过滤屏幕
erzet_likp
LIKE likp-erzet,
END OF typ_lips .
TYPES: BEGIN OF typ_vbfa_dn ,
vbelv
TYPE vbfa-vbelv,
posnv
TYPE vbfa-posnv,
vbeln
TYPE vbfa-vbeln,
posnn
TYPE vbfa-posnn,
posnn_4
TYPE mseg-zeile,
vbtyp_n
TYPE vbfa-vbtyp_n,
mjahr
TYPE vbfa-mjahr,
plmin
TYPE vbfa-plmin,
END OF typ_vbfa_dn .
TYPES: BEGIN OF typ_mseg_dn ,
mblnr
TYPE mseg-mblnr,
mjahr
TYPE mseg-mjahr,
zeile
TYPE mseg-zeile,
menge
TYPE mseg-menge,
meins
TYPE mseg-meins,
cpudt
LIKE mkpf-cpudt,
cputm
LIKE mkpf-cputm,
END OF typ_mseg_dn .
TYPES: BEGIN OF typ_vbrp ,
vkorg
TYPE vbrk-vkorg,
kunag
TYPE vbrk-kunag,
vbeln
TYPE vbrp-vbeln,
posnr
TYPE vbrp-posnr,
fkimg
TYPE vbrp-fkimg,
vrkme
TYPE vbrp-vrkme,
erzet
TYPE vbrk-erzet,
erdat
TYPE vbrk-erdat,
END OF typ_vbrp .
TYPES: BEGIN OF typ_vbpa ,
vbeln
TYPE vbpa-vbeln,
posnr
TYPE vbpa-posnr,
parvw
TYPE vbpa-parvw,
kunnr
TYPE vbpa-kunnr,
adrnr
TYPE vbpa-adrnr,
END OF typ_vbpa .
TYPES: BEGIN OF typ_adrc ,
addrnumber
TYPE adrc-addrnumber,
date_from
TYPE adrc-date_from,
nation
TYPE adrc-nation,
name1
TYPE adrc-name1,
street
TYPE adrc-street,
END OF typ_adrc .
TYPES: BEGIN OF typ_knvv ,
kunnr
TYPE knvv-kunnr,
vkorg
TYPE knvv-vkorg,
vtweg
TYPE knvv-vtweg,
spart
TYPE knvv-spart,
kdgrp
TYPE knvv-kdgrp,
END OF typ_knvv .
TYPES: BEGIN OF typ_t151t ,
kdgrp
TYPE t151t-kdgrp,
ktext
TYPE t151t-ktext,
END OF typ_t151t .
DATA: BEGIN OF git_tvak OCCURS 0,
auart
LIKE tvakt-auart,
bezei
LIKE tvakt-bezei,
END OF git_tvak.
DATA: BEGIN OF git_t023 OCCURS 0,
matkl
LIKE t023-matkl,
wgbez
LIKE t023t-wgbez,
END OF git_t023.
DATA:BEGIN OF gwa_konv,
knumv
LIKE konv-knumv,
kposn
LIKE konv-kposn,
kwert
LIKE konv-kwert,
kschl
LIKE konv-kschl,
END OF gwa_konv.
DATA:git_konv LIKE gwa_konv OCCURS 0 WITH HEADER LINE.
*----------------------------------------------------------------------*
* DATA *
*----------------------------------------------------------------------*
DATA: git_output TYPE TABLE OF typ_output,
gwa_output
TYPE typ_output,
git_vbrp
TYPE TABLE OF typ_vbrp,
gwa_vbrp
TYPE typ_vbrp,
git_mseg_dn
TYPE TABLE OF typ_mseg_dn,
gwa_mseg_dn
TYPE typ_mseg_dn,
git_m_mbmps_po
TYPE TABLE OF typ_m_mbmps,
gwa_m_mbmps_po
TYPE typ_m_mbmps,
git_m_mbmps_dn
TYPE TABLE OF typ_m_mbmps,
gwa_m_mbmps_dn
TYPE typ_m_mbmps,
git_vbfa_dn
TYPE TABLE OF typ_vbfa_dn WITH HEADER LINE,
tmp_git_vbfa_dn
TYPE TABLE OF typ_vbfa_dn WITH HEADER LINE,
gwa_vbfa_dn
TYPE typ_vbfa_dn,
git_lips
TYPE TABLE OF typ_lips,
gwa_lips
TYPE typ_lips,
gwa_lips_chai
TYPE typ_lips,
git_rseg
TYPE TABLE OF typ_rseg,
gwa_rseg
TYPE typ_rseg,
git_mseg_po
TYPE TABLE OF typ_mseg_po,
gwa_mseg_po
TYPE typ_mseg_po,
git_ekbe
TYPE TABLE OF typ_ekbe,
gwa_ekbe
TYPE typ_ekbe,
git_vbfa_so
TYPE TABLE OF typ_vbfa_so WITH HEADER LINE,
gwa_vbfa_so
TYPE typ_vbfa_so,
git_vbup
TYPE TABLE OF typ_vbup,
gwa_vbup
TYPE typ_vbup,
git_t001l
TYPE TABLE OF typ_t001l,
gwa_t001l
TYPE typ_t001l,
git_t001w
TYPE TABLE OF typ_t001w,
gwa_t001w
TYPE typ_t001w,
git_tvgrt
TYPE TABLE OF typ_tvgrt,
gwa_tvgrt
TYPE typ_tvgrt,
git_tvkbt
TYPE TABLE OF typ_tvkbt,
gwa_tvkbt
TYPE typ_tvkbt,
git_kna1
TYPE TABLE OF typ_kna1,
gwa_kna1
TYPE typ_kna1,
git_vbap
TYPE TABLE OF typ_vbap,
gwa_vbap
TYPE typ_vbap,
git_adrc
TYPE TABLE OF typ_adrc,
gwa_adrc
TYPE typ_adrc,
git_vbpa
TYPE TABLE OF typ_vbpa,
gwa_vbpa
TYPE typ_vbpa,
git_t151t
TYPE TABLE OF typ_t151t,
gwa_t151t
TYPE typ_t151t,
git_knvv
TYPE TABLE OF typ_knvv,
gwa_knvv
TYPE typ_knvv.
*---for selection-screen
DATA: BEGIN OF gwa_screen,
erdat
TYPE vbak-erdat, "创建日期
vbeln
TYPE vbak-vbeln, "销售订单编号
auart
TYPE vbak-auart, "销售订单类型
kunnr
TYPE vbak-kunnr, " 客户代码
vkorg
TYPE vbak-vkorg, " 销售组织
vtweg
TYPE vbak-vtweg, " 分销渠道
spart
TYPE vbak-spart, " 产品组
bzirk
TYPE vbkd-bzirk, "销售部
route
LIKE vttk-route, "路线
route_txt
LIKE tvrot-bezei, "路线描述
vkbur
TYPE vbak-vkbur, " 销售大区
vkgrp
TYPE vbak-vkgrp, " 销售办事处
bstnk
TYPE vbak-bstnk, "客户采购订单编号
matnr
TYPE vbap-matnr, " 物料号
pstyv
TYPE vbap-pstyv, "行项目类型
werks
TYPE vbap-werks, " 交货工厂
lgort
TYPE vbap-lgort, " 库存地
vstel
TYPE vbap-vstel, " 装载点
matkl
TYPE vbap-matkl, "物料组
vbeln_dn
TYPE lips-vbeln, "交货单号
vbeln_dn_bl
TYPE vbrp-vbeln, "开票号
audat
TYPE vbak-audat, "订单日期
END OF gwa_screen.
*---for alv
DATA: gwa_layout TYPE slis_layout_alv,
git_field
TYPE slis_t_fieldcat_alv,
gwa_field
LIKE LINE OF git_field,
git_sort
TYPE slis_t_sortinfo_alv,
gwa_sort
LIKE LINE OF git_sort,
g_grid_title
TYPE lvc_title,
go_gui_alv_grid
TYPE REF TO cl_gui_alv_grid.
*----------------------------------------------------------------------*
* SCREEN DECLARATION: PARAMETERS & SELECT-OPTIONS *
*----------------------------------------------------------------------*
TABLES: knvv,likp,mkpf,vbfa .
SELECTION-SCREEN: BEGIN OF BLOCK b01 WITH FRAME TITLE text-t01.
SELECT-OPTIONS:
s_erdat
FOR gwa_screen-erdat OBLIGATORY ,"订单创建日期
" s_audat FOR gwa_screen-audat, "单据日期
s_vbeln
FOR gwa_screen-vbeln,"销售订单编号
s_auart
FOR gwa_screen-auart,"销售订单类型
s_kunnr
FOR gwa_screen-kunnr,"客户代码
s_kunnr2
FOR gwa_screen-kunnr,"送达方代码
s_vkorg
FOR gwa_screen-vkorg,"销售组织
s_vtweg
FOR gwa_screen-vtweg,"分销渠道
" s_spart FOR gwa_screen-spart OBLIGATORY,"产品组
" s_kdgrp FOR knvv-kdgrp,"客户组
s_bzirk
FOR gwa_screen-bzirk,"销售部
s_vkbur
FOR gwa_screen-vkbur,"销售大区
s_vkgrp
FOR gwa_screen-vkgrp,"销售办事处
s_bstnk
FOR gwa_screen-bstnk,"客户采购订单编号
s_matnr
FOR gwa_screen-matnr,"物料号
s_pstyv
FOR gwa_screen-pstyv,"行项目类型
s_matkl
FOR gwa_screen-matkl,"物料组
s_werks
FOR gwa_screen-werks,"交货工厂
" s_lgort FOR gwa_screen-lgort,"库存地
s_vstel
FOR gwa_screen-vstel,"装载点 “20120312增加
s_vbeln2
FOR gwa_screen-vbeln_dn,"交货单号
s_vbeln3
FOR gwa_screen-vbeln_dn_bl,"开票凭证号
s_vbelns
FOR vbfa-vbeln,
erdat1
FOR likp-erdat,"交货单创建日期
erzet1
FOR likp-erzet,"交货单创建时间
cpudt
FOR mkpf-cpudt,"发货过账日期
cputm
FOR mkpf-cputm."发货过账时间
PARAMETER: p_flag TYPE c AS CHECKBOX DEFAULT 'X'."不显示采购订单
"PARAMETER: p_bl TYPE c AS CHECKBOX."不显示公司间开票
PARAMETER: p_del TYPE c AS CHECKBOX DEFAULT 'X'."删除DN总数量是0的交货单
"PARAMETER: p_th TYPE c AS CHECKBOX . "48小时订单
"PARAMETER: p_one TYPE c AS CHECKBOX.
SELECTION-SCREEN SKIP 1.
PARAMETER: r_1 TYPE c RADIOBUTTON GROUP rg1.
PARAMETER: r_2 TYPE c RADIOBUTTON GROUP rg1.
PARAMETER: r_3 TYPE c RADIOBUTTON GROUP rg1 DEFAULT 'X'.
SELECTION-SCREEN: END OF BLOCK b01.
*----------------------------------------------------------------------*
* DEFINE *
*----------------------------------------------------------------------*
DEFINE m_alv_fieldcat.
GWA_FIELD
-FIELDNAME = &1."字段名称
GWA_FIELD
-OUTPUTLEN = &2."输出长度
GWA_FIELD
-REPTEXT_DDIC = &3.
GWA_FIELD
-EDIT = &4."是否编辑
GWA_FIELD
-CHECKBOX = &5."复选框
GWA_FIELD
-REF_FIELDNAME = &6.
GWA_FIELD
-REF_TABNAME = &7.
GWA_FIELD
-KEY = &8.
GWA_FIELD
-NO_ZERO = &9.
* WA_FIELD-EMPHASIZE = 'X'.
* WA_FIELD-just = ''.
* WA_FIELD-datatype = 'X'.
* WA_FIELD-REPTEXT_DDIC = &9.
* WA_FIELD-NO_OUT = &9.
* WA_FIELD-COL_POS = &10.
* WA_FIELD-CHECKBOX = &9.
* WA_FIELD-HOTSPOT = &9.
APPEND GWA_FIELD TO GIT_FIELD.
CLEAR GWA_FIELD.
END-OF-DEFINITION.
*----------------------------------------------------------------------*
* INITIALIZATION *
*----------------------------------------------------------------------*
INITIALIZATION.
PERFORM frm_initialization.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN OUTPUT *
*----------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
PERFORM frm_modify_screen.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN *
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
PERFORM frm_check_input.
*----------------------------------------------------------------------*
* START-OF-SELECTION *
*----------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM frm_retrive_data."get data
PERFORM frm_process_data."process data
PERFORM frm_process_data1."process data
*----------------------------------------------------------------------*
* END-OF-SELECTION *
*----------------------------------------------------------------------*
END-OF-SELECTION.
PERFORM frm_output.
*&---------------------------------------------------------------------*
*& Form frm_initialization
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_initialization .
*---将订单日期初始化为当月
DATA: lwa_erdat LIKE LINE OF s_erdat.
lwa_erdat
-sign = 'I'.
lwa_erdat
-option = 'BT'.
"lwa_erdat-high = sy-datum.
CONCATENATE sy-datum+0(6) '01' INTO lwa_erdat-low.
APPEND lwa_erdat TO s_erdat.
ENDFORM. " frm_initialization
*&---------------------------------------------------------------------*
*& Form frm_modify_screen
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_modify_screen .
ENDFORM. " frm_modify_screen
*&---------------------------------------------------------------------*
*& Form frm_check_input
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_check_input .
ENDFORM. " frm_check_input
*&---------------------------------------------------------------------*
*& Form frm_retrive_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_retrive_data .
DATA: lc_tabix TYPE sy-tabix.
*---get 1. 销售订单信息
SELECT vbak~erdat
vbak
~vdatu
vbak
~vbeln
vbak
~kunnr
vbak
~vkorg"销售组织
vbak
~vtweg
* vbak~spart
vbak
~vkgrp"销售办事处
vbak
~vkbur
vbak
~bstnk"客户采购订单编号
vbak
~erzet "add by yk
vbap
~spart AS spart2
vbap
~posnr
vbap
~matnr
vbap
~arktx
vbap
~werks
"vbap~lgort
vbap
~kwmeng"数量
vbap
~vrkme
vbap
~netwr"总净值-item
vbap
~mwsbp"总税额-item
vbap
~umvkz"分子
vbap
~umvkn"分母
vbap
~meins
"2011-1-2 添加
vbap
~kdmat "红白条头数
vbak
~auart "订单类型
vbap
~matkl "物料组
* ------20120312修改--------------
vbap
~vstel "装载点
vbap
~eannr
vbap
~pstyv
vbak
~knumv
vbkd
~bzirk
INTO CORRESPONDING FIELDS OF TABLE git_vbap
FROM vbak
INNER
JOIN vbap ON vbak~vbeln = vbap~vbeln
INNER
JOIN vbkd ON vbak~vbeln = vbkd~vbeln" AND vbap~posnr = vbkd~posnr
WHERE vbak~erdat IN s_erdat
"AND vbak~audat IN s_audat
AND vbak~vbeln IN s_vbeln
AND vbak~auart IN s_auart
AND vbak~kunnr IN s_kunnr
AND vbak~vkorg IN s_vkorg
AND vbak~vtweg IN s_vtweg
"AND vbak~spart IN s_spart
AND vbak~vkbur IN s_vkbur
AND vbak~vkgrp IN s_vkgrp
AND vbak~bstnk IN s_bstnk
AND vbap~matnr IN s_matnr
AND vbap~pstyv IN s_pstyv
AND vbkd~bzirk IN s_bzirk
AND vbap~werks IN s_werks
"AND vbap~lgort IN s_lgort
AND vbap~matkl IN s_matkl
AND vbap~vstel IN s_vstel.
SORT git_vbap BY vbeln.
DELETE ADJACENT DUPLICATES FROM git_vbap.
*---权限检查
DATA: BEGIN OF gt_t001w OCCURS 0,
werks
LIKE t001w-werks,
vkorg
LIKE t001w-vkorg,
END OF gt_t001w.
IF NOT git_vbap IS INITIAL.
SELECT werks vkorg INTO CORRESPONDING FIELDS OF TABLE gt_t001w
FROM t001w
FOR ALL ENTRIES IN git_vbap
WHERE werks = git_vbap-werks.
SORT gt_t001w BY werks.
ENDIF.
* LOOP AT git_vbap INTO gwa_vbap.
* lc_tabix = sy-tabix.
* "对销售办事处进行检查
* AUTHORITY-CHECK OBJECT 'Z_SD_VKGRP'
* ID 'VKGRP' FIELD gwa_vbap-vkgrp.
* IF sy-subrc <> 0.
* DELETE git_vbap INDEX lc_tabix.
* CONTINUE.
* ENDIF.
*
**---权限检查1.1
* AUTHORITY-CHECK OBJECT 'V_VBAK_VKO'
* ID 'VKORG' FIELD gwa_vbap-vkorg
* ID 'VTWEG' DUMMY
* ID 'SPART' DUMMY"FIELD "gwa_vbap-spart
* ID 'ACTVT' FIELD '03'.
* IF sy-subrc <> 0.
* DELETE git_vbap INDEX lc_tabix.
* CONTINUE.
* ENDIF.
*
* ENDLOOP.
**---权限检查1.2
* AUTHORITY-CHECK OBJECT 'V_VBAK_VKO'
* ID 'VKORG' FIELD gwa_vbap-vkorg
* ID 'VTWEG' DUMMY
* ID 'SPART' FIELD gwa_vbap-spart2 "行项目
* ID 'ACTVT' FIELD '03'.
* IF sy-subrc <> 0.
**---权限检查2.1
* READ TABLE gt_t001w WITH KEY werks = gwa_vbap-werks BINARY SEARCH.
* IF sy-subrc = 0.
* AUTHORITY-CHECK OBJECT 'V_VBAK_VKO'
* ID 'VKORG' FIELD gt_t001w-vkorg
* ID 'VTWEG' DUMMY
* ID 'SPART' FIELD gwa_vbap-spart
* ID 'ACTVT' FIELD '03'.
* IF sy-subrc <> 0.
**---权限检查2.2
* AUTHORITY-CHECK OBJECT 'V_VBAK_VKO'
* ID 'VKORG' FIELD gt_t001w-vkorg
* ID 'VTWEG' DUMMY
* ID 'SPART' FIELD gwa_vbap-spart2 "行项目
* ID 'ACTVT' FIELD '03'.
* IF sy-subrc <> 0.
* DELETE git_vbap INDEX lc_tabix.
* CONTINUE.
* ENDIF.
* ENDIF.
* ELSE.
* "没有读到数据,删除
* DELETE git_vbap INDEX lc_tabix.
* CONTINUE.
* ENDIF.
* ENDIF.
* ENDIF.
IF git_vbap IS NOT INITIAL.
*--取折扣价值
SELECT knumv kposn kwert kschl INTO TABLE git_konv FROM konv FOR ALL ENTRIES IN git_vbap
WHERE knumv = git_vbap-knumv AND kposn = git_vbap-posnr AND kschl IN ( 'ZB03','ZB04','ZB07' ).
*---物料组描述
SELECT matkl
wgbez
INTO CORRESPONDING FIELDS OF TABLE git_t023
FROM t023t
FOR ALL ENTRIES IN git_vbap
WHERE matkl = git_vbap-matkl
AND spras = sy-langu.
*---订单类型
SELECT auart
bezei
INTO CORRESPONDING FIELDS OF TABLE git_tvak
FROM tvakt
FOR ALL ENTRIES IN git_vbap
WHERE auart = git_vbap-auart
AND spras = sy-langu.
*---get 客户组
SELECT kunnr
vkorg
vtweg
spart
kdgrp
INTO CORRESPONDING FIELDS OF TABLE git_knvv
FROM knvv
FOR ALL ENTRIES IN git_vbap
WHERE kunnr = git_vbap-kunnr
AND vkorg = git_vbap-vkorg
AND vtweg = git_vbap-vtweg
AND spart = '00'.
IF git_knvv IS NOT INITIAL.
*---get 客户组描述
SELECT kdgrp
ktext
INTO CORRESPONDING FIELDS OF TABLE git_t151t
FROM t151t
WHERE spras = sy-langu.
ENDIF.
*---get 送达方
SELECT vbeln
posnr
parvw
kunnr
adrnr
INTO CORRESPONDING FIELDS OF TABLE git_vbpa
FROM vbpa
FOR ALL ENTRIES IN git_vbap
WHERE vbeln = git_vbap-vbeln
* and POSNR = git_vbrp-posnr
AND parvw = 'WE'.
IF git_vbpa IS NOT INITIAL.
*---get 地址相关信息
SELECT addrnumber
date_from
nation
name1
street
INTO CORRESPONDING FIELDS OF TABLE git_adrc
FROM adrc
FOR ALL ENTRIES IN git_vbpa
WHERE addrnumber = git_vbpa-adrnr.
ENDIF.
*---get 工厂名称
SELECT werks
name1
INTO CORRESPONDING FIELDS OF TABLE git_t001w
FROM t001w.
*---get 客户名称
SELECT kunnr
name1
INTO CORRESPONDING FIELDS OF TABLE git_kna1
FROM kna1
FOR ALL ENTRIES IN git_vbap
WHERE kunnr = git_vbap-kunnr.
*---get 销售大区描述
SELECT vkbur
bezei
INTO CORRESPONDING FIELDS OF TABLE git_tvkbt
FROM tvkbt
WHERE spras = sy-langu.
*---get 销售办事处描述
SELECT vkgrp
bezei
INTO CORRESPONDING FIELDS OF TABLE git_tvgrt
FROM tvgrt
WHERE spras = sy-langu.
*---get SO项目状态
SELECT vbeln
posnr
absta
INTO CORRESPONDING FIELDS OF TABLE git_vbup
FROM vbup
FOR ALL ENTRIES IN git_vbap
WHERE vbeln = git_vbap-vbeln
AND posnr = git_vbap-posnr.
*---get 合并 1.1 1.2 SO对应的采购订单、交货单
SELECT vbelv
posnv
vbeln
posnn
posnn
AS posnn_5
vbtyp_n
erdat
rfmng
rfwrt
meins
erzet
INTO CORRESPONDING FIELDS OF TABLE git_vbfa_so
FROM vbfa
FOR ALL ENTRIES IN git_vbap
WHERE vbelv = git_vbap-vbeln
AND posnv = git_vbap-posnr
AND vbtyp_n IN ('V','J','T')."V 表示采购订单,J表示交货单,T表示订单的退货
IF git_vbfa_so[] IS NOT INITIAL.
*---如果T类型前面含有J类型的情况,则删除T类型
SORT git_vbfa_so BY vbelv posnv erdat erzet vbtyp_n.
DATA:tmp_type TYPE vbtyp_n,
tmp_vbelv
TYPE vbeln_von,
tmp_posnv
TYPE posnr_von.
LOOP AT git_vbfa_so.
IF git_vbfa_so-vbtyp_n = 'T' AND tmp_type = 'J' AND git_vbfa_so-vbelv = tmp_vbelv AND git_vbfa_so-posnv = tmp_posnv.
DELETE git_vbfa_so.
ELSEIF git_vbfa_so-vbtyp_n = 'V'."排除类型V
ELSE.
tmp_type
= git_vbfa_so-vbtyp_n.
tmp_vbelv
= git_vbfa_so-vbelv.
tmp_posnv
= git_vbfa_so-posnv.
ENDIF.
ENDLOOP.
*---get 合并1.1.1 1.1.2 PO对应的收货单、发票校验号
SELECT ebeln
ebelp
zekkn
vgabe
gjahr
belnr
buzei
buzei
AS buzei_6
INTO CORRESPONDING FIELDS OF TABLE git_ekbe
FROM ekbe
FOR ALL ENTRIES IN git_vbfa_so
WHERE ebeln = git_vbfa_so-vbeln
AND ebelp = git_vbfa_so-posnn_5
AND vgabe IN ('1','2')."1 表示收货,2 表示发票收据
IF git_ekbe IS NOT INITIAL.
*---get 1.1.1 PO对应的物料凭证(收货)信息
SELECT mblnr
mjahr
zeile
menge
meins
INTO CORRESPONDING FIELDS OF TABLE git_mseg_po
FROM mseg
FOR ALL ENTRIES IN git_ekbe
WHERE mblnr = git_ekbe-belnr
AND mjahr = git_ekbe-gjahr
AND zeile = git_ekbe-buzei
AND smbln = ''."冲销凭证为空,表示该物料凭证不是冲销凭证、
IF git_mseg_po IS NOT INITIAL.
"get 检查选择出来的物料凭证是否已经被冲销
SELECT smbln
sjahr
smblp
mjahr
zeile
mblnr
INTO CORRESPONDING FIELDS OF TABLE git_m_mbmps_po
FROM m_mbmps
FOR ALL ENTRIES IN git_mseg_po
WHERE smbln = git_mseg_po-mblnr
AND sjahr = git_mseg_po-mjahr
AND smblp = git_mseg_po-zeile.
ENDIF.
*---get 1.1.2 PO对应的发票校验信息
SELECT rbkp~belnr
rbkp
~gjahr
rseg
~buzei
rseg
~menge
rseg
~meins
INTO CORRESPONDING FIELDS OF TABLE git_rseg
FROM rbkp
INNER
JOIN rseg ON rseg~belnr = rbkp~belnr AND rseg~gjahr = rbkp~gjahr
FOR ALL ENTRIES IN git_ekbe
WHERE rbkp~belnr = git_ekbe-belnr
AND rbkp~gjahr = git_ekbe-gjahr
AND rseg~buzei = git_ekbe-buzei_6
AND rbkp~stblg = ''."该字段为空,表示当前凭证既不是冲销凭证,也没有被冲销
ENDIF.
*---get 1.2 交货单信息
*2011-1-2
* SELECT VBELN
* POSNR
* CHARG
* LGMNG
* MEINS
* UECHA"批次拆分项目的上层项目
** werks
* LGORT
* INTO CORRESPONDING FIELDS OF TABLE GIT_LIPS
* FROM LIPS
* FOR ALL ENTRIES IN GIT_VBFA_SO
* WHERE VBELN = GIT_VBFA_SO-VBELN
* AND POSNR = GIT_VBFA_SO-POSNN.
SELECT a~vbeln
a
~posnr
a
~charg
a
~lgmng
a
~meins
a
~uecha"批次拆分项目的上层项目
* werks
a
~lgort
* b~bolnr "车牌号
b
~erzet AS erzet_likp
b
~erdat AS erdat_likp
INTO CORRESPONDING FIELDS OF TABLE git_lips
FROM lips AS a INNER JOIN likp AS b
ON a~vbeln = b~vbeln
FOR ALL ENTRIES IN git_vbfa_so
WHERE a~vbeln = git_vbfa_so-vbeln
AND a~posnr = git_vbfa_so-posnn.
IF git_lips IS NOT INITIAL.
*---get 库存描述
SELECT werks
lgort
lgobe
INTO CORRESPONDING FIELDS OF TABLE git_t001l
FROM t001l.
*---get 1.2.1 1.2.2 交货单对应的物料凭证、开票凭证
SELECT vbelv
posnv
vbeln
posnn
posnn
AS posnn_4
vbtyp_n
mjahr
"物料凭证年度
plmin
INTO CORRESPONDING FIELDS OF TABLE git_vbfa_dn
FROM vbfa
FOR ALL ENTRIES IN git_lips
WHERE vbelv = git_lips-vbeln
AND posnv = git_lips-posnr
AND vbtyp_n IN ('R','M','5','O')
AND vbeln IN s_vbelns."R 表示过账发货,M表示开具发票,5表示公司间开具发票,O表示退货的一种凭证类型
"如果选中不显示公司间开票,那么删除公司开票记录
* IF p_bl = 'X'.
* DELETE git_vbfa_dn WHERE vbtyp_n = '5'.
* ENDIF.
IF git_vbfa_dn[] IS NOT INITIAL.
*---(M,5,O)三种类型中,如果存在PLMIN字段是+的,则删除所有-值的条目,R类型,如果有PLMIN正值条目,删除所有-值条目
SORT git_vbfa_dn BY vbelv posnv vbtyp_n plmin DESCENDING.
tmp_git_vbfa_dn[]
= git_vbfa_dn[].
LOOP AT git_vbfa_dn WHERE vbtyp_n <> 'R' AND plmin = '+'.
DELETE tmp_git_vbfa_dn WHERE vbelv = git_vbfa_dn-vbelv AND posnv = git_vbfa_dn-posnv AND plmin = '' AND vbtyp_n <> 'R'.
ENDLOOP.
LOOP AT git_vbfa_dn WHERE vbtyp_n = 'R' AND plmin = '+'.
DELETE tmp_git_vbfa_dn WHERE vbelv = git_vbfa_dn-vbelv AND posnv = git_vbfa_dn-posnv AND plmin = '' AND vbtyp_n = 'R'.
ENDLOOP.
CLEAR git_vbfa_dn[].
git_vbfa_dn[]
= tmp_git_vbfa_dn[].
CLEAR tmp_git_vbfa_dn[].
*---get 1.2.1 交货单对应的物料凭证
SELECT mseg~mblnr
mseg
~mjahr
zeile
menge
meins
mkpf
~cpudt
mkpf
~cputm
INTO CORRESPONDING FIELDS OF TABLE git_mseg_dn
FROM mseg
INNER
JOIN mkpf ON mkpf~mblnr = mseg~mblnr AND mkpf~mjahr = mseg~mjahr
FOR ALL ENTRIES IN git_vbfa_dn
WHERE mseg~mblnr = git_vbfa_dn-vbeln
AND mseg~mjahr = git_vbfa_dn-mjahr
AND zeile = git_vbfa_dn-posnn_4
AND smbln = ''
."冲销凭证为空,表示该物料凭证不是冲销凭证
* and LFBNR = ''."参考凭证为空,表示该物料凭证没有被冲销
IF git_mseg_dn IS NOT INITIAL.
"get 检查选择出来的物料凭证是否已经被冲销
SELECT smbln
sjahr
smblp
mjahr
zeile
mblnr
INTO CORRESPONDING FIELDS OF TABLE git_m_mbmps_dn
FROM m_mbmps
FOR ALL ENTRIES IN git_mseg_dn
WHERE smbln = git_mseg_dn-mblnr
AND sjahr = git_mseg_dn-mjahr
AND smblp = git_mseg_dn-zeile.
ENDIF.
*---get 1.2.2 交货单对应的开票凭证
SELECT vbrp~vbeln
vbrp
~posnr
vbrp
~fkimg
vbrp
~vrkme
vbrk
~erzet
vbrk
~erdat
INTO CORRESPONDING FIELDS OF TABLE git_vbrp
FROM vbrp
INNER
JOIN vbrk ON vbrk~vbeln = vbrp~vbeln
FOR ALL ENTRIES IN git_vbfa_dn
WHERE vbrp~vbeln = git_vbfa_dn-vbeln
AND vbrp~posnr = git_vbfa_dn-posnn
AND vbrk~fksto <> 'X'."不为X,表示未取消
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " frm_retrive_data
*&---------------------------------------------------------------------*
*& Form frm_process_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_process_data .
DATA: BEGIN OF lwa_flag,"判断是否已经输出
so
TYPE c, "销售订单
po
TYPE c, "采购订单
dn_gr
TYPE c, "交货单DN对应的发货单GR
* dn type c,"交货单
* dn_chai type c,"交货单拆分
END OF lwa_flag.
DATA: lwa_output_so TYPE typ_output,
lwa_output_so_po
TYPE typ_output,
lwa_output_so_dn
TYPE typ_output,
lc_name
TYPE thead-tdname,
lit_lines
TYPE TABLE OF tline,
lwa_lines
TYPE tline.
* lwa_output_so_dn_chai type typ_output.
*---process 1. 销售订单相关信息
LOOP AT git_vbap INTO gwa_vbap.
CLEAR: gwa_output,lwa_flag,lc_name,lit_lines.
"process 销售订单
MOVE-CORRESPONDING gwa_vbap TO gwa_output.
* IF gwa_vbap-auart = 'ZORJ' OR gwa_vbap-auart = 'ZORS' OR gwa_vbap-auart = 'ZORW'.
* gwa_output-eannr = gwa_output-klmeng.
* ENDIF.
* gwa_output-kwmeng = gwa_vbap-kwmeng.
*--取折扣价值
LOOP AT git_konv WHERE knumv = gwa_vbap-knumv AND kposn = gwa_output-posnr.
"gwa_output-zh_kwert = git_konv-kwert + gwa_output-zh_kwert.
CASE git_konv-kschl.
WHEN 'ZB03'.gwa_output-zh_kwert = git_konv-kwert * -1."显示正数
WHEN 'ZB04'.gwa_output-zj_kwert = git_konv-kwert * -1.
WHEN 'ZB07'.gwa_output-fy_kwert = git_konv-kwert * -1.
ENDCASE.
ENDLOOP.
"process 红白条数
TRY .
* gwa_output-kdmat_quan = gwa_vbap-kdmat.
CATCH cx_root.
ENDTRY.
*---2011-1-2 hanlin s
READ TABLE git_t023 WITH KEY matkl = gwa_vbap-matkl.
IF sy-subrc = 0.
gwa_output
-wgbez = git_t023-wgbez.
ENDIF.
READ TABLE git_tvak WITH KEY auart = gwa_vbap-auart.
IF sy-subrc = 0.
gwa_output
-bezei = git_tvak-bezei.
ENDIF.
"process 客户组
READ TABLE git_knvv INTO gwa_knvv WITH KEY kunnr = gwa_vbap-kunnr vkorg = gwa_vbap-vkorg vtweg = gwa_vbap-vtweg.
IF sy-subrc = 0.
gwa_output
-kdgrp = gwa_knvv-kdgrp.
"process 客户组描述
READ TABLE git_t151t INTO gwa_t151t WITH KEY kdgrp = gwa_knvv-kdgrp.
IF sy-subrc = 0.
gwa_output
-ktext = gwa_t151t-ktext.
ENDIF.
ENDIF.
"process 送达方代码
READ TABLE git_vbpa INTO gwa_vbpa WITH KEY vbeln = gwa_vbap-vbeln parvw = 'WE'.
IF sy-subrc = 0 AND gwa_vbpa-kunnr IN s_kunnr2.
gwa_output
-kunnr_we = gwa_vbpa-kunnr.
"process 送达方名称
READ TABLE git_adrc INTO gwa_adrc WITH KEY addrnumber = gwa_vbpa-adrnr.
IF sy-subrc = 0.
gwa_output
-name1_we = gwa_adrc-name1.
ENDIF.
ELSE.
DELETE TABLE git_output FROM gwa_output.
CONTINUE.
ENDIF.
"process 工厂名称
READ TABLE git_t001w INTO gwa_t001w WITH KEY werks = gwa_vbap-werks.
IF sy-subrc = 0.
gwa_output
-name1_t001w = gwa_t001w-name1.
ENDIF.
"process 客户名称
READ TABLE git_kna1 INTO gwa_kna1 WITH KEY kunnr = gwa_vbap-kunnr.
IF sy-subrc = 0.
gwa_output
-name1_kna1 = gwa_kna1-name1.
ENDIF.
"process 销售大区描述
READ TABLE git_tvkbt INTO gwa_tvkbt WITH KEY vkbur = gwa_vbap-vkbur.
IF sy-subrc = 0.
gwa_output
-bezei_tvkbt = gwa_tvkbt-bezei.
ENDIF.
"process 销售办事处描述
READ TABLE git_tvgrt INTO gwa_tvgrt WITH KEY vkgrp = gwa_vbap-vkgrp.
IF sy-subrc = 0.
gwa_output
-bezei_tvgrt = gwa_tvgrt-bezei.
ENDIF.
"process 含税单价--销售单位
IF gwa_output-kwmeng IS NOT INITIAL.
gwa_output
-zdj = ( gwa_output-netwr + gwa_output-mwsbp ) / gwa_output-kwmeng.
ENDIF.
"process 基本单位数量
IF gwa_output-umvkn IS NOT INITIAL.
gwa_output
-zsl_base = gwa_output-kwmeng * gwa_output-umvkz / gwa_output-umvkn.
ENDIF.
"process 基本单位含税单价
IF gwa_output-zsl_base IS NOT INITIAL.
gwa_output
-zdj_base = ( gwa_output-netwr + gwa_output-mwsbp ) / gwa_output-zsl_base.
ENDIF.
"process SO项目状态
READ TABLE git_vbup INTO gwa_vbup WITH KEY vbeln = gwa_vbap-vbeln posnr = gwa_vbap-posnr.
IF sy-subrc = 0.
gwa_output
-absta = gwa_vbup-absta.
CASE gwa_vbup-absta.
WHEN 'A'.
gwa_output
-zabsta_des = '没有处理'.
WHEN 'B'.
gwa_output
-zabsta_des = '部分处理'.
WHEN 'C'.
gwa_output
-zabsta_des = '完全地处理 '.
WHEN OTHERS.
ENDCASE.
ENDIF.
"备份 SO数据
lwa_output_so
= gwa_output.
"process 1.1 SO对应的PO采购订单
IF p_flag = ''."当flag为空时,才取采购订单
LOOP AT git_vbfa_so INTO gwa_vbfa_so WHERE vbelv = gwa_vbap-vbeln AND posnv = gwa_vbap-posnr AND vbtyp_n = 'V'.
CLEAR: lwa_flag-po.
"还原 SO数据
gwa_output
= lwa_output_so.
"process PO相关信息
gwa_output
-ebeln_po = gwa_vbfa_so-vbeln.
gwa_output
-ebelp_po = gwa_vbfa_so-posnn.
gwa_output
-aedat_po = gwa_vbfa_so-erdat."订单日期
gwa_output
-menge_po = gwa_vbfa_so-rfmng."数量
IF gwa_vbfa_so-rfmng IS NOT INITIAL.
gwa_output
-netpr_po = gwa_vbfa_so-rfwrt / gwa_vbfa_so-rfmng."净单价
ENDIF.
gwa_output
-meins_po = gwa_vbfa_so-meins."单位
"process 1.1.1 PO对应的GR收货单
"备份 SO-PO数据
lwa_output_so_po
= gwa_output.
LOOP AT git_ekbe INTO gwa_ekbe WHERE ebeln = gwa_vbfa_so-vbeln AND ebelp = gwa_vbfa_so-posnn_5 AND vgabe = '1'.
"process GR相关信息
READ TABLE git_mseg_po INTO gwa_mseg_po WITH KEY mblnr = gwa_ekbe-belnr mjahr = gwa_ekbe-gjahr zeile = gwa_ekbe-buzei.
IF sy-subrc = 0.
"process 过滤掉已经被冲销的物料凭证
READ TABLE git_m_mbmps_po INTO gwa_m_mbmps_po WITH KEY smbln = gwa_mseg_po-mblnr sjahr = gwa_mseg_po-mjahr smblp = gwa_mseg_po-zeile.
IF sy-subrc <> 0.
gwa_output
-mblnr_po_gr = gwa_mseg_po-mblnr.
gwa_output
-zeile_po_gr = gwa_mseg_po-zeile.
gwa_output
-menge_po_gr = gwa_mseg_po-menge.
gwa_output
-meins_po_gr = gwa_mseg_po-meins.
APPEND gwa_output TO git_output.
lwa_flag
-so = 'X'."销售订单已经输出过
lwa_flag
-po = 'X'."采购订单已经输出过
ENDIF.
ENDIF.
ENDLOOP.
"还原 so-po数据
gwa_output
= lwa_output_so_po.
"process 1.1.2 PO对应的IR发票校验
LOOP AT git_ekbe INTO gwa_ekbe WHERE ebeln = gwa_vbfa_so-vbeln AND ebelp = gwa_vbfa_so-posnn_5 AND vgabe = '2'.
"process IR相关信息
READ TABLE git_rseg INTO gwa_rseg WITH KEY belnr = gwa_ekbe-belnr gjahr = gwa_ekbe-gjahr buzei = gwa_ekbe-buzei_6.
IF sy-subrc = 0.
gwa_output
-belnr_po_ir = gwa_rseg-belnr.
gwa_output
-buzei_po_ir = gwa_rseg-buzei.
gwa_output
-menge_po_ir = gwa_rseg-menge.
gwa_output
-meins_po_ir = gwa_rseg-meins.
APPEND gwa_output TO git_output.
lwa_flag
-so = 'X'."销售订单已经输出过
lwa_flag
-po = 'X'."采购订单已经输出过
ENDIF.
ENDLOOP.
"检查PO采购订单是否已经输出过
IF lwa_flag-po = ''.
APPEND gwa_output TO git_output.
lwa_flag
-so = 'X'."销售订单已经输出过
lwa_flag
-po = 'X'."采购订单已经输出过
ENDIF.
ENDLOOP.
ENDIF.
"process 1.2 SO对应的交货单DN
LOOP AT git_vbfa_so INTO gwa_vbfa_so WHERE vbelv = gwa_vbap-vbeln AND posnv = gwa_vbap-posnr AND ( vbtyp_n = 'J' OR vbtyp_n = 'T' ).
"还原so数据
gwa_output
= lwa_output_so.
"process 交货单
* READ TABLE git_lips INTO gwa_lips WITH KEY vbeln = gwa_vbfa_so-vbeln posnr = gwa_vbfa_so-posnn uecha = ''.
READ TABLE git_lips INTO gwa_lips WITH KEY vbeln = gwa_vbfa_so-vbeln posnr = gwa_vbfa_so-posnn.
IF sy-subrc = 0.
"process 交货单DN相关信息
gwa_output
-vbeln_dn = gwa_lips-vbeln.
gwa_output
-posnr_dn = gwa_lips-posnr.
gwa_output
-charg_dn = gwa_lips-charg.
gwa_output
-lgmng_dn = gwa_lips-lgmng.
gwa_output
-meins_dn = gwa_lips-meins.
* gwa_output-werks = gwa_lips-werks.
gwa_output
-lgort = gwa_lips-lgort.
**2011-1-2 HANLIN
gwa_output
-bolnr = gwa_lips-bolnr.
**2011-1-2 HANLIN
gwa_output
-erdat_likp = gwa_lips-erdat_likp.
gwa_output
-erzet_likp = gwa_lips-erzet_likp.
"process 库存描述
READ TABLE git_t001l INTO gwa_t001l WITH KEY werks = gwa_vbap-werks lgort = gwa_lips-lgort.
IF sy-subrc = 0.
gwa_output
-lgobe = gwa_t001l-lgobe.
ENDIF.
"process 行项目文本
CONCATENATE gwa_output-vbeln_dn gwa_output-posnr_dn INTO lc_name.
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
id = '0001'
language = sy-langu
name
= lc_name
object
= 'VBBP'
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
TABLES
lines = lit_lines
EXCEPTIONS
id = 1
language = 2
name
= 3
not_found
= 4
object
= 5
reference_check
= 6
wrong_access_to_archive
= 7
OTHERS = 8.
IF sy-subrc = 4.
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
id = '0001'
language = sy-langu
name
= lc_name
object
= 'VBBP'
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
TABLES
lines = lit_lines
EXCEPTIONS
id = 1
language = 2
name
= 3
not_found
= 4
object
= 5
reference_check
= 6
wrong_access_to_archive
= 7
OTHERS = 8.
ENDIF.
LOOP AT lit_lines INTO lwa_lines.
CONCATENATE gwa_output-ztext lwa_lines-tdline INTO gwa_output-ztext.
ENDLOOP.
"process 抬头文本
CLEAR: lit_lines ,
lc_name
,
lwa_lines
.
lc_name
= gwa_output-vbeln_dn.
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
id = '0001'
language = sy-langu
name
= lc_name
object
= 'VBBK'
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
TABLES
lines = lit_lines
EXCEPTIONS
id = 1
language = 2
name
= 3
not_found
= 4
object
= 5
reference_check
= 6
wrong_access_to_archive
= 7
OTHERS = 8.
IF sy-subrc = 4.
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
id = '0001'
language = sy-langu
name
= lc_name
object
= 'VBBK'
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
TABLES
lines = lit_lines
EXCEPTIONS
id = 1
language = 2
name
= 3
not_found
= 4
object
= 5
reference_check
= 6
wrong_access_to_archive
= 7
OTHERS = 8.
ENDIF.
LOOP AT lit_lines INTO lwa_lines.
* GWA_OUTPUT-RISE_TEXT = LWA_LINES-TDLINE .
CONCATENATE gwa_output-rise_text lwa_lines-tdline INTO gwa_output-rise_text.
ENDLOOP.
CLEAR: lit_lines ,
lc_name
,
lwa_lines
.
lc_name
= gwa_output-vbeln.
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
id = '0001'
language = sy-langu
name
= lc_name
object
= 'VBBK'
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
TABLES
lines = lit_lines
EXCEPTIONS
id = 1
language = 2
name
= 3
not_found
= 4
object
= 5
reference_check
= 6
wrong_access_to_archive
= 7
OTHERS = 8.
IF sy-subrc = 4.
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
id = '0001'
language = sy-langu
name
= lc_name
object
= 'VBBK'
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
TABLES
lines = lit_lines
EXCEPTIONS
id = 1
language = 2
name
= 3
not_found
= 4
object
= 5
reference_check
= 6
wrong_access_to_archive
= 7
OTHERS = 8.
ENDIF.
LOOP AT lit_lines INTO lwa_lines.
* GWA_OUTPUT-RISE_TEXT = LWA_LINES-TDLINE .
CONCATENATE gwa_output-so_text lwa_lines-tdline INTO gwa_output-so_text.
ENDLOOP.
"备份 so-dn数据
lwa_output_so_dn
= gwa_output.
"判断当前交货单是否被拆分过:1.如果被拆分,那么多条;2.如果未被拆分,一条数据
READ TABLE git_lips INTO gwa_lips_chai WITH KEY vbeln = gwa_lips-vbeln uecha = gwa_lips-posnr.
IF sy-subrc = 0.
"process 交货单DN的拆分项目
LOOP AT git_lips INTO gwa_lips_chai WHERE vbeln = gwa_lips-vbeln AND uecha = gwa_lips-posnr.
"还原 so-dn数据
gwa_output
= lwa_output_so_dn.
gwa_output
-posnr_dn_chai = gwa_lips_chai-posnr.
gwa_output
-charg_dn_chai = gwa_lips_chai-charg.
gwa_output
-lgmng_dn_chai = gwa_lips_chai-lgmng.
gwa_output
-meins_dn_chai = gwa_lips_chai-meins.
"process 交货单DN拆分的发货单GR
LOOP AT git_vbfa_dn INTO gwa_vbfa_dn WHERE vbelv = gwa_lips_chai-vbeln AND posnv = gwa_lips_chai-posnr AND vbtyp_n = 'R'.
"process DN拆分对应的发货单信息
READ TABLE git_mseg_dn INTO gwa_mseg_dn WITH KEY mblnr = gwa_vbfa_dn-vbeln mjahr = gwa_vbfa_dn-mjahr zeile = gwa_vbfa_dn-posnn_4.
IF sy-subrc = 0.
"process 过滤掉已经被冲销的物料凭证
READ TABLE git_m_mbmps_dn INTO gwa_m_mbmps_dn WITH KEY smbln = gwa_mseg_dn-mblnr sjahr = gwa_mseg_dn-mjahr smblp = gwa_mseg_dn-zeile.
IF sy-subrc <> 0.
gwa_output
-mblnr_dn_gr = gwa_mseg_dn-mblnr.
gwa_output
-zeile_dn_gr = gwa_mseg_dn-zeile.
gwa_output
-menge_dn_gr = gwa_mseg_dn-menge.
gwa_output
-meins_dn_gr = gwa_mseg_dn-meins.
ENDIF.
ENDIF.
ENDLOOP.
"process 交货单DN拆分的开票凭证BL
LOOP AT git_vbfa_dn INTO gwa_vbfa_dn WHERE vbelv = gwa_lips_chai-vbeln AND posnv = gwa_lips_chai-posnr AND ( vbtyp_n = 'M' OR vbtyp_n = '5' OR vbtyp_n = 'O').
"process DN拆分对应的开票凭证
READ TABLE git_vbrp INTO gwa_vbrp WITH KEY vbeln = gwa_vbfa_dn-vbeln posnr = gwa_vbfa_dn-posnn.
IF sy-subrc = 0.
gwa_output
-vbeln_dn_bl = gwa_vbrp-vbeln.
gwa_output
-posnr_dn_bl = gwa_vbrp-posnr.
gwa_output
-fkimg_dn_bl = gwa_vbrp-fkimg.
gwa_output
-vrkme_dn_bl = gwa_vbrp-vrkme.
"process 交货单拆分是否输出过.
APPEND gwa_output TO git_output.
lwa_flag
-so = 'X'."销售订单已经输出过
lwa_flag
-dn_gr = 'X'."交货单DN的发货单GR已经输出过
ENDIF.
ENDLOOP.
"判断交货单DN的发货单GR是否输出过
IF lwa_flag-dn_gr = ''.
APPEND gwa_output TO git_output.
lwa_flag
-so = 'X'."销售订单已经输出过
ENDIF.
ENDLOOP.
ELSE. "2.未被拆分
"process 交货单DN的发货单GR
LOOP AT git_vbfa_dn INTO gwa_vbfa_dn WHERE vbelv = gwa_lips-vbeln AND posnv = gwa_lips-posnr AND vbtyp_n = 'R'.
"process DN对应的发货单信息
READ TABLE git_mseg_dn INTO gwa_mseg_dn WITH KEY mblnr = gwa_vbfa_dn-vbeln mjahr = gwa_vbfa_dn-mjahr zeile = gwa_vbfa_dn-posnn_4.
IF sy-subrc = 0.
"process 过滤掉已经被冲销的物料凭证
READ TABLE git_m_mbmps_dn INTO gwa_m_mbmps_dn WITH KEY smbln = gwa_mseg_dn-mblnr sjahr = gwa_mseg_dn-mjahr smblp = gwa_mseg_dn-zeile.
IF sy-subrc <> 0.
gwa_output
-mblnr_dn_gr = gwa_mseg_dn-mblnr.
gwa_output
-zeile_dn_gr = gwa_mseg_dn-zeile.
gwa_output
-menge_dn_gr = gwa_mseg_dn-menge.
gwa_output
-meins_dn_gr = gwa_mseg_dn-meins.
gwa_output
-cpudt = gwa_mseg_dn-cpudt.
gwa_output
-cputm = gwa_mseg_dn-cputm.
ENDIF.
ENDIF.
ENDLOOP.
"process 交货单DN的开票凭证BL
LOOP AT git_vbfa_dn INTO gwa_vbfa_dn WHERE vbelv = gwa_lips-vbeln AND posnv = gwa_lips-posnr AND ( vbtyp_n = 'M' OR vbtyp_n = '5' OR vbtyp_n = 'O').
"process DN对应的开票凭证
READ TABLE git_vbrp INTO gwa_vbrp WITH KEY vbeln = gwa_vbfa_dn-vbeln posnr = gwa_vbfa_dn-posnn.
IF sy-subrc = 0.
gwa_output
-vbeln_dn_bl = gwa_vbrp-vbeln.
gwa_output
-posnr_dn_bl = gwa_vbrp-posnr.
gwa_output
-fkimg_dn_bl = gwa_vbrp-fkimg.
gwa_output
-vrkme_dn_bl = gwa_vbrp-vrkme.
gwa_output
-erzet_fp = gwa_vbrp-erzet.
gwa_output
-erdat_fp = gwa_vbrp-erdat.
"process 交货单DN是否输出过
APPEND gwa_output TO git_output.
lwa_flag
-so = 'X'."销售订单已经输出过
lwa_flag
-dn_gr = 'X'."交货单DN的发货单GR已经输出过
ENDIF.
ENDLOOP.
"判断交货单DN的发货单GR是否输出过
IF lwa_flag-dn_gr = ''.
APPEND gwa_output TO git_output.
lwa_flag
-so = 'X'."销售订单已经输出过
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
"判断销售订单SO是否输出过
IF lwa_flag-so = ''.
APPEND gwa_output TO git_output.
ENDIF.
ENDLOOP.
*---按照库存地点 过滤数据
* IF s_lgort IS NOT INITIAL.
* DELETE git_output WHERE lgort NOT IN s_lgort.
* ENDIF.
*---按照送达方编码 过滤数据
* IF s_kunnr2 IS NOT INITIAL.
* DELETE git_output WHERE kunnr_we NOT IN s_kunnr2.
* ENDIF.
*---按照是否审批,过滤数据:1.已审批,则删除交货单为空的;2.未审批,则删除交货单不为空的
IF r_1 = 'X'.
DELETE git_output WHERE vbeln_dn IS INITIAL.
ELSEIF r_2 = 'X'.
DELETE git_output WHERE vbeln_dn IS NOT INITIAL.
ENDIF.
*---按照交货单号、开票凭证号进行过滤
IF s_vbeln2 IS NOT INITIAL."交货单号
DELETE git_output WHERE vbeln_dn NOT IN s_vbeln2.
ENDIF.
IF s_vbeln3 IS NOT INITIAL."开票凭证号
DELETE git_output WHERE vbeln_dn_bl NOT IN s_vbeln3.
ENDIF.
**---按照客户组过滤数据
* IF s_kdgrp IS NOT INITIAL.
* DELETE git_output WHERE kdgrp NOT IN s_kdgrp.
* ENDIF.
**---判断是否存在相应的选择数据
IF git_output IS INITIAL.
MESSAGE text-001 TYPE 'S'.
LEAVE LIST-PROCESSING.
ENDIF.
"--------------修改使销售单位数量、基本单位数量不重复显示---add by sxl 2011.01.08-------------
DATA: gwa_output_temp TYPE typ_output.
LOOP AT git_output INTO gwa_output.
* IF gwa_output-vbeln = gwa_output_temp-vbeln AND gwa_output-posnr = gwa_output_temp-posnr.
* CLEAR: gwa_output-kwmeng , gwa_output-zdj , gwa_output-zsl_base, gwa_output-zdj_base.
* MODIFY git_output FROM gwa_output.
* ELSE.
* gwa_output_temp = gwa_output.
* ENDIF.
"-------------退货订单加负----add by sxl-----2011.06.13-------
IF gwa_output-auart = 'ZKA1' OR gwa_output-auart = 'ZKR1' OR gwa_output-auart = 'ZRE1' OR gwa_output-auart = 'ZRE2'.
gwa_output
-kwmeng = gwa_output-kwmeng * ( -1 ).
gwa_output
-zsl_base = gwa_output-zsl_base * ( -1 ).
ENDIF.
"-------------增加金额计算----add by sxl-----2011.01.10-------
" gwa_output-dmbtr = gwa_output-kwmeng * gwa_output-zdj.
gwa_output
-dmbtr = gwa_output-netwr + gwa_output-mwsbp.
SELECT SINGLE bztxt INTO gwa_output-bzirk_txt
FROM t171t
WHERE bzirk EQ gwa_output-bzirk.
SELECT SINGLE vtext INTO gwa_output-pstyv_txt
FROM tvapt
WHERE pstyv EQ gwa_output-pstyv.
SELECT SINGLE route INTO gwa_output-route
FROM likp
WHERE vbeln EQ gwa_output-vbeln_dn.
SELECT SINGLE bezei INTO gwa_output-route_txt
FROM tvrot
WHERE route EQ gwa_output-route.
MODIFY git_output FROM gwa_output.
ENDLOOP.
ENDFORM. " frm_process_data
*&---------------------------------------------------------------------*
*& Form frm_output
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_output .
gwa_layout
-colwidth_optimize = 'X'."宽度自动优化
gwa_layout
-zebra = 'X'."斑马线
* GWA_LAYOUT-F2CODE = '&ETA'.
gwa_layout
-box_fieldname = 'ZSEL'.
gwa_sort
-fieldname = 'VBELN'."销售订单
gwa_sort
-up = 'X'.
APPEND gwa_sort TO git_sort.
SORT git_output BY vbeln posnr vbeln_dn posnr_dn.
DELETE ADJACENT DUPLICATES FROM git_output.
DATA:luecha LIKE lips-uecha.
DATA:lpstyv LIKE lips-pstyv.
DATA:ls_output TYPE typ_output.
** LOOP AT git_output INTO gwa_output.
** SELECT SINGLE pstyv uecha INTO ( lpstyv ,luecha )
** FROM lips
** WHERE vbeln EQ gwa_output-vbeln_dn AND posnr EQ gwa_output-posnr_dn.
**
** IF lpstyv EQ 'ZMN'.
** READ TABLE git_output INTO ls_output
** WITH KEY vbeln = gwa_output-vbeln vbeln_dn = gwa_output-vbeln_dn posnr_dn = luecha.
** ls_output-kwmeng = ls_output-kwmeng + gwa_output-kwmeng.
** ls_output-lgmng_dn = ls_output-lgmng_dn + gwa_output-lgmng_dn.
** ls_output-menge_dn_gr = ls_output-menge_dn_gr + gwa_output-menge_dn_gr.
** MODIFY TABLE git_output FROM ls_output.
** DELETE TABLE git_output FROM gwa_output.
** ENDIF.
** CLEAR:luecha,lpstyv,ls_output.
** ENDLOOP.
DATA:lv_output TYPE typ_output.
LOOP AT git_output INTO gwa_output WHERE posnr_dn_chai IS NOT INITIAL .
"IF gwa_output-posnr_dn_chai IS NOT INITIAL.
READ TABLE git_output INTO lv_output WITH KEY vbeln = gwa_output-vbeln
vbeln_dn
= gwa_output-vbeln_dn
posnr_dn
= gwa_output-posnr_dn_chai.
* CLEAR gwa_output-menge_dn_gr .
* CLEAR gwa_output-dmbtr.
IF sy-subrc EQ 0.
gwa_output
-lgmng_dn = lv_output-lgmng_dn.
gwa_output
-menge_dn_gr = lv_output-menge_dn_gr.
gwa_output
-dmbtr = lv_output-dmbtr.
gwa_output
-cpudt = lv_output-cpudt.
gwa_output
-cputm = lv_output-cputm.
gwa_output
-erzet_fp = lv_output-erzet_fp.
gwa_output
-erdat_fp = lv_output-erdat_fp.
DELETE TABLE git_output FROM lv_output.
ENDIF.
MODIFY git_output FROM gwa_output.
"ENDIF.
CLEAR lv_output.
ENDLOOP.
LOOP AT git_output INTO gwa_output WHERE posnr_dn_chai IS NOT INITIAL .
LOOP AT git_output INTO lv_output WHERE vbeln EQ gwa_output-vbeln
AND vbeln_dn EQ gwa_output-vbeln_dn
AND posnr_dn EQ gwa_output-posnr_dn
AND posnr_dn_chai <> gwa_output-posnr_dn_chai .
gwa_output
-lgmng_dn = gwa_output-lgmng_dn + lv_output-lgmng_dn.
gwa_output
-menge_dn_gr = gwa_output-menge_dn_gr + lv_output-menge_dn_gr.
DELETE TABLE git_output FROM lv_output.
ENDLOOP.
CLEAR gwa_output-posnr_dn_chai.
READ TABLE git_vbfa_dn INTO gwa_vbfa_dn WITH KEY vbelv = gwa_output-vbeln_dn posnv = gwa_output-posnr_dn vbtyp_n = 'M' .
IF sy-subrc = 0.
READ TABLE git_vbrp INTO gwa_vbrp WITH KEY vbeln = gwa_vbfa_dn-vbeln posnr = gwa_vbfa_dn-posnn.
IF sy-subrc = 0.
gwa_output
-vbeln_dn_bl = gwa_vbrp-vbeln.
gwa_output
-posnr_dn_bl = gwa_vbrp-posnr.
gwa_output
-fkimg_dn_bl = gwa_vbrp-fkimg.
gwa_output
-vrkme_dn_bl = gwa_vbrp-vrkme.
gwa_output
-erzet_fp = gwa_vbrp-erzet.
gwa_output
-erdat_fp = gwa_vbrp-erdat.
ENDIF.
ENDIF.
MODIFY git_output FROM gwa_output.
ENDLOOP.
m_alv_fieldcat
:
* 'ZSEL' 4 text-f01 'X' 'X' '' '' '' 'X',
'ERDAT' 8 text-f02 '' '' '' '' 'X' 'X',
'ERZET' 6 '创建时间' '' '' '' '' 'X' 'X',
'VDATU' 8 '交货日期' '' '' '' '' 'X' 'X',
'VBELN' 8 text-f03 '' '' '' '' 'X' 'X',
'KUNNR' 8 text-f04 '' '' '' '' 'X' 'X',
'NAME1_KNA1' 8 text-f05 '' '' '' '' 'X' 'X',
'KUNNR_WE' 30 text-f59 '' '' '' '' '' 'X',
'NAME1_WE' 30 text-f60 '' '' '' '' '' 'X',
'VKORG' 30 text-f06 '' '' '' '' '' 'X',
'VTWEG' 30 text-f07 '' '' '' '' '' 'X',
"'SPART' 10 text-f08 '' '' '' '' '' '',
'KDGRP' 10 text-f61 '' '' '' '' '' '',
'KTEXT' 10 text-f62 '' '' '' '' '' '',
'BZIRK' 10 '销售部' '' '' '' '' '' '',
'BZIRK_TXT' 10 '销售部描述' '' '' '' '' '' '',
'VKBUR' 10 text-f09 '' '' '' '' '' '',
'BEZEI_TVKBT' 25 text-f10 '' '' '' '' '' 'X',
'VKGRP' 25 text-f11 '' '' '' '' '' '',
'BEZEI_TVGRT' 25 text-f12 '' '' '' '' '' 'X',
'BSTNK' '' text-f58 '' '' '' '' '' '',
'POSNR' 25 text-f13 '' '' '' '' '' 'X',
'PSTYV' 25 '行项目类型' '' '' '' '' '' 'X',
'PSTYV_TXT' 25 '行项目类型描述' '' '' '' '' '' 'X',
'MATNR' 25 text-f14 '' '' '' '' '' 'X',
'ARKTX' 25 text-f15 '' '' '' '' '' 'X',
'WERKS' 25 text-f16 '' '' '' '' '' 'X',
'NAME1_T001W' '' text-f17 '' '' '' '' '' 'X',
'KWMENG' '' text-f20 '' '' '' '' '' 'X',
"'ZDJ' '' text-f21 '' '' '' '' '' 'X',
'DMBTR' '' '销售订单行项目金额' '' '' '' '' '' 'X',
'ZH_KWERT' '' '折扣金额' '' '' '' '' '' 'X',
'ZJ_KWERT' '' '折价金额' '' '' '' '' '' 'X',
'FY_KWERT' '' '费用折扣' '' '' '' '' '' 'X',
'VRKME' '' text-f22 '' '' '' '' '' 'X',
"'ZSL_BASE' '' text-f23 '' '' '' '' '' 'X',
'ZDJ_BASE' '' text-f24 '' '' '' '' '' 'X',
'MEINS' '' text-f25 '' '' '' '' '' 'X',
'ZABSTA_DES' '' text-f26 '' '' '' '' '' 'X',
"'KDMAT_QUAN' '' '红白条头数' '' '' '' '' '' 'X',
"'BOLNR' '' '车牌号' '' '' '' '' '' 'X',
'AUART' '' '订单类型' '' '' '' '' '' 'X',
'BEZEI' '' '订单类型描述' '' '' '' '' '' 'X',
'MATKL' '' '物料组' '' '' '' '' '' 'X',
'WGBEZ' '' '物料组描述' '' '' '' '' '' 'X',
'ERDAT_LIKP' '' '交货单创建日期' '' '' '' '' '' 'X',
'ERZET_LIKP' '' '交货单创建时间' '' '' '' '' '' 'X',
"'DDLX' '' '时间订单' '' '' '' '' '' 'X',
*-----------------------------ADD BY YK
'CPUDT' '' '物料凭证创建日期' '' '' '' '' '' 'X',
'CPUTM' '' '物料凭证创建时间' '' '' '' '' '' 'X',
'ERZET_FP' '' '发票创建时间' '' '' '' '' '' 'X',
'ERDAT_FP' '' '发票创建日期' '' '' '' '' '' 'X'.
"erdat_likp
IF p_flag = 'X'."当flag为空的时候,不显示跟采购订单有关的列
m_alv_fieldcat
: 'EBELN_PO' '' text-f27 '' '' '' '' '' 'X',
'AEDAT_PO' '' text-f28 '' '' '' '' '' 'X',
'EBELP_PO' '' text-f29 '' '' '' '' '' 'X',
'MENGE_PO' '' text-f30 '' '' '' '' '' 'X',
'NETPR_PO' '' text-f31 '' '' '' '' '' 'X',
'MEINS_PO' '' text-f32 '' '' '' '' '' 'X',
'MBLNR_PO_GR' '' text-f33 '' '' '' '' '' 'X',
'ZEILE_PO_GR' '' text-f34 '' '' '' '' '' 'X',
'MENGE_PO_GR' '' text-f35 '' '' '' '' '' 'X',
'MEINS_PO_GR' '' text-f36 '' '' '' '' '' 'X',
'BELNR_PO_IR' '' text-f37 '' '' '' '' '' 'X',
'BUZEI_PO_IR' '' text-f38 '' '' '' '' '' 'X',
'MENGE_PO_IR' '' text-f39 '' '' '' '' '' 'X',
'MEINS_PO_IR' '' text-f40 '' '' '' '' '' 'X'.
ENDIF.
m_alv_fieldcat
:
'VBELN_DN' '' text-f41 '' '' '' '' '' 'X',
'POSNR_DN' '' text-f42 '' '' '' '' '' 'X',
'ROUTE' '' '路线代码' '' '' '' '' '' 'X',
'ROUTE_TXT' '' '路线描述' '' '' '' '' '' 'X',
'ZTEXT' '' '交货单行项目长文本' '' '' '' '' '' 'X',
'RISE_TEXT' '' '交货单抬头文本' '' '' '' '' '' 'X',
'SO_TEXT' '' '订单抬头文本' '' '' '' '' '' 'X',
'LGORT' '' text-f18 '' '' '' '' '' 'X',
'LGOBE' '' text-f19 '' '' '' '' '' 'X',
'VSTEL' '' text-f63 '' '' '' '' '' 'X', "20120312增加
'CHARG_DN' '' text-f43 '' '' '' '' '' 'X',
'LGMNG_DN' '' text-f44 '' '' '' '' '' 'X',
'MEINS_DN' '' text-f45 '' '' '' '' '' 'X',
'POSNR_DN_CHAI' '' text-f46 '' '' '' '' '' 'X',
'CHARG_DN_CHAI' '' text-f47 '' '' '' '' '' 'X',
'LGMNG_DN_CHAI' '' text-f48 '' '' '' '' '' 'X',
'MEINS_DN_CHAI' '' text-f49 '' '' '' '' '' 'X',
'MBLNR_DN_GR' '' text-f50 '' '' '' '' '' 'X',
'ZEILE_DN_GR' '' text-f51 '' '' '' '' '' 'X',
'MENGE_DN_GR' '' text-f52 '' '' '' '' '' 'X',
'MEINS_DN_GR' '' text-f53 '' '' '' '' '' 'X',
'VBELN_DN_BL' '' text-f54 '' '' '' '' '' 'X',
'POSNR_DN_BL' '' text-f55 '' '' '' '' '' 'X',
'FKIMG_DN_BL' '' text-f56 '' '' '' '' '' 'X',
'VRKME_DN_BL' '' text-f57 '' '' '' '' '' 'X',
'EANNR' '' ' ' '' '' '' '' '' 'X'.
**********************************************************************
* 删除交货单数量为0的条目
IF p_del = 'X'.
* delete git_output where vbeln_dn <> '' and lgmng_dn = 0.
DATA: BEGIN OF lt_filter OCCURS 10,
vbeln_dn
LIKE likp-vbeln,
lgmng_dn
LIKE lips-lgmng,
END OF lt_filter.
LOOP AT git_output INTO gwa_output.
MOVE-CORRESPONDING gwa_output TO lt_filter.
COLLECT lt_filter.
ENDLOOP.
DELETE lt_filter WHERE lgmng_dn <> 0 OR vbeln_dn = ''.
RANGES: lr_filter FOR likp-vbeln.
LOOP AT lt_filter.
lr_filter
-sign = 'I'.
lr_filter
-option = 'EQ'.
lr_filter
-low = lt_filter.
APPEND lr_filter.
ENDLOOP.
IF NOT lr_filter IS INITIAL.
DELETE git_output WHERE vbeln_dn IN lr_filter.
ENDIF.
ENDIF.
**********************************************************************
IF NOT erdat1 IS INITIAL.
DELETE git_output WHERE erdat_likp NOT IN erdat1.
ENDIF.
IF NOT erzet1 IS INITIAL.
DELETE git_output WHERE erzet_likp NOT IN erzet1.
ENDIF.
IF NOT cpudt IS INITIAL.
DELETE git_output WHERE cpudt NOT IN cpudt.
ENDIF.
IF NOT cputm IS INITIAL.
DELETE git_output WHERE cputm NOT IN cputm.
ENDIF.
**********************************************************************
* 删除不是48小时的订单
* IF p_th = 'X'.
* DATA: temp_date TYPE dats.
* LOOP AT git_output INTO gwa_output.
* CLEAR temp_date.
* temp_date = gwa_output-vdatu - gwa_output-erdat.
* IF temp_date <> 1."add by yk 原来的两天改为一天.
* DELETE git_output.
* ENDIF.
* ENDLOOP.
* ENDIF.
**********************************************************************
**********************************************************************
* 删除不是24小时的订单 ADD BY YK
* IF p_one = 'X'.
* DATA: temp_date_one TYPE dats.
* LOOP AT git_output INTO gwa_output.
* CLEAR temp_date_one.
* temp_date_one = gwa_output-vdatu - gwa_output-erdat.
* IF temp_date_one <> 0."add by y
* DELETE git_output.
* ENDIF.
* ENDLOOP.
* ENDIF.
**********************************************************************
*---加上订单描述
DATA: temp_date_ddlx TYPE dats.
DATA: temp_date_one TYPE dats.
LOOP AT git_output INTO gwa_output.
CLEAR temp_date_one.
temp_date_ddlx
= gwa_output-vdatu - gwa_output-erdat.
IF temp_date_ddlx = 0."add by y
* gwa_output-ddlx = '24小时订单'.
MODIFY git_output FROM gwa_output.
ENDIF.
IF temp_date_ddlx = 1.
* gwa_output-ddlx = '48小时订单'.
MODIFY git_output FROM gwa_output.
ENDIF.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program
= sy-repid
* I_CALLBACK_PF_STATUS_SET = 'FRM_SET_STATUS'
* I_CALLBACK_USER_COMMAND = 'FRM_USER_COMMAND'
is_layout
= gwa_layout
it_fieldcat
= git_field
it_sort
= git_sort
i_default
= 'X'
i_save
= 'A'
TABLES
t_outtab
= git_output
EXCEPTIONS
program_error
= 1
OTHERS = 2.
* IF sy-subrc <> 0.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
* ENDIF.
ENDFORM. " frm_output
*&---------------------------------------------------------------------*
*& Form frm_set_status
*&---------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
FORM frm_set_status USING rt_extab TYPE slis_t_extab.
* SET PF-STATUS 'GS_1000' EXCLUDING RT_EXTAB.
ENDFORM. "FRM_SET_STATUS
*&---------------------------------------------------------------------*
*& Form frm_user_command
*&---------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
FORM frm_user_command USING rf_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield.
* DATA: l_ok_code TYPE sy-ucomm,
* l_valid(1) TYPE c.
* l_ok_code = rf_ucomm.
* CLEAR: rf_ucomm.
*
***---screen=>internal table
** CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
** IMPORTING
** E_GRID = go_gui_alv_grid.
** CALL METHOD go_gui_alv_grid->CHECK_CHANGED_DATA
** IMPORTING
** E_VALID = L_VALID.
**
**---get 双击行的相关数据
*
* read table git_PLAF into gwa_PLAF index RS_SELFIELD-TABINDEX.
*
**
***---PAI
**
*
* CASE l_ok_code.
* WHEN '&IC1'."双击
* case rs_selfield-FIELDNAME.
* when 'KDAUF'."双击销售订单字段
* CHECK gwa_PLAF-KDAUF IS NOT INITIAL.
* "跳转到销售订单显示
* SET PARAMETER ID 'AUN' FIELD gwa_PLAF-KDAUF.
* CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
* when others."默认情况
* CHECK gwa_PLAF-plnum IS NOT INITIAL.
* "跳转到计划订单显示
* SET PARAMETER ID 'PAF' FIELD gwa_PLAF-plnum.
* CALL TRANSACTION 'MD13' AND SKIP FIRST SCREEN.
* endcase.
*
* WHEN OTHERS.
* ENDCASE.
*
**
**
***---PBO
**
*** LOOP AT git_output INTO gwa_output.
***
*** ENDLOOP.
**
***---internal table=>screen
** RS_SELFIELD-REFRESH = 'X'.
ENDFORM. "USER_COMMAND
*&---------------------------------------------------------------------*
*& Form FRM_PROCESS_DATA1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_process_data1 .
DATA: BEGIN OF v_itab OCCURS 0,
vbeln_dn
TYPE lips-vbeln,
lgmng_dn
TYPE lips-lgmng,
END OF v_itab.
DATA: vw_itab LIKE LINE OF v_itab.
DATA: v_itab1 LIKE TABLE OF v_itab WITH HEADER LINE.
LOOP AT git_output INTO gwa_output WHERE vbeln_dn <> ''. "取出交货单号不为空数据
vw_itab
-vbeln_dn = gwa_output-vbeln_dn.
vw_itab
-lgmng_dn = gwa_output-lgmng_dn.
APPEND vw_itab TO v_itab.
ENDLOOP.
SORT v_itab BY vbeln_dn ASCENDING.
LOOP AT v_itab. " 汇总数据
COLLECT v_itab INTO v_itab1.
ENDLOOP.
RANGES: v_rangs FOR vbrk-vbeln.
LOOP AT v_itab1. "将数据为0的存入rangs
IF v_itab1-lgmng_dn = 0.
v_rangs
-sign = 'I'.
v_rangs
-option = 'EQ'.
v_rangs
-low = v_itab1-vbeln_dn.
APPEND v_rangs.
ENDIF.
ENDLOOP.
IF v_rangs[] IS NOT INITIAL.
DELETE git_output WHERE vbeln_dn IN v_rangs. "删除数据为0的数据
ENDIF.
ENDFORM. " FRM_PROCESS_DATA1
INCLUDE zsdr017_inc.