公众号:SAP Technical
本文作者:matinal
 

前言部分

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

正文部分

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反查的更多相关文章

  1. SAP函数 CS_WHERE_USED_MAT 反查上层BOM

    遇到用户要根据下层物料反查最上层BOM物料是什么. 试了一下,通过函数 CS_WHERE_USED_MAT 来查询,但是只能往上查询一层,类似事务码CS15的效果.如果要找最上层物料,需要自己写迭代进 ...

  2. 【ABAP系列】SAP GUI740 PATCH5出现弹窗BUG

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP GUI740 PATCH ...

  3. SAP MM 根据采购订单反查采购申请?

    SAP MM 根据采购订单反查采购申请? 前日微信上某同行发来一个message,说是想知道如何通过采购订单号查询到其前端的采购申请号. 笔者首先想到去检查采购订单相关的常用报表ME2L/ME2M/M ...

  4. 单层反查BOM

    *&---------------------------------------------------------------------* *& Report YCX_001 * ...

  5. 【ABAP系列】SAP ABAP BAPI_REQUISITION_CREATE创建采购申请

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP BAPI_RE ...

  6. 【ABAP系列】SAP ABAP 字符编码与解码、Unicode

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP 字符编码与解码 ...

  7. 【ABAP系列】SAP ABAP下载带密码的Excel文件

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP下载带密码的Ex ...

  8. 【ABAP系列】SAP ABAP 高级业务应用程序编程(ABAP)

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP 高级业务应用程 ...

  9. 【ABAP系列】SAP ABAP Break Point

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP Break P ...

随机推荐

  1. mongodb aggregate

    $project:修改输入文档的结构.可以用来重命名.增加或删除域,也可以用于创建计算结果以及嵌套文档. $match:用于过滤数据,只输出符合条件的文档.$match使用MongoDB的标准查询操作 ...

  2. Mongodb数据模型

    描述表关系的方式: 方式一:嵌入式 > db.person.find({name:'zjf'}).pretty() { "_id" : ObjectId("592f ...

  3. 实践:Linux用户、组和密码相关文件被破坏如何恢复系统

    我们先看一下用户用户组和密码相关文件: 1 2 3 4 5 6 7 8 9 [root❄centos7 ~]☭ ll /etc/passwd* /etc/shadow* /etc/group* /et ...

  4. redis集群搭建及java(jedis)链接

    1.创建一个redis-cluster 目录 mkdir -p /usr/local/redis-cluster 创建6台redis服务器(单机下学习) mkdir 7001.mkdir 7002.m ...

  5. vue 设置当前页背景色

    beforeRouteEnter(to, from, next) { // 添加背景色 document.querySelector('body').setAttribute('style', 'ba ...

  6. C# WinForm捕获全局异常(捕获未处理的异常)

    static class Program { /// <summary> /// 应用程序的主入口点. /// </summary> [STAThread] static vo ...

  7. Java I/O 全面详解

    1.什么是IO Java中I/O操作主要是指使用Java进行输入,输出操作. Java所有的I/O机制都是基于数据流进行输入输出,这些数据流表示了字符或者字节数据的流动序列.Java的I/O流提供了读 ...

  8. List集合遍历的三种方法

    测试数据: List<String> list = new ArrayList<String>(); list.add("java"); list.add( ...

  9. 手动升级 Confluence - 规划你的升级

    1. 确定你的升级路径 使用下面的表格来确定最佳的升级路径来让你的Confluence 从当前版本升级到最新的 Confluence 版本. 你的版本 推荐升级到 Confluence 的升级路径 2 ...

  10. Unity3D_(游戏)卡牌02_主菜单界面

      启动屏界面.主菜单界面.选关界面.游戏界面 卡牌01_启动屏界面 传送门 卡牌02_主菜单界面 传送门 卡牌03_选关界面 传送门 卡牌04_游戏界面    传送门 主菜单界面 (选择左边图标或选 ...