SAP公司间采购订单关联交货单报表源代码(自己收藏)
SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF }
.L0S31 { font-style: italic; color: #808080 }
.L0S32 { color: #3399FF }
.L0S33 { color: #4DA619 }
.L0S52 { color: #0000FF }
.L0S55 { color: #800080 }
.L0S70 { color: #808080 }
*&---------------------------------------------------------------------*
*& Report ZMMR023
*&
*&---------------------------------------------------------------------*
*&by xiaochangye 20161010
*&xiugai by dev02 20161226
*&---------------------------------------------------------------------*
report ztestxiao001.
tables:vbkd,vbak,vbrp,vbrk,ekpo,vbap,lips.
*定义ALV变量
type-pools: slis.
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid,
gt_events type slis_t_event,
gd_prntparams type slis_print_alv,
gt_sort type slis_t_sortinfo_alv,
gs_sort type slis_sortinfo_alv,
g_title type lvc_title.
data:begin of gt_out occurs 0,
ernam like ekko-ernam,"负责人
bstkd_e like vbkd-bstkd_e,"采购订单号
menge like ekpo-menge,"订单数量
bpmng like ekbe-bpmng,"收货数量
werks like ekpo-werks,"工厂
matnr like ekpo-matnr,"物料号
txz01 like ekpo-txz01,"物料描述
vbelnxs like vbkd-vbeln,"销售订单号
posnrxs like vbkd-posnr,"销售订单行项目号
kwmeng like vbep-wmeng,"销售订单数量
lfimg like lips-lfimg,"交货数量
vkorg like vbak-vkorg,"销售组织
matwa like vbap-matwa,"物料号
arktx like vbap-arktx,"物料描述
vbelnjh like vbkd-vbeln,"交互单号
posnrjh like vbkd-posnr,"交货单行项目号
vbelnfp like vbkd-vbeln,"发票号
posnrfp like vbkd-posnr,"发票行项目号
fkdat like vbrk-fkdat,"发票创建日期
end of gt_out.
data:begin of gt_huizong occurs 0,
ernam like ekko-ernam,"负责人
bstkd_e like vbkd-bstkd_e,"采购订单号
werks like ekpo-werks,"工厂
matnr like ekpo-matnr,"物料号
txz01 like ekpo-txz01,"物料描述
vbelnxs like vbkd-vbeln,"销售订单号
posnrxs like vbkd-posnr,"销售订单行项目号
lfimg like lips-lfimg,"交货数量
end of gt_huizong.
data:begin of gt_vbkd occurs 0,
bstkd_e like vbkd-bstkd_e,"采购订单号
ebeln like vbkd-vbeln,"采购订单号
vbelnxs like vbkd-vbeln,"销售订单号
posnrxs like vbkd-posnr,"销售订单行项目号
vbeln like vbkd-vbeln,"销售订单号
posnr like vbkd-posnr,"销售订单行项目号
vbelnjh like vbkd-vbeln,"交互单号
posnrjh like vbkd-posnr,"交货单行项目号
ERNAM like ekko-ERNAM,
end of gt_vbkd.
data:begin of gt_ekpo occurs 0,
ebeln like vbkd-vbeln,"采购订单号
werks like ekpo-werks,"采购工厂
matnr like ekpo-matnr,"采购物料号
txz01 like ekpo-txz01,"采购物料描述
MENGE LIKE EKPO-MENGE,"订单数量
end of gt_ekpo.
data gt_ekpo1 like gt_ekpo occurs 0 with header line.
data:begin of gt_ekbe occurs 0,
ebeln like vbkd-vbeln,"采购订单号
MENGE like ekbe-MENGE,"收货数量
BWART like ekbe-BWART,"移动类型
end of gt_ekbe.
data gt_ekbe1 like gt_ekbe occurs 0 with header line.
data:begin of gt_vbrk occurs 0,
vbelnxs like vbak-vbeln,"销售订单号
vkorg like vbak-vkorg,"销售组织
matwa like vbap-matwa,"销售物料号
arktx like vbap-arktx,"销售物料描述
end of gt_vbrk.
data:begin of gt_vbap occurs 0,
vbeln like vbap-vbeln,"销售订单号
KWMENG like vbap-KWMENG,"
end of gt_vbap.
data gt_vbap1 like gt_vbap occurs 0 with header line.
data:begin of gt_vbak occurs 0,
bstkd_e like vbkd-bstkd_e,"交货单号
posex_e like vbkd-posex_e,"交货单行项目号
vbelnjh like vbkd-vbeln,"交互单号
vbeln like vbkd-vbeln,"销售订单号
posnr like vbkd-posnr,"销售订单行项目号
end of gt_vbak.
data:begin of gt_lips occurs 0,
vbeln like lips-vbeln,"交货单号
vgbel like lips-vgbel,
vgpos like lips-vgpos,
LFIMG like lips-LFIMG,"
end of gt_lips.
data gt_lips1 like gt_lips occurs 0 with header line.
data:begin of gt_fp occurs 0,
aubel like vbrp-aubel,"销售订单号
aupos like vbrp-aupos,"销售订单行项目号
vbeln like vbrp-vbeln,"发票号
posnr like vbrp-posnr,"发票行项目号
end of gt_fp.
data:begin of gt_fpdata occurs 0,
vbeln like vbrp-vbeln,"发票号
fkdat like vbrk-fkdat,"发票日期
end of gt_fpdata.
"定义选择屏幕(输入条件)
selection-screen begin of block block1 with frame title text-001.
select-options: s_bstkd for vbkd-bstkd_e. "采购订单号
select-options: s_aubel for vbrp-aubel. "销售订单号
selection-screen end of block block1.
start-of-selection.
"取数
perform get_data.
"处理数据
perform deal_data.
"alv显示
perform alv_dis.
end-of-selection.
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form get_data .
select
a~bstkd_e
a~vbeln as vbelnxs
a~posnr as posnrxs
b~vbeln as vbelnjh
b~posnr as posnrjh
c~ERNAM
into corresponding fields of table gt_vbkd
from vbkd as a
inner join lips as b on b~vgbel = a~vbeln and b~vgpos = a~posnr
inner join ekko as c on c~EBELN = a~bstkd_e
where a~bstkd_e in s_bstkd
and a~vbeln in s_aubel.
if gt_vbkd[] is not initial. "判断查出的数据是否为空,如果为空不再执行以下的程序(initial=空)
select "从表VBKD查出销售订单类型为ZWK1,售达方为公司间的全部数据放到临时表GT_VBAK里
a~vbeln as vbeln
a~posnr
a~bstkd_e
a~posex_e
into corresponding fields of table gt_vbak
from vbkd as a
inner join vbak as b on a~vbeln = b~vbeln
where b~auart = 'ZKE1'
and ( b~kunnr = '0000002300' or b~kunnr = '0000002100'
or b~kunnr = '0000002200' or b~kunnr = '0000003100'
or b~kunnr = '0000001000' )
and a~posex_e <> ''.
loop at gt_vbak. "更改自字符串长度格式
gt_vbak-vbelnjh = gt_vbak-bstkd_e+0(10).
modify gt_vbak.
clear gt_vbak.
endloop.
loop at gt_vbkd. "更改自字符串长度格式
gt_vbkd-ebeln = gt_vbkd-bstkd_e+0(10).
modify gt_vbkd.
clear gt_vbkd.
endloop.
"删除gt_vbkd中交货单号及航项目在gt_vbak中找不到的行
* loop at gt_vbkd.
* read table gt_vbak with key vbelnjh = gt_vbkd-vbelnjh
* posex_e = gt_vbkd-posnrjh.
* if sy-subrc <> 0.
* delete gt_vbkd.
* endif.
* endloop.
*对gt_vbkd中交货单号机航项目在gt_vbak中找到的行,
*修改销售订单号及航项目=gt_vbak中的销售订单号及航项目
loop at gt_vbkd.
read table gt_vbak with key vbelnjh = gt_vbkd-vbelnjh
posex_e = gt_vbkd-posnrjh.
if sy-subrc = 0.
gt_vbkd-vbeln = gt_vbak-vbeln.
gt_vbkd-posnr = gt_vbak-posnr.
endif.
modify gt_vbkd.
clear gt_vbkd.
endloop.
"查出销售订单号,销售订单行项目,发票号,发票行项目,发票日期放到临时表 get_FP里
select
aubel
aupos
vbeln
posnr
into corresponding fields of table gt_fp
from vbrp
for all entries in gt_vbkd
where aubel = gt_vbkd-vbeln and aupos = gt_vbkd-posnr.
"查出发票的下达日期放到GT_FPDATA这个临时表里
select
vbeln
fkdat
into corresponding fields of table gt_fpdata
from vbrk
for all entries in gt_fp
where vbeln = gt_fp-vbeln.
"查出采购订单的工厂、物料号、采购数量、和物料描述放在临时表GT_EKPO里。
select
ebeln
werks
matnr
txz01
MENGE
into corresponding fields of table gt_ekpo
from ekpo
for all entries in gt_vbkd
where ebeln = gt_vbkd-ebeln
and LOEKZ = ''.
* 收货数量
select
ebeln
MENGE
BWART
into corresponding fields of table gt_ekbe
from ekbe
for all entries in gt_vbkd
where ebeln = gt_vbkd-ebeln
and BWART <> ''.
"查出销售订单的销售组织、物料号和物料描述在临时表GT_VBRK
select
a~vbeln as vbelnxs
a~vkorg
b~matwa
b~arktx
into corresponding fields of table gt_vbrk
from vbak as a
inner join vbap as b on b~vbeln = a~vbeln
for all entries in gt_vbkd
where a~vbeln = gt_vbkd-vbelnxs.
* 销售订单数量
select
vbeln
KWMENG
into corresponding fields of table gt_vbap
from vbap
for all entries in gt_vbkd
where vbeln = gt_vbkd-vbelnxs.
* 交货数量
select
vbeln
LFIMG
into corresponding fields of table gt_lips
from lips
for all entries in gt_vbkd
where vbeln = gt_vbkd-vbelnjh and LGORT <> ''.
endif.
endform. " GET_DATA
*&---------------------------------------------------------------------*
*& Form DEAL_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form deal_data . "给需要输出的字段赋值
loop at gt_ekbe.
if gt_ekbe-BWART = '102'.
gt_ekbe-MENGE = 0 - gt_ekbe-MENGE.
endif.
gt_ekbe-BWART = ''.
modify gt_ekbe.
clear gt_ekbe.
endloop.
sort gt_ekbe by ebeln.
loop at gt_ekbe.
collect gt_ekbe into gt_ekbe1.
endloop.
sort gt_vbap by VBELN.
loop at gt_vbap.
collect gt_vbap into gt_vbap1.
endloop.
sort gt_lips by VBELN.
loop at gt_lips.
collect gt_lips into gt_lips1.
endloop.
loop at gt_vbkd.
gt_out-ernam = gt_vbkd-ernam .
gt_out-bstkd_e = gt_vbkd-bstkd_e.
gt_out-vbelnxs = gt_vbkd-vbelnxs.
gt_out-posnrxs = gt_vbkd-posnrxs.
gt_out-vbelnjh = gt_vbkd-vbelnjh.
gt_out-posnrjh = gt_vbkd-posnrjh.
read table gt_fp with key aubel = gt_vbkd-vbeln
aupos = gt_vbkd-posnr.
if sy-subrc = 0.
gt_out-vbelnfp = gt_fp-vbeln.
gt_out-posnrfp = gt_fp-posnr.
endif.
read table gt_fpdata with key vbeln = gt_out-vbelnfp.
if sy-subrc = 0.
gt_out-fkdat = gt_fpdata-fkdat.
endif.
read table gt_ekpo with key ebeln = gt_vbkd-ebeln.
if sy-subrc = 0.
gt_out-werks = gt_ekpo-werks."工厂
gt_out-matnr = gt_ekpo-matnr."物料号
gt_out-txz01 = gt_ekpo-txz01."物料描述
gt_out-menge = gt_ekpo-menge."
endif.
read table gt_ekbe1 with key ebeln = gt_vbkd-ebeln.
if sy-subrc = 0.
gt_out-bpmng = gt_ekbe1-MENGE."
endif.
read table gt_vbrk with key vbelnxs = gt_vbkd-vbelnxs.
if sy-subrc = 0.
gt_out-vkorg = gt_vbrk-vkorg."销售组织
gt_out-matwa = gt_vbrk-matwa."物料号
gt_out-arktx = gt_vbrk-arktx."物料描述
endif.
read table gt_vbap1 with key vbeln = gt_vbkd-vbelnxs.
if sy-subrc = 0.
gt_out-kwmeng = gt_vbap1-kwmeng ."销售组织
endif.
read table gt_lips1 with key vbeln = gt_vbkd-vbelnjh.
if sy-subrc = 0.
gt_out-lfimg = gt_lips1-lfimg ."销售组织
endif.
call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
exporting
input = gt_out-matnr
importing
output = gt_out-matnr.
call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
exporting
input = gt_out-matwa
importing
output = gt_out-matwa.
call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
exporting
input = gt_out-vbelnxs
importing
output = gt_out-vbelnxs.
append gt_out.
clear gt_out.
endloop.
loop at gt_out.
MOVE-CORRESPONDING gt_out TO GT_HUIZONG.
collect gt_huizong.
endloop.
loop at gt_out.
read table gt_huizong with key bstkd_e = gt_out-bstkd_e
vbelnxs = gt_out-vbelnxs
posnrxs = gt_out-posnrxs.
if sy-subrc = 0.
gt_out-lfimg = gt_huizong-lfimg ."销售组织
endif.
modify gt_out.
clear gt_out.
endloop.
sort gt_out by BSTKD_E VBELNXS POSNRXS.
DELETE ADJACENT DUPLICATES FROM gt_out COMPARING BSTKD_E VBELNXS POSNRXS.
endform. " DEAL_DATA
*&---------------------------------------------------------------------*
*& Form ALV_DIS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form alv_dis .
*创建字段宏定义和输出字段赋值
perform frm_build_fieldcatalog.
*定义输出模式
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-f2code = '&IC1'. "Sets fcode for when double click(press f2)
"gd_layout-box_fieldname = 'BOX'.
gd_layout-cell_merge = 'X'.
gd_layout-zebra = 'X'.
*使用ALV输出函数
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
**用户操作的参数
* I_CALLBACK_USER_COMMAND = 'USER_COMMAND_4000' "自定义指向代码
*ALV输出状态的参数
i_callback_pf_status_set = 'SET_PF_STATUS_3200' "菜单
*输出模式参数
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
is_print = gd_prntparams
i_grid_title = g_title
i_save = 'X'
"it_sort = gt_sort[]
tables
*用于输出ALV的内表
t_outtab = gt_out
exceptions
*定义输出异常时的信息,配合MESSAGE语句使用
program_error = 1
others = 2.
endform. " ALV_DIS
*&---------------------------------------------------------------------*
*& Form FRM_BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form frm_build_fieldcatalog .
"创建字段宏定义
define add_field.
fieldcatalog-fieldname = &1. "内表字段名称
fieldcatalog-seltext_m = &2. "字段输出名称
fieldcatalog-no_zero = &3. "是否显示零
fieldcatalog-just = &4. "对齐方式
fieldcatalog-emphasize = &5. "是否高亮
fieldcatalog-checkbox = &6. "是否带单选框
fieldcatalog-edit = &7. "可编辑
append fieldcatalog.
clear fieldcatalog.
end-of-definition.
*输出字段赋值
add_field 'ERNAM' '负责人' '' 'L' '' '' ''.
add_field 'BSTKD_E' '采购订单号' '' 'L' '' '' ''.
add_field 'MENGE' '订单数量' '' 'L' '' '' ''.
add_field 'BPMNG' '收货数量' '' 'L' '' '' ''.
add_field 'WERKS' '工厂' '' 'L' '' '' ''.
add_field 'MATNR' '物料号' '' 'L' '' '' ''.
add_field 'TXZ01' '物料描述' '' 'L' '' '' ''.
add_field 'VBELNXS' '销售订单号' '' 'L' '' '' ''.
add_field 'POSNRXS' '销售订单行项目号' '' 'L' '' '' ''.
add_field 'VKORG' '销售组织' '' 'L' '' '' ''.
add_field 'KWMENG' '订单数量' '' 'L' '' '' ''.
add_field 'LFIMG' '交货数量' '' 'L' '' '' ''.
add_field 'MATWA' '物料号' '' 'L' '' '' ''.
add_field 'ARKTX' '物料描述' '' 'L' '' '' ''.
add_field 'VBELNJH' '交货单号' '' 'L' '' '' ''.
add_field 'POSNRJH' '交货单行项目号' '' 'L' '' '' ''.
add_field 'VBELNFP' '发票号' '' 'L' '' '' ''.
add_field 'POSNRFP' '发票行项目号' '' 'L' '' '' ''.
add_field 'FKDAT' '发票下达日期' '' 'L' '' '' ''.
endform. " FRM_BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
*& Form set_pf_status_3200
*&---------------------------------------------------------------------*
* GUI定义
*----------------------------------------------------------------------*
* -->EXTAB text
*----------------------------------------------------------------------*
form set_pf_status_3200 using extab type slis_t_extab.
data: r_ucomm like sy-ucomm.
set pf-status 'MYSTATUS'.
endform.
SAP公司间采购订单关联交货单报表源代码(自己收藏)的更多相关文章
- sap 如何获取公司间采购订单或销售订单的交货状态
在上SAP项目过程,上了SD模块的企业一般都要做一些跟公司间采购订单或销售订单的交货状态的报表,通过这些报表可以经客户的业务上提供很大的灵活性,至于如何的灵活,还是那句老话“谁用谁知道".1 ...
- SAP采购订单历史明细报表源代码(自己收藏)
SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF } ...
- SAP 公司间STO场景中外向交货单过账后自动触发内向交货单功能的实现
SAP 公司间STO场景中外向交货单过账后自动触发内向交货单功能的实现 如下STO,是从公司代码SZSP转入CSAS, 如下图示的内向交货单180018660.该内向交货单是在外向交货单8001632 ...
- SAP MM 公司间STO里外向交货单与内向交货单里序列号对应关系
SAP MM 公司间STO里外向交货单与内向交货单里序列号对应关系 笔者所在的A项目,后勤模块里有启用HU管理,序列号管理,批次管理等功能,以实现各个业务场景下的追溯. 公司间转储订单流程里,如果是整 ...
- SAP MM 按采购订单查询付款信息的报表?
SAP MM 按采购订单查询付款信息的报表? 上午给P3项目采购部门用户做了一个采购相关的报表的培训.培训过程中,客户的采购部门经理提出了一个问题:有没有报表能查询到各个采购订单的付款情况,显示采购订 ...
- SAP IDOC 通过采购订单输出消息生成销售订单
题记: 在网络上看到一篇类似的公众号文章,叫<通过IDoc逐步指导PO&SO集成>,个人觉得整个配置过程中还是少了一些重点配置,也少了说明整个功能的核心逻辑,那么,趁着这个机会,就 ...
- SAP MM 根据采购订单反查采购申请?
SAP MM 根据采购订单反查采购申请? 前日微信上某同行发来一个message,说是想知道如何通过采购订单号查询到其前端的采购申请号. 笔者首先想到去检查采购订单相关的常用报表ME2L/ME2M/M ...
- 【SD系列】SAP SD模块-公司间销售简介
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[SD系列]SAP SD模块-公司间销售简介 ...
- 采购订单限价(包含阶梯价)ME_PROCESS_PO_CUST
为了能管控到钱财的每个环节,公司要求采购订单需要使用物料限价,当有报价低于先前的价格时,在采购订单保存时,更新最低限价 BADI:ME_PROCESS_PO_CUST process~item里做限价 ...
随机推荐
- python+selenium 浏览器的问题
以前用selenium调用firefox是不需要驱动的,最近安装了python3.52+最新的firefox 发现调不起来了 搜索以后发现Firefox 47+需要搞个firefox的驱动 gecko ...
- spring 属性注入
Spring的核心技术室依赖注入,下面是依赖注入之属性注入的实现过程,牛刀小试,请看效果. 1.首先添加Spring.Web引用.本例中是使用分层思想来演示的,下面是项目的结构和UserModel类的 ...
- Python语言十分钟快速入门
Python(蟒蛇)是一种动态解释型的编程语言.Python可以在Windows.UNIX.MAC等多种操作系统上使用,也可以在Java..NET开发平台上使用. AD:[51CTO技术沙龙]移动时代 ...
- 查找树ADT
通过二叉查找树实现排序的例程 /** * 无论排序的对象是什么,都要实现Comparable接口 * * @param <T> */ public class BinaryNode< ...
- ThreadLocal是什么?保证线程安全
早在JDK 1.2的版本中就提供Java.lang.ThreadLocal,ThreadLocal为解决多线程程序的并发问题提供了一种新的思路.使用这个工具类可以很简洁地编写出优美的多线程程序. 当使 ...
- ftp协议详解
客户端与服务器之间,需要多条连接才能完成应用的协议,属于复杂协议.如FTP,PPTP,H.323和SIP均属于复杂协议. 这里主要介绍ftp协议的工作原理.首先,ftp通信协议有两种工作模式,被动模式 ...
- 【转】Source Insight的Alt + W键不能使用的解决办法
转载地址:http://velep.com/archives/607.html 对于Source Insight 3.5,习惯于使用Alt + W组合键并配合数字键来切换文件窗口,带来无比的便利.但是 ...
- sqlite嵌入式数据库C语言基本操作(1)
sqlite嵌入式数据库C语言基本操作(1) :first-child{margin-top:0!important}img.plugin{box-shadow:0 1px 3px rgba(0,0, ...
- eaysui 利用datagrid 实现左右移除数据
效果图 $(function () { var logBussnessAgentData = []; var logInspectionEngineerData = []; //选中 $(" ...
- python中的generator(coroutine)浅析和应用
背景知识: 在Python中一个function要运行起来,它在python VM中需要三个东西. PyCodeObject,这个保存了函数的代码 PyFunctionObject,这个代表一个虚拟机 ...