【ABAP系列】SAP BOM反查

前言部分
大家可以关注我的公众号,公众号里的排版更好,阅读更舒适。
正文部分
TCODE::CS15
或者函数::CS_WHERE_USED_MAT
tables : stpo,stas,mara,makt. data : begin of itab occurs ,
matnr like mast-matnr,
menge like stpo-menge,
end of itab. data : begin of alttab occurs ,
matnr like mast-matnr,
menge like stpo-menge,
end of alttab. data : begin of top_code occurs ,
matnr(),
maktx(),
meins(),
menge like stpo-menge,
matkl(),
wrkst(),
end of top_code. data : begin of makr occurs ,
maker(),
idnlf(),
end of makr. data : begin of usedtab occurs .
include structure stpov.
data : end of usedtab. data : begin of equicat occurs .
include structure cscequi.
data : end of equicat. data : begin of kndcat occurs .
include structure cscknd.
data : end of kndcat. data : begin of matcat occurs .
include structure cscmat.
data : end of matcat. data : begin of stdcat occurs .
include structure cscstd.
data : end of stdcat. data : begin of tplcat occurs .
include structure csctpl.
data : end of tplcat. data : top_cnt() type n,
m_cnt() type n,
lin() type n,
line_cnt() type n. selection-screen begin of block blk1 with frame.
selection-screen : comment () text-,
skip.
parameters : matnr like marc-matnr obligatory,
werks like marc-werks obligatory default 'PQ50'.
select-options : bdate for sy-datum default sy-datum to sy-datum
no-extension obligatory.
selection-screen end of block blk1. start-of-selection.
itab-matnr = matnr.
itab-menge = .
append itab.
clear itab. perform get_top_code. ************************************
*&---------------------------------------------------------------------*
*& Form GET_TOP_CODE
*&---------------------------------------------------------------------*
form get_top_code. clear lin.
describe table itab lines lin.
if lin = .
exit.
endif. loop at itab.
call function 'CS_WHERE_USED_MAT'
exporting
datub = bdate-high
datuv = bdate-low
matnr = itab-matnr
werks = werks
tables
wultb = usedtab
equicat = equicat
kndcat = kndcat
matcat = matcat
stdcat = stdcat
tplcat = tplcat
exceptions
call_invalid =
material_not_found =
no_where_used_rec_found =
no_where_used_rec_selected =
no_where_used_rec_valid =
others = . clear line_cnt.
describe table usedtab lines line_cnt.
if line_cnt = .
move itab-matnr to top_code-matnr.
top_code-menge = itab-menge.
collect top_code.
clear top_code.
else.
loop at usedtab where postp ne 'F' and datuv le bdate-high
and ( sumfg = ' ' or sumfg = 'x' ).
select single lkenz into stas-lkenz from stas
where stlty = 'M'
and stlnr = usedtab-stlnr
and stlal = ''
and stlkn = usedtab-stlkn
and datuv le bdate-low
and lkenz = 'X'.
if sy-subrc ne .
move usedtab-matnr to alttab-matnr.
alttab-menge = usedtab-menge * itab-menge.
collect alttab.
endif.
clear alttab.
endloop.
endif.
refresh : usedtab,equicat,kndcat,matcat,stdcat,tplcat. endloop. refresh itab.
itab[] = alttab[].
refresh alttab.
perform get_top_code. endform. " GET_TOP_CODE
【ABAP系列】SAP BOM反查的更多相关文章
- SAP函数 CS_WHERE_USED_MAT 反查上层BOM
遇到用户要根据下层物料反查最上层BOM物料是什么. 试了一下,通过函数 CS_WHERE_USED_MAT 来查询,但是只能往上查询一层,类似事务码CS15的效果.如果要找最上层物料,需要自己写迭代进 ...
- 【ABAP系列】SAP GUI740 PATCH5出现弹窗BUG
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP GUI740 PATCH ...
- SAP MM 根据采购订单反查采购申请?
SAP MM 根据采购订单反查采购申请? 前日微信上某同行发来一个message,说是想知道如何通过采购订单号查询到其前端的采购申请号. 笔者首先想到去检查采购订单相关的常用报表ME2L/ME2M/M ...
- 单层反查BOM
*&---------------------------------------------------------------------* *& Report YCX_001 * ...
- 【ABAP系列】SAP ABAP BAPI_REQUISITION_CREATE创建采购申请
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP BAPI_RE ...
- 【ABAP系列】SAP ABAP 字符编码与解码、Unicode
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP 字符编码与解码 ...
- 【ABAP系列】SAP ABAP下载带密码的Excel文件
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP下载带密码的Ex ...
- 【ABAP系列】SAP ABAP 高级业务应用程序编程(ABAP)
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP 高级业务应用程 ...
- 【ABAP系列】SAP ABAP Break Point
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP Break P ...
随机推荐
- 洛谷P3370 && 字符串哈希讲解
字符串哈希 寻找长度为n的主串s中的的匹配串T(长度为m)出现的位置或者次数问题属于字符串匹配问题. 朴素(一般)的想法就是从一个字符串的头开始for循环查找,当查找的一个字符与匹配串首字符相同时,往 ...
- MySQL更新字段来自另一个表的count()值
假设有文章post和评论comment两个表,文章表记录有评论的数量,但是这个值我们要一次更新. 如下,现在post表的comment_count都是0,我们的目标是:执行一个SQL语句,让其把统计c ...
- redis 加锁与释放锁(分布式锁)
使用Redis的 SETNX 命令可以实现分布式锁 SETNX key value 返回值 返回整数,具体为 - 1,当 key 的值被设置 - 0,当 key 的值没被设置
- CMMI分为哪几个等级?
一共分为五个等级. 1.CMMI一级,完成级.在完成级水平上,企业对项目的目标与要做的努力很清晰.项目的目标得以实现. 2.CMMI二级,管理级.在管理级水平上,企业在项目实施上能够遵守既定的计划与流 ...
- Java 工厂方法模式的简单示例
工厂方法模式:也叫工厂模式,属于类创建型模式,工厂父类(接口)负责定义产品对象的公共接口,而子类工厂则负责创建具体的产品对象. 目的:是为了把产品的实例化操作延迟到子类工厂中完成,通过工厂子类来决定究 ...
- Java技术综述
自己打算好好学习下Java,所以想先明晰Java开发中到底有哪些技术,以便以后学习的过程中,可以循序渐进,随着学习的深入,本文将不断更新. Java基础教程将Java的入门基础知识贯穿在一个实例中,逐 ...
- orm中的聚合函数,分组,F/Q查询,字段类,事务
目录 一.聚合函数 1. 基础语法 2. Max Min Sum Avg Count用法 (1) Max()/Min() (2)Avg() (3)Count() (4)聚合函数联用 二.分组查询 1. ...
- shell中条件判断if中的-z到-d
shell中条件判断if中的-z到-d的意思 [ -a FILE ] 如果 FILE 存在则为真. [ -b FILE ] 如果 FILE 存在且是一个块特殊文件则为真.[ -c FILE ] 如果 ...
- JavaScript基础——JavaScript常量和变量(笔记)
JavaScript常量和变量(笔记) Javascript代码严格区分大小写. javascript暂不支持constant关键字,不允许用户自定义常量. javascript使用var关键字声明变 ...
- CART 分类与回归树
from www.jianshu.com/p/b90a9ce05b28 本文结构: CART算法有两步 回归树的生成 分类树的生成 剪枝 CART - Classification and Regre ...